Skip to contents

Creates a quaternion-class object.

Usage

quaternion(m)

Arguments

m

n x 4 matrix or 4 element vector containing a unit quaternion, or an orientation object

Details

The rows of m are 4 element unit vectors interpreted as follows: the first 3 (x,y,z) define the axis of rotation, and the last element gives the cosine of half the angle of rotation in a counter-clockwise direction when looking down the axis towards the origin.

Value

A quaternion-class object.

Author

Duncan Murdoch

Examples

x <- quaternion(c(1,0,0,0))
x
#> An object of class "quaternion"
#> Slot "x":
#>      [,1] [,2] [,3] [,4]
#> [1,]    1    0    0    0
#> 
rotmatrix(x)
#> An object of class "rotmatrix"
#> Slot "x":
#> , , 1
#> 
#>      [,1] [,2] [,3]
#> [1,]    1    0    0
#> [2,]    0   -1    0
#> [3,]    0    0   -1
#> 
#>