Jump to content
  • Advertisement
Sign in to follow this  
Trauts

Rotating a 3D Vector along a plane

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

how can I rotate a 3D vector along an arbitrary plane? for example... I have a vector that points straight up the wall, and one that points to the right along the wall, and I want to rotate it to the left, so that its pointing diagonally across the wall The angle is arbitrary. So I might want to rotate the vector left or right 45 degrees, etc. for convenience, the normal to the wall is called 'up', going up in the z axis is 'forward' and going to the right facing away from the wall is 'right'

Share this post


Link to post
Share on other sites
Advertisement
So, to clarify in your terminology, you have a vector that initially points in the "right" direction and you wish to rotate about the "up" axis so that the vector then points "right and forward" (or somewhere else in the right/forward plane)---remaining within the plane of the wall?

You could basically apply a quaternion rotation to the vector that rotates it about your "up" direction, where "up" is normal to whatever plane you're interested in.

Share this post


Link to post
Share on other sites
I don't know anything about how to do that :-/



_____________
| |
| |
| |
| |
|___________|


Supposing that was my plane, the y axis would be 'forward' and the x axis would be 'right'. I want to rotate the 'forward' vector an arbitrary number of degrees left or right

The only problem is that its not as simple as xy plane... its a 3D plane.

Edit: These are the built-in functions available. I don't have a clue what they do:

void QuaternionSlerp( const Quaternion &p, const Quaternion &q, float t, Quaternion &qt );
void QuaternionSlerpNoAlign( const Quaternion &p, const Quaternion &q, float t, Quaternion &qt );
void QuaternionBlend( const Quaternion &p, const Quaternion &q, float t, Quaternion &qt );
void QuaternionBlendNoAlign( const Quaternion &p, const Quaternion &q, float t, Quaternion &qt );
void QuaternionIdentityBlend( const Quaternion &p, float t, Quaternion &qt );
float QuaternionAngleDiff( const Quaternion &p, const Quaternion &q );
void QuaternionScale( const Quaternion &p, float t, Quaternion &q );
void QuaternionAlign( const Quaternion &p, const Quaternion &q, Quaternion &qt );
float QuaternionDotProduct( const Quaternion &p, const Quaternion &q );
float QuaternionNormalize( Quaternion &q );
void QuaternionAdd( const Quaternion &p, const Quaternion &q, Quaternion &qt );
void QuaternionMult( const Quaternion &p, const Quaternion &q, Quaternion &qt );
void QuaternionMatrix( const Quaternion &q, matrix3x4_t &matrix );
void QuaternionMatrix( const Quaternion &q, const Vector &pos, matrix3x4_t &matrix );
void QuaternionAngles( const Quaternion &q, QAngle &angles );
void AngleQuaternion( const QAngle& angles, Quaternion &qt );
void QuaternionAngles( const Quaternion &q, RadianEuler &angles );
void AngleQuaternion( RadianEuler const &angles, Quaternion &qt );
void QuaternionAxisAngle( const Quaternion &q, Vector &axis, float &angle );
void AxisAngleQuaternion( const Vector &axis, float angle, Quaternion &q );
void BasisToQuaternion( const Vector &vecForward, const Vector &vecRight, const Vector &vecUp, Quaternion &q );

Share this post


Link to post
Share on other sites
Rotate around plane normal, that is, axis of rotation given by cross product of these vectors, and angle is angle you want.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dmytry
Rotate around plane normal, that is, axis of rotation given by cross product of these vectors, and angle is angle you want.


Well, how do rotate around the normal?

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!