Sign in to follow this  

Applying Quaternion Rotation To A Vector

This topic is 3375 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alright, I am making a program in C#/XNA and I have some Particles which are emitted from an Emitter. The Particle's are given some initial 3D velocity, such as Vector3(50, 0, 0). The Emitter has a quaternion representing it's rotation, and I want it so that when the Emitter is rotated, it affects the starting velocity of the Particles (i.e. so it always looks like particle's are emitted from the top of the emitter), but I just can't get it to work. This is how I assumed it would be done:
// Initialize Particle Properties
cParticle.cVelocity = new Vector3(50, 0, 0);

// Rotate the Emitter around the Z-axis according to some Angle
mcEmitter.mcRotation = new Quaternion(Vector3.Forward, mfAngle);
mcEmitter.mcRotation.Normalize();

// Rotate the Particle according to the Emitter
cParticle.cVelocity = Vector3.Transform(cParticle.cVelocity, mcEmitter.mcRotation);


I'm sure I'm doing something wrong with how I'm rotating the Velocity vector, but I'm not sure what. Can anybody see the problem? Thanks. [Edited by - deadlydog on September 19, 2008 10:54:09 AM]

Share this post


Link to post
Share on other sites
I got it, I was just defining a quaternion, instead of computing the actual rotation quaternion that I wanted, so the line:

mcEmitter.mcRotation = new Quaternion(Vector3.Forward, mfAngle);

just needed to be replaced with:

mcEmitter.mcRotation = Quaternion.CreateFromAxisAngle(Vector3.Forward, mfAngle);

So simple I kept overlooking it.

Share this post


Link to post
Share on other sites

This topic is 3375 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this