• Advertisement
Sign in to follow this  

C++ Rotate a Vec around another Vec

This topic is 3036 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

I need to rotate a vector around another 3d vector by x degrees. Basically a mirror of my current vector where the mirror is the vector in which we are rotating around. ................Mirror....................... My vec - (<) | (>) - My rotated vec I was looking for a function like VectorRotate(StartVec, Angletorotate, Rotatearoundvector, Rotatedvector);

Share this post


Link to post
Share on other sites
Advertisement
Quote:
I need to rotate a vector around another 3d vector by x degrees. Basically a mirror of my current vector where the mirror is the vector in which we are rotating around.
Rotation and mirroring are two different things, but I'm going to assume it's vector rotation that you're interested in here.

There's a fairly straightforward equation for computing a rotated vector given a vector, an angle, and an axis, but it's more common to see this particular transformation expressed in matrix form.

Here is a reference that shows how to construct a matrix representing an axis-angle rotation (note that you may need to transpose the matrix depending on what convention you're using). Also, if you're using an existing math library, it's likely you already have a function available that will construct such a matrix for you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement