rotation | R Documentation |
Rotate points or quaternions using a handful of ways to define a rotation.
rotate(rotand, rotator = NULL, ...) ## S3 method for class 'dddr_vector3' rotate(rotand, rotator = NULL, ..., origin = NULL) ## S3 method for class 'dddr_quat' rotate( rotand, rotator = NULL, ..., axis = NULL, angle = NULL, from = NULL, to = NULL, as = NULL )
rotand |
Object to be rotated; can be either a vector or a quaternion |
rotator |
(Optional) Quaternion specifying the rotation to perform. If this argument is not specified, it is constructed using the others. |
... |
Additional arguments passed on to underlying S3 methods |
origin |
(Optional) The origin of the rotation, i.e, the point that should not change position during the rotation. |
axis |
(Optional) The axis of rotation |
angle |
(Optional) The angle of rotation, specified in radians. If this is not provided, it is calculated using 'from' and 'to' |
from, to |
(Optional) Instead of specifying an axis-angle pair, or angle amount, a rotation is performed mapping the direction of 'from' to the direction of 'to'. |
as |
Specify the rotation to apply to the quaternion as the type of object the quaternion represents or the mathematical operation to be applied. Accepted values are '"action"', '"orientation"', '"multiplying"', and '"conjugating"'. |
Note that with quaternions, there are two operations that might be called "rotations." The operation is selected using the 'as' argument. When quaternions represent orientations, rotation is merely quaternion multiplication. This operation is perfomed by the arguments '"orientation"' or '"multipliying"'. When quaternions represent actions, rotation is conjugating the first quaternion by the second. This operation is performed by the arguments '"action"' or '"conjugating"'.
If it is not clear which to use, ask whether the identity quaternion (no rotation at all) should become something other than the identity quaternion after rotation. If so, use '"orientation"'; if not, use '"action"'.
example_vector <- vector3(x = 1:4, y = 2:5, z = 3:6) rotate(example_vector, rotator = quat(0, 1, 0, 0)) rotate(example_vector, rotator = quat(0, 1, 0, 0), origin = vector3(1, 2, 3)) rotate(example_vector, axis = vector3(1, 0, 0), angle = pi / 4) rotate(example_vector, from = vector3(1, 0, 0), to = vector3(0, 1, 0))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.