   Help with particle rotation!
  Hi guys,I'm modifying an existing spark particle system, which only has Y movement for now. I managed to add in the motion in X and Y direction but I would like to ask about the particle rotation in Z. So I have this particle texture to represent the streak, something like this:   |   |   |and my coordinate is: positive Y up, positive X to the right, and positive Z is into the screen. I have the particle follows gravity but couldn't find a good way to rotate the particle around the z axis.I tried to store an old position and current position of the particle, then calculate the directional vector of the particle. I then transform it to camera space and take the tangent of x / y component of the directional vector. The problem I observe is that when I move the camera around, the rotation of the particle starts rotate in the opposite direction until it flips.I wonder how do you guys deal with the rotation of the particle. If you guys can give me some advice I would greatly appreciate it. Thanks in advance.   
  You want to look into Matrices, Rotation Matrices and Quarternions. A 4x4 Matrix can hold rotation and position; a 3x3 Matrix can hold rotation and a Quaternion can also hold rotation.And, if you multiply a vector by a Rotation Matrix or Quaternion, you get a rotated vector. Multiply it by a position and rotation matrix and it both moves the position of the vector and rotates it.   ;Quote:The problem I observe is that when I move the camera around, the rotation of the particle starts rotate in the opposite direction until it flips.Yup :(The (particle.velocity cross camera.at) is going to be up from one side and down from the other.  You could:* Special case the calculation so that it always forces it to face up.* Use a symmetric textures so that you can't tell it flipped.* When spawning the particle store a local "up" that you use as a hint for creating your bilboard* try playing with your particle scale, having too large a particle when it is velocity aligned can make the visual pop more prominent.* Or, you could just not care. Hopefully the sparks are moving fast enough that not many people are going to whip the camera around and notice.--edit.If you are talking about the particle rotating CW from one side and CCW from the other, but you always want it rotating "top away from center of explosion" to make rolling smoke or something, then you have to go with #1 or #3 to make sure the particle knows what "up" is so you can know when to flip the flip to get the rotation you are looking for.   