# Rotating a 3D Vector along a plane

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

## 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 on other sites
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 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 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 on other sites
Quote:
 Original post by DmytryRotate 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?

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632959
• Total Posts
3009461
• ### Who's Online (See full list)

There are no registered users currently online

×