Title: | Conversion Between Attitude Representations of DCM, Euler Angles, Quaternions, and Euler Vectors |
---|---|
Description: | Conversion between attitude representations: DCM, Euler angles, Quaternions, and Euler vectors. Plus conversion between 2 Euler angle set types (xyx, yzy, zxz, xzx, yxy, zyz, xyz, yzx, zxy, xzy, yxz, zyx). Fully vectorized code, with warnings/errors for Euler angles (singularity, out of range, invalid angle order), DCM (orthogonality, not proper, exceeded tolerance to unity determinant) and Euler vectors(not unity). Also quaternion and other useful functions. Based on SpinCalc by John Fuller and SpinConv by Paolo de Leva. |
Authors: | Jose Gama [aut, cre], John Fuller [aut, cph], Paolo Leva [aut, cph] |
Maintainer: | Jose Gama <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.0.2 |
Built: | 2024-10-31 20:50:25 UTC |
Source: | CRAN |
DCM2EA
converts from Direction Cosine Matrix (DCM) to Euler Angles (EA).
DCM2EA(DCM, EulerOrder='zyx', tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
DCM2EA(DCM, EulerOrder='zyx', tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
DCM |
Direction Cosine Matrix (DCM) is a rotation matrix 3x3 (N=1) or an array 3x3xN |
EulerOrder |
Euler Angles (EA) is a vector [psi, theta, phi] |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ichk |
Logical, FALSE=disables near-singularity warnings. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
Euler Angles (EA) xyz <=> x(roll) y(pitch) z(yaw) Type 1 Rotations (Tait-Bryan angles): xyz - xzy - yxz - yzx - zyx - zxy Singular if second rotation angle is -90 or 90 degrees. Type 2 Rotations (proper Euler angles): xyx - xzx - yxy - yzy - zxz - zyz Singular if second rotation angle is 0 or 180 degrees.
Euler angles [psi, theta, phi] range from -90 to 90 degrees. Tait-Bryan angles [psi, theta, phi] range from 0 to 180 degrees. Angles about Euler vectors range from 0 to 180 degrees.
Euler Angles (EA) vector [psi, theta, phi]
Jose Gama
by John Fuller, 14 Jul 2008 SpinCalc, Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors. http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm–euler-angles–quaternions–and-euler-vectors
Paolo de Leva, 01 May 2013 SpinConv, Conversion from a rotation representation type to another. http://www.mathworks.com/matlabcentral/fileexchange/41562-spinconv
DCM <- matrix(c(-0.3573404, -0.1515663, 0.9215940, 0.6460385, 0.6724915, 0.3610947, -0.6744939, 0.7244189, -0.1423907),3,3,byrow=TRUE) DCM2EA(DCM,'xyz')
DCM <- matrix(c(-0.3573404, -0.1515663, 0.9215940, 0.6460385, 0.6724915, 0.3610947, -0.6744939, 0.7244189, -0.1423907),3,3,byrow=TRUE) DCM2EA(DCM,'xyz')
DCM2EV
converts from Direction Cosine Matrix (DCM) to Euler Vectors (EV).
DCM2EV(DCM, tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
DCM2EV(DCM, tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
DCM |
Direction Cosine Matrix (DCM) is a rotation matrix 3x3 (N=1) or an array 3x3xN. |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ichk |
Logical, FALSE=disables near-singularity warnings. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
Euler Vectors (EV) vector [m1, m2, m3, MU]
Jose Gama
by John Fuller, 14 Jul 2008 SpinCalc, Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors. http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm–euler-angles–quaternions–and-euler-vectors
Paolo de Leva, 01 May 2013 SpinConv, Conversion from a rotation representation type to another. http://www.mathworks.com/matlabcentral/fileexchange/41562-spinconv
DCM <- matrix(c(-0.3573404, -0.1515663, 0.9215940, 0.6460385, 0.6724915, 0.3610947, -0.6744939, 0.7244189, -0.1423907),3,3,byrow=TRUE) DCM2EV(DCM)
DCM <- matrix(c(-0.3573404, -0.1515663, 0.9215940, 0.6460385, 0.6724915, 0.3610947, -0.6744939, 0.7244189, -0.1423907),3,3,byrow=TRUE) DCM2EV(DCM)
DCM2Q
converts from Direction Cosine Matrix (DCM) to Quaternions (Q).
DCM2Q(DCM, tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
DCM2Q(DCM, tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
DCM |
Direction Cosine Matrix (DCM) is a rotation matrix 3x3 (N=1) or an array 3x3xN |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ichk |
Logical, FALSE=disables near-singularity warnings. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
Quaternion (Q) vector [q1, q2, q3, q4].
Jose Gama
by John Fuller, 14 Jul 2008 SpinCalc, Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors. http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm–euler-angles–quaternions–and-euler-vectors
Paolo de Leva, 01 May 2013 SpinConv, Conversion from a rotation representation type to another. http://www.mathworks.com/matlabcentral/fileexchange/41562-spinconv
DCM <- matrix(c(-0.3573404, -0.1515663, 0.9215940, 0.6460385, 0.6724915, 0.3610947, -0.6744939, 0.7244189, -0.1423907),3,3,byrow=TRUE) DCM2Q(DCM)
DCM <- matrix(c(-0.3573404, -0.1515663, 0.9215940, 0.6460385, 0.6724915, 0.3610947, -0.6744939, 0.7244189, -0.1423907),3,3,byrow=TRUE) DCM2Q(DCM)
DCMrandom
generates uniform random direction cosine matrices.
DCMrandom(n=NA, tol = 10 * .Machine$double.eps, ignoreAllChk=FALSE)
DCMrandom(n=NA, tol = 10 * .Machine$double.eps, ignoreAllChk=FALSE)
n |
Optional integer for the number of generated direction cosine matrices, default = 1. |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
DCM |
Direction cosine matrix or array (DCM). |
Jose Gama
DCMrandom() DCMrandom(5)
DCMrandom() DCMrandom(5)
EA2DCM
converts from Euler Angles (EA) to Direction Cosine Matrix (DCM).
EA2DCM(EA, EulerOrder='zyx', tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
EA2DCM(EA, EulerOrder='zyx', tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
EA |
Euler Angles (EA) vector [psi, theta, phi]. |
EulerOrder |
Euler Order (xyx, yzy, zxz, xzx, yxy, zyz, xyz, yzx, zxy, xzy, yxz, zyx) |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ichk |
Logical, FALSE=disables near-singularity warnings. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
Euler Angles (EA) xyz <=> x(roll) y(pitch) z(yaw) Type 1 Rotations (Tait-Bryan angles): xyz - xzy - yxz - yzx - zyx - zxy Singular if second rotation angle is -90 or 90 degrees. Type 2 Rotations (proper Euler angles): xyx - xzx - yxy - yzy - zxz - zyz Singular if second rotation angle is 0 or 180 degrees.
Euler angles [psi, theta, phi] range from -90 to 90 degrees. Tait-Bryan angles [psi, theta, phi] range from 0 to 180 degrees. Angles about Euler vectors range from 0 to 180 degrees.
Direction Cosine Matrix (DCM) 3x3xN.
Jose Gama
by John Fuller, 14 Jul 2008 SpinCalc, Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors. http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm–euler-angles–quaternions–and-euler-vectors
Paolo de Leva, 01 May 2013 SpinConv, Conversion from a rotation representation type to another. http://www.mathworks.com/matlabcentral/fileexchange/41562-spinconv
EAxyx <- c(-170.6607, 110.937, 136.2344) * (pi/180) EA2DCM(EAxyx,'xyx')
EAxyx <- c(-170.6607, 110.937, 136.2344) * (pi/180) EA2DCM(EAxyx,'xyx')
EA2EA
converts from Euler Angles (EA) to Euler Angles (EA).
EA2EA(EA, EulerOrder1='zyx', EulerOrder2='zyx', tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
EA2EA(EA, EulerOrder1='zyx', EulerOrder2='zyx', tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
EA |
Euler Angles (EA) vector [psi, theta, phi]. |
EulerOrder1 |
Euler Order 1 (xyx, yzy, zxz, xzx, yxy, zyz, xyz, yzx, zxy, xzy, yxz, zyx) |
EulerOrder2 |
Euler Order 2 (xyx, yzy, zxz, xzx, yxy, zyz, xyz, yzx, zxy, xzy, yxz, zyx) |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ichk |
Logical, FALSE=disables near-singularity warnings. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
Euler Angles (EA) xyz <=> x(roll) y(pitch) z(yaw) Type 1 Rotations (Tait-Bryan angles): xyz - xzy - yxz - yzx - zyx - zxy Singular if second rotation angle is -90 or 90 degrees. Type 2 Rotations (proper Euler angles): xyx - xzx - yxy - yzy - zxz - zyz Singular if second rotation angle is 0 or 180 degrees.
Euler angles [psi, theta, phi] range from -90 to 90 degrees. Tait-Bryan angles [psi, theta, phi] range from 0 to 180 degrees. Angles about Euler vectors range from 0 to 180 degrees.
Euler Angles (EA) vector [psi, theta, phi].
Jose Gama
by John Fuller, 14 Jul 2008 SpinCalc, Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors. http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm–euler-angles–quaternions–and-euler-vectors
Paolo de Leva, 01 May 2013 SpinConv, Conversion from a rotation representation type to another. http://www.mathworks.com/matlabcentral/fileexchange/41562-spinconv
## Not run: EAxyx <- c(-170.6607, 110.937, 136.2344) EA2EA(EAxyx,'xyx','xyz') EA2EA(EAxyx,'xyx','xzy') EA2EA(EAxyx,'xyx','yzx') EA2EA(EAxyx,'xyx','yxz') EA2EA(EAxyx,'xyx','zxy') EA2EA(EAxyx,'xyx','zyx') EA2EA(EAxyx,'xyx','xzx') EA2EA(EAxyx,'xyx','yxy') EA2EA(EAxyx,'xyx','yzy') EA2EA(EAxyx,'xyx','zxz') EA2EA(EAxyx,'xyx','zyz') ## End(Not run)
## Not run: EAxyx <- c(-170.6607, 110.937, 136.2344) EA2EA(EAxyx,'xyx','xyz') EA2EA(EAxyx,'xyx','xzy') EA2EA(EAxyx,'xyx','yzx') EA2EA(EAxyx,'xyx','yxz') EA2EA(EAxyx,'xyx','zxy') EA2EA(EAxyx,'xyx','zyx') EA2EA(EAxyx,'xyx','xzx') EA2EA(EAxyx,'xyx','yxy') EA2EA(EAxyx,'xyx','yzy') EA2EA(EAxyx,'xyx','zxz') EA2EA(EAxyx,'xyx','zyz') ## End(Not run)
EA2EV
converts from Euler Angles (EA) to Euler Vectors (EV).
EA2EV(EA, EulerOrder='zyx', tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
EA2EV(EA, EulerOrder='zyx', tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
EA |
Euler Angles (EA) vector [psi, theta, phi]. |
EulerOrder |
Euler Order (xyx, yzy, zxz, xzx, yxy, zyz, xyz, yzx, zxy, xzy, yxz, zyx) |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ichk |
Logical, FALSE=disables near-singularity warnings. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
Euler Angles (EA) xyz <=> x(roll) y(pitch) z(yaw) Type 1 Rotations (Tait-Bryan angles): xyz - xzy - yxz - yzx - zyx - zxy Singular if second rotation angle is -90 or 90 degrees. Type 2 Rotations (proper Euler angles): xyx - xzx - yxy - yzy - zxz - zyz Singular if second rotation angle is 0 or 180 degrees.
Euler angles [psi, theta, phi] range from -90 to 90 degrees. Tait-Bryan angles [psi, theta, phi] range from 0 to 180 degrees. Angles about Euler vectors range from 0 to 180 degrees.
Euler Vectors (EV) vector [m1, m2, m3, MU].
Jose Gama
by John Fuller, 14 Jul 2008 SpinCalc, Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors. http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm–euler-angles–quaternions–and-euler-vectors
Paolo de Leva, 01 May 2013 SpinConv, Conversion from a rotation representation type to another. http://www.mathworks.com/matlabcentral/fileexchange/41562-spinconv
EAxyx <- c(-170.6607, 110.937, 136.2344) * (pi/180) EA2EV(EAxyx,'xyx')
EAxyx <- c(-170.6607, 110.937, 136.2344) * (pi/180) EA2EV(EAxyx,'xyx')
EA2Q
converts from Euler Angles (EA) to Quaternions (Q).
EA2Q(EA, EulerOrder='zyx', ichk = FALSE, ignoreAllChk = FALSE)
EA2Q(EA, EulerOrder='zyx', ichk = FALSE, ignoreAllChk = FALSE)
EA |
Euler Angles (EA) vector [psi, theta, phi]. |
EulerOrder |
Euler Order (xyx, yzy, zxz, xzx, yxy, zyz, xyz, yzx, zxy, xzy, yxz, zyx) |
ichk |
Logical, FALSE=disables near-singularity warnings. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
Euler Angles (EA) xyz <=> x(roll) y(pitch) z(yaw) Type 1 Rotations (Tait-Bryan angles): xyz - xzy - yxz - yzx - zyx - zxy Singular if second rotation angle is -90 or 90 degrees. Type 2 Rotations (proper Euler angles): xyx - xzx - yxy - yzy - zxz - zyz Singular if second rotation angle is 0 or 180 degrees.
Euler angles [psi, theta, phi] range from -90 to 90 degrees. Tait-Bryan angles [psi, theta, phi] range from 0 to 180 degrees. Angles about Euler vectors range from 0 to 180 degrees.
Quaternions (Q) vector [q1, q2, q3, q4].
Jose Gama
by John Fuller, 14 Jul 2008 SpinCalc, Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors. http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm–euler-angles–quaternions–and-euler-vectors
Paolo de Leva, 01 May 2013 SpinConv, Conversion from a rotation representation type to another. http://www.mathworks.com/matlabcentral/fileexchange/41562-spinconv
EAxyx <- c(-170.6607, 110.937, 136.2344) * (pi/180) EA2Q(EAxyx,'xyx')
EAxyx <- c(-170.6607, 110.937, 136.2344) * (pi/180) EA2Q(EAxyx,'xyx')
EArandom
generates uniform random Euler Angles.
EArandom(n=NA, EulerOrder='zyx', tol = 10 * .Machine$double.eps, ignoreAllChk=FALSE)
EArandom(n=NA, EulerOrder='zyx', tol = 10 * .Machine$double.eps, ignoreAllChk=FALSE)
n |
Optional integer for the number of generated Euler Angles, default = 1. |
EulerOrder |
Euler Order (xyx, yzy, zxz, xzx, yxy, zyz, xyz, yzx, zxy, xzy, yxz, zyx). |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
EA |
Euler Angles (EA). |
Jose Gama
EArandom() EArandom(5)
EArandom() EArandom(5)
EV2DCM
converts from Euler Vectors (EV) to Direction Cosine Matrix (DCM).
EV2DCM(EV, tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
EV2DCM(EV, tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
EV |
Euler Vectors (EV) vector [m1, m2, m3, MU]. |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ichk |
Logical, FALSE=disables near-singularity warnings. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
Direction Cosine Matrix (DCM) 3x3xN.
Jose Gama
by John Fuller, 14 Jul 2008 SpinCalc, Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors. http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm–euler-angles–quaternions–and-euler-vectors
Paolo de Leva, 01 May 2013 SpinConv, Conversion from a rotation representation type to another. http://www.mathworks.com/matlabcentral/fileexchange/41562-spinconv
EV <- c(-0.1995301, -0.8765382, -0.4380279, 114.4324 * (pi/180)) EV2DCM(EV,1e-7) #EV2DCM(EV)
EV <- c(-0.1995301, -0.8765382, -0.4380279, 114.4324 * (pi/180)) EV2DCM(EV,1e-7) #EV2DCM(EV)
EV2EA
converts from Euler Vectors (EV) to Euler Angles (EA).
EV2EA(EV, EulerOrder='zyx', tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
EV2EA(EV, EulerOrder='zyx', tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
EV |
Euler Vectors (EV) vector [m1, m2, m3, MU]. |
EulerOrder |
Euler Order (xyx, yzy, zxz, xzx, yxy, zyz, xyz, yzx, zxy, xzy, yxz, zyx) |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ichk |
Logical, FALSE=disables near-singularity warnings. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
Euler Angles (EA) xyz <=> x(roll) y(pitch) z(yaw) Type 1 Rotations (Tait-Bryan angles): xyz - xzy - yxz - yzx - zyx - zxy Singular if second rotation angle is -90 or 90 degrees. Type 2 Rotations (proper Euler angles): xyx - xzx - yxy - yzy - zxz - zyz Singular if second rotation angle is 0 or 180 degrees.
Euler angles [psi, theta, phi] range from -90 to 90 degrees. Tait-Bryan angles [psi, theta, phi] range from 0 to 180 degrees. Angles about Euler vectors range from 0 to 180 degrees.
Euler Angles (EA) vector [psi, theta, phi].
Jose Gama
by John Fuller, 14 Jul 2008 SpinCalc, Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors. http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm–euler-angles–quaternions–and-euler-vectors
Paolo de Leva, 01 May 2013 SpinConv, Conversion from a rotation representation type to another. http://www.mathworks.com/matlabcentral/fileexchange/41562-spinconv
## Not run: EV <- c(-0.1995301, -0.8765382, -0.4380279, 114.4324 * (pi/180)) EV2EA(EV,'xyx') ## End(Not run)
## Not run: EV <- c(-0.1995301, -0.8765382, -0.4380279, 114.4324 * (pi/180)) EV2EA(EV,'xyx') ## End(Not run)
EV2Q
converts from Euler Vectors (EV) to Quaternions (Q).
EV2Q(EV, tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
EV2Q(EV, tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
EV |
Euler Vectors (EV) vector [m1, m2, m3, MU]. |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ichk |
Logical, FALSE=disables near-singularity warnings. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
Quaternions (Q) vector [q1, q2, q3, q4].
Jose Gama
by John Fuller, 14 Jul 2008 SpinCalc, Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors. http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm–euler-angles–quaternions–and-euler-vectors
Paolo de Leva, 01 May 2013 SpinConv, Conversion from a rotation representation type to another. http://www.mathworks.com/matlabcentral/fileexchange/41562-spinconv
EV <- c(-0.1995301, -0.8765382, -0.4380279, 114.4324 * (pi/180)) EV2Q(EV,1e-7) #EV2Q(EV)
EV <- c(-0.1995301, -0.8765382, -0.4380279, 114.4324 * (pi/180)) EV2Q(EV,1e-7) #EV2Q(EV)
EVrandom
generates uniform random Euler Vectors.
EVrandom(n=NA, tol = 10 * .Machine$double.eps, ignoreAllChk=FALSE)
EVrandom(n=NA, tol = 10 * .Machine$double.eps, ignoreAllChk=FALSE)
n |
Optional integer for the number of generated Euler Vectors, default = 1. |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
EV |
Euler Vectors (EV). |
Jose Gama
EVrandom() EVrandom(5)
EVrandom() EVrandom(5)
isPureRotationMatrix
determines if a matrix is pure rotation matrix (proper orthogonal matrix) with det(m)==1.
isPureQuaternion
determines if a quaternion is a pure quaternion.
isRealQuaternion
determines if a quaternion is a real quaternion.
isUnitQuaternion
determines if a quaternion is a unit quaternion.
isPureRotationMatrix(DCM, tol = 0.01)
isPureRotationMatrix(DCM, tol = 0.01)
DCM |
Direction Cosine Matrix (DCM) is a rotation matrix 3x3 (N=1) or an array 3x3xN. |
tol |
Tolerance value. |
Logical, TRUE = matrix is pure rotation matrix.
Jose Gama
isPureRotationMatrix(matrix(rep(0,9),3,3,byrow=TRUE),.1) isPureRotationMatrix(matrix(rep(1,9),3,3,byrow=TRUE),.1) isPureRotationMatrix(matrix(c(0,0,-1,0,1,0,1,0,1),3,3,byrow=TRUE),.1) DCMx10 <- DCMrandom(10) isPureRotationMatrix(DCMx10)
isPureRotationMatrix(matrix(rep(0,9),3,3,byrow=TRUE),.1) isPureRotationMatrix(matrix(rep(1,9),3,3,byrow=TRUE),.1) isPureRotationMatrix(matrix(c(0,0,-1,0,1,0,1,0,1),3,3,byrow=TRUE),.1) DCMx10 <- DCMrandom(10) isPureRotationMatrix(DCMx10)
Q2DCM
converts from Quaternions to Direction Cosine Matrix (DCM).
Q2DCM(Q, tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
Q2DCM(Q, tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
Q |
Quaternion (Q) vector [q1, q2, q3, q4]. |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ichk |
Logical, FALSE=disables near-singularity warnings. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
Direction Cosine Matrix (DCM) 3x3xN.
Jose Gama
by John Fuller, 14 Jul 2008 SpinCalc, Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors. http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm–euler-angles–quaternions–and-euler-vectors
Paolo de Leva, 01 May 2013 SpinConv, Conversion from a rotation representation type to another. http://www.mathworks.com/matlabcentral/fileexchange/41562-spinconv
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q2DCM(Q)
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q2DCM(Q)
Q2EA
converts from Quaternions (Q) to Euler Angles (EA) based on D. M.
Henderson (1977).
Q2EA.Xiao
is the algorithm by J. Xiao (2013) for the Princeton Vision
Toolkit - included here to allow reproducible research.
Q2EA(Q, EulerOrder='zyx', tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
Q2EA(Q, EulerOrder='zyx', tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
Q |
Quaternion (Q) vector [q1, q2, q3, q4]. |
EulerOrder |
Euler Order (xyx, yzy, zxz, xzx, yxy, zyz, xyz, yzx, zxy, xzy, yxz, zyx). |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ichk |
Logical, FALSE=disables near-singularity warnings. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
Euler Angles (EA) xyz <=> x(roll) y(pitch) z(yaw) Type 1 Rotations (Tait-Bryan angles): xyz - xzy - yxz - yzx - zyx - zxy Singular if second rotation angle is -90 or 90 degrees. Type 2 Rotations (proper Euler angles): xyx - xzx - yxy - yzy - zxz - zyz Singular if second rotation angle is 0 or 180 degrees.
Euler angles [psi, theta, phi] range from -90 to 90 degrees. Tait-Bryan angles [psi, theta, phi] range from 0 to 180 degrees. Angles about Euler vectors range from 0 to 180 degrees.
Euler Angles (EA) vector [psi, theta, phi].
Jose Gama
D. M. Henderson, 1977 Shuttle Program. Euler Angles, Quaternions, and Transformation Matrices Working Relationships. National Aeronautics and Space Administration (NASA), N77-31234/6
J. Xiao, 2013 Princeton Vision Toolkit. Available from: http://vision.princeton.edu/code.html http://vision.princeton.edu/pvt/GCBreader/quaternion.m
John Fuller, 14 Jul 2008 SpinCalc, Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors. http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm–euler-angles–quaternions–and-euler-vectors
Paolo de Leva, 01 May 2013 SpinConv, Conversion from a rotation representation type to another. http://www.mathworks.com/matlabcentral/fileexchange/41562-spinconv
## Not run: Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q2EA(Q,'xyx') ## End(Not run)
## Not run: Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q2EA(Q,'xyx') ## End(Not run)
Q2EV
converts from Quaternions (Q) to Euler Vectors (EV).
Q2EV(Q, tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
Q2EV(Q, tol = 10 * .Machine$double.eps, ichk = FALSE, ignoreAllChk = FALSE)
Q |
Quaternion (Q) vector [q1, q2, q3, q4]. |
tol |
Tolerance from deviations from unity for the determinant of rotation matrices or the the vector length for unitary vectors. |
ichk |
Logical, FALSE=disables near-singularity warnings. |
ignoreAllChk |
Logical, TRUE=disables all warnings and error checks (use with caution!). |
Euler Vectors (EV) vector [m1, m2, m3, MU].
Jose Gama
by John Fuller, 14 Jul 2008 SpinCalc, Function to Convert between DCM, Euler angles, Quaternions, and Euler vectors. http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm–euler-angles–quaternions–and-euler-vectors
Paolo de Leva, 01 May 2013 SpinConv, Conversion from a rotation representation type to another. http://www.mathworks.com/matlabcentral/fileexchange/41562-spinconv
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q2EV(Q)
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q2EV(Q)
DCM2EA
converts from Quaternions (Q) to OpenGL rotation matrix.
Q2GL(Q)
Q2GL(Q)
Q |
rotation Quaternions (Q) vector [q1, q2, q3, q4]. |
OpenGL rotation matrix 4x4xN.
Jose Gama
Python - IMU Brick 2012 http://www.tinkerforge.com/doc/Software/Bricks/IMU_Brick_Python.html
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q2GL(Q)
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q2GL(Q)
QangularDifference
returns the angular difference between 2 quaternions.
QangularDifference(Q1, Q2)
QangularDifference(Q1, Q2)
Q1 |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q2 |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Real value = angular difference between 2 quaternions.
Jose Gama
Q1 <- Qrandom() Q2 <- Qrandom() QangularDifference(Q1, Q2)
Q1 <- Qrandom() Q2 <- Qrandom() QangularDifference(Q1, Q2)
Qconj
performs a quaternion conjugate operation.
Qconj(Q)
Qconj(Q)
Q |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q |
Conjugate quaternion (Q) vector [q1, q2, q3, q4]. |
Jose Gama
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Qconj(Q)
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Qconj(Q)
Qinv
calculated the quaternion inverse.
Qinv(Q)
Qinv(Q)
Q |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q |
Quaternion inverse (Q) vector [q1, q2, q3, q4]. |
Jose Gama
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Qinv(Q)
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Qinv(Q)
Qlerp
linear quaternion interpolation.
Qslerp
spherical linear interpolation.
QslerpNoInvert
version of slerp, used by squad, that does not check for theta > 90.
Qspline
spherical cubic interpolation.
Qsquad
spherical and Quadrangle linear interpolation.
Qbezier
Shoemake-Bezier interpolation using De Castlejau algorithm.
Qspline
for 3 quaternions, qn-1,qn and qn+1, calculate a control point to be used in spline interpolation.
Qlerp(Q1, Q2, fracT)
Qlerp(Q1, Q2, fracT)
Q1 |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q2 |
Quaternion (Q) vector [q1, q2, q3, q4]. |
fracT |
Fraction of . |
Q |
Zero or one-valued quaternion (Q) vector [q1, q2, q3, q4] or matrix n x 4. |
Jose Gama
Q1 <- Qrandom() Q2 <- Qrandom() Qlerp(Q1, Q2, 0.1)
Q1 <- Qrandom() Q2 <- Qrandom() Qlerp(Q1, Q2, 0.1)
Qlog
performs a quaternion logarithm operation.
Qexp
performs a quaternion exponential operation.
Qlog(Q) Qexp(Q)
Qlog(Q) Qexp(Q)
Q |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q |
Result quaternion (Q) vector [q1, q2, q3, q4]. |
Jose Gama
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Qlog(Q) Qexp(Q)
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Qlog(Q) Qexp(Q)
Qnorm
calculates the norm of a quaternion.
Qnorm(Q)
Qnorm(Q)
Q |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Norm of the quaternion.
Jose Gama
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Qnorm(Q)
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Qnorm(Q)
Qnormalize
performs a quaternion normalization.
Qnormalize(Q)
Qnormalize(Q)
Q |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q |
Normalized quaternion (Q) vector [q1, q2, q3, q4]. |
Jose Gama
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Qnormalize(Q)
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Qnormalize(Q)
Qrandom
generates uniform random unit quaternions.
Qrandom(n=NA)
Qrandom(n=NA)
n |
Optional integer for the number of generated quaternions, default = 1. |
Q |
Uniform random unit quaternion (Q) vector [q1, q2, q3, q4] or matrix n x 4. |
Jose Gama
Qrandom() Qrandom(5)
Qrandom() Qrandom(5)
Qrot
updates the current attitude quaternion.
Qrot(Q, w, dT)
Qrot(Q, w, dT)
Q |
Quaternion (Q) vector [q1, q2, q3, q4]. |
w |
Angular rate values [wx, wy, wz]. |
dT |
Inverse of update rate. |
Q |
Updated quaternion (Q) vector [q1, q2, q3, q4]. |
Jose Gama
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) w <- c(0.1, 0.2, 0.3) dT <- -.12 Qrot(Q,w,dT)
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) w <- c(0.1, 0.2, 0.3) dT <- -.12 Qrot(Q,w,dT)
Qzero
generates zero-valued quaternions.
Qone
generates one-valued quaternions.
Qzero(n=NA)
Qzero(n=NA)
n |
Optional integer for the number of generated quaternions, default = 1. |
Q |
Zero or one-valued quaternion (Q) vector [q1, q2, q3, q4] or matrix n x 4. |
Jose Gama
Qzero() Qzero(5) Qone() Qone(5)
Qzero() Qzero(5) Qone() Qone(5)
vectQrot
performs a vector rotation by a quaternion.
vectQrot(Q, rr)
vectQrot(Q, rr)
Q |
Quaternion (Q) vector [q1, q2, q3, q4]. |
rr |
Vector [x, y, z]. |
Rotated vector [x, y, z].
Jose Gama
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) v <- c(1, 2, 3) vectQrot(Q, v)
Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) v <- c(1, 2, 3) vectQrot(Q, v)
%Q*%
performs a quaternion multiplication.
Q1 %Q*% Q2
Q1 %Q*% Q2
Q1 |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q2 |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q |
Quaternion result of multiplication (Q) vector [q1, q2, q3, q4]. |
Jose Gama
## Not run: Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q %Q*% Q ## End(Not run)
## Not run: Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q %Q*% Q ## End(Not run)
%Q/%
performs a quaternion division.
Q1 %Q/% Q2
Q1 %Q/% Q2
Q1 |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q2 |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q |
Quaternion result of division (Q) vector [q1, q2, q3, q4]. |
Jose Gama
## Not run: Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q %Q/% Q ## End(Not run)
## Not run: Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q %Q/% Q ## End(Not run)
%Q-%
performs a quaternion subtraction.
Q1 %Q-% Q2
Q1 %Q-% Q2
Q1 |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q2 |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q |
Quaternion result of subtraction (Q) vector [q1, q2, q3, q4]. |
Jose Gama
## Not run: Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q %Q-% Q ## End(Not run)
## Not run: Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q %Q-% Q ## End(Not run)
%Q+%
performs a quaternion addition.
Q1 %Q+% Q2
Q1 %Q+% Q2
Q1 |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q2 |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q |
Quaternion sum (Q) vector [q1, q2, q3, q4]. |
Jose Gama
## Not run: Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q %Q+% Q ## End(Not run)
## Not run: Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q %Q+% Q ## End(Not run)
%Q.%
performs a quaternion dot product.
Q1 %Q.% Q2
Q1 %Q.% Q2
Q1 |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q2 |
Quaternion (Q) vector [q1, q2, q3, q4]. |
Q |
Quaternion result of dot product (Q) vector [q1, q2, q3, q4]. |
Jose Gama
## Not run: Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q %Q.% Q ## End(Not run)
## Not run: Q <- c(-0.1677489, -0.7369231, -0.3682588, 0.5414703) Q %Q.% Q ## End(Not run)