Version 0.58.2

rotation

Constructor of a rotation transformation of type atrafo.

Signatures

  •   rotation( vector axis, float angle )
  •   rotation( vector onset, vector axis, float angle  )

Details

The rotation transformation allows for rotating an object or vector around a specified axis in space. This operation follows the right-hand rule, which determines the direction of rotation. A positive angle results in a counterclockwise rotation, while a negative angle rotates the object clockwise when looking from the end of the axis vector towards the origin.

The first form of the constructor takes an axis vector and an angle in radians and rotates around the axis that passes through the origin. The second form allows for specifying an onset point for the axis, enabling rotation around an arbitrary line in space.

Illustration of a rotation around the Z-axis centered at the origin.

Illustration of a rotation around an arbitrary axis defined by an onset point.

Example

  make rotation( <[ 0.0, 0.0, 1.0 ]>, rad( 90 ) ) >> box()
 

Rotates a box 90 degrees counterclockwise around the Z-axis.

Example

 make rotation( <[ 1.0, 0.0, 0.0 ]>, <[ 0.0, 0.0, 1.0 ]>, rad( 45 ) ) >> box()
 

Rotates a box 45 degrees counterclockwise around an axis defined by the vector <[ 0.0, 0.0, 1.0 ]> starting at the point <[ 1.0, 0.0, 0.0 ]>.

Note

All angles are specified in radians. The function rad() can be used to convert degrees to radians if needed.

Parameters

axis

A vector representing the direction of the axis of rotation.

angle

The angle of rotation in radians.

onset

A vector representing the starting point of the axis.

See also

🗙

Search results for