# codewings

Member Since 08 Dec 2012
Offline Last Active Mar 10 2013 08:35 AM

### Resize a whole particle system

08 December 2012 - 01:58 PM

Hi,

I am now want to make my particle system support scaling. My particle system can be attached to an arbitrary node. Here is my plan:

1. decompose the final transformation of the particle system to get the scaling component, then remove it from the final transformation.
2. transform the particle system by using the matrix get from step 1.
3. use the scaling component to scale the parameters of the particle system ( velocity, acceleration, position, size and so on ).

I am not sure if I can extract the scaling component from the matrix by using the following code:

const FLOAT Sum0 = (M[0][0] * M[0][0]) + (M[0][1] * M[0][1]) + (M[0][2] * M[0][2]);
const FLOAT Sum1 = (M[1][0] * M[1][0]) + (M[1][1] * M[1][1]) + (M[1][2] * M[1][2]);
const FLOAT Sum2 = (M[2][0] * M[2][0]) + (M[2][1] * M[2][1]) + (M[2][2] * M[2][2]);

FLOAT ScaleX = sqrt(Sum0);
FLOAT InvScaleX = 1.f / ScaleX;
M[0][0] *= InvScaleX;
M[0][1] *= InvScaleX;
M[0][2] *= InvScaleX;

FLOAT ScaleY = sqrt(Sum1);
FLOAT InvScaleY = 1.f / ScaleY;
M[1][0] *= InvScaleY;
M[1][1] *= InvScaleY;
M[1][2] *= InvScaleY;

FLOAT ScaleZ = sqrt(Sum2);
FLOAT InvScaleZ = 1.f / ScaleZ;
M[2][0] *= InvScaleZ;
M[2][1] *= InvScaleZ;
M[2][2] *= InvScaleZ;