rotateVector()

Synopsis

Rotates a vector about an axis, returning a new vector . The axis is defined by an axis vector . Positive angles rotate about the axis according to the Right-Hand Rule. This function will always return a unit vector . See also vectorAt() which is a simplified version of this function for 2D problems.

Syntax

rotateVector ( base As Vector, _
               angle As Number, _
               axis As Vector ) As Vector
Argument Type Description
base Vector The vector to be rotated.
angle Number Angle of rotation
axis Vector The direction of the axis.

Example 1

Rotate an X-axis aligned vector by 90 degrees around the Z axis
Intent >rotateVector(UnitX, 90, UnitZ) 
--> Vector_(0.0, 1.0, 0.0, WorldFrame()) 

Example 2

Rotate an X-axis aligned vector by 30 degrees
Intent >rotateVector(UnitX, 30, -UnitY) 
--> Vector_(0.86602540378444, 0.0, 0.5, WorldFrame()) 

Example 3

Rotate the local X-axis 45 degrees around the z axis.
Intent >rotateVector(vector(1,0,0), 45, vector(0,0,1)) 
--> Vector_(0.70710678118655, 0.70710678118655, 0.0, WorldFrame())

Example 4

Rotating a vector about a parallel vector just returns the input vector .
Intent >rotateVector(vector(1,0,0), 45, vector(1,0,0)) 
--> Vector_(1.0, 0.0, 0.0, WorldFrame())