Learn R Programming

rotations (version 0.1)

Q4: Quaternions

Description

Creates or tests for objects of class "Q4."

Usage

Q4(q, ...)

## S3 method for class 'default': Q4(q, theta = NULL, ...)

## S3 method for class 'SO3': Q4(q, ...)

as.Q4(q)

is.Q4(q)

id.Q4

Arguments

q
object to be coerced or tested.
theta
vector of rotation angles.
...
additional arguments.

Value

  • as.Q4coerces its object into an Q4 type.
  • is.Q4returns TRUE or False depending on whether its argument satifies the conditions to be an quaternion. Namely, is four-dimensional and of unit length.
  • Q4.defaultreturns an n-by-4 matrix where each row is a quaternion constructed from axis U and angle theta.
  • Q4.SO3returns n-by-4 matrix where each row is a quaternion constructed from the corresponding rotation matrix.

format

id.Q4 is the identity rotation given by the matrix $[1,0,0,0]^\top$.

Details

Construct a unit quaternion to represent a rotation. Each quaternion can be interpreted as a rotation of some reference frame about the axis U (of unit length) through the angle theta. For each axis, U, and angle theta the quaternion is formed through $$q=[cos(\theta/2),sin(\theta/2)U]^\top.$$ If the theta element is left empty then the length of each axis is taken to be the angle of rotation theta. If an SO3 object is given then this function will return the quaternion equivalent.