
Creates or tests for objects of class "SO3".
as.SO3(x, ...)# S3 method for default
as.SO3(x, theta = NULL, ...)
# S3 method for Q4
as.SO3(x, ...)
# S3 method for SO3
as.SO3(x, ...)
# S3 method for data.frame
as.SO3(x, ...)
is.SO3(x)
id.SO3
coerces provided data into an SO3 type.
returns TRUE
or False
depending on whether its
argument satisfies the conditions to be an rotation matrix. Namely, has
determinant one and its transpose is its inverse.
id.SO3
is the identity rotation given by the the 3-by-3
identity matrix.
An object of class SO3
with 1 rows and 9 columns.
object to be coerced or tested; see details for possible forms
additional arguments.
vector or single rotation angle; if length(theta)==1
the
same theta is used for all axes
Construct a single or sample of rotations in 3-dimensions in 3-by-3 matrix
form. Several possible inputs for x
are possible and they are
differentiated based on their class and dimension.
For x
an n-by-3 matrix or a vector of length 3, the angle-axis
representation of rotations is utilized. More specifically, each rotation
matrix can be interpreted as a rotation of some reference frame about the
axis x
, then for each axis and angle the matrix is formed through
x
. If axes are provided but theta
is not provided then the
length of each axis is taken to be the angle of rotation, theta.
For x
an n-by-4 matrix of quaternions or an object of class
"Q4"
, this function will return the rotation matrix equivalent of
x
. See Q4
or the vignette "rotations-intro" for more
details on quaternions.
For x
an n-by-9 matrix, rows are treated as 3-by-3 matrices; rows that
don't form matrices in SO(3) are projected into SO(3) and those that are
already in SO(3) are returned untouched. See project.SO3
for
more on projecting arbitrary matrices into SO(3). A message is printed if
any of the rows are not proper rotations.
For x
a "data.frame"
, it is translated into a matrix of the
same dimension and the dimensionality of x
is used to determine the
data type: angle-axis, quaternion or rotation. As demonstrated below,
is.SO3
may return TRUE
for a data frame, but the functions
defined for objects of class "SO3"
will not be called until
as.SO3
has been used.
# Select one location to focus on
Loc698 <- subset(nickel, location == 698)
is.SO3(Loc698[,5:13]) #Some of the rows are not rotations due to rounding or entry errors
#as.SO3 will project matrices not in SO(3) to SO(3)
Rs <- as.SO3(Loc698[,5:13]) #Translate the Rs data.frame into an object of class 'SO3'
#Rows 4, 6 and 13 are not in SO(3) so they are projected to SO(3)
mean(Rs) #Estimate the central orientation with the average
median(Rs) #Re-estimate central orientation robustly
Qs <- as.Q4(Rs) #Coerse into "SO3" format, see ?as.SO3 for more
#Visualize the location, there appears to be two groups
# \donttest{
plot(Rs, col = c(1, 2, 3))
# }
Run the code above in your browser using DataLab