Library
Documentation for ReferenceFrameRotations.jl.
ReferenceFrameRotations.DCM — Type.The Direction Cosine Matrice is a SMatrix{3,3}, which is a 3x3 static matrix.
struct EulerAngleAxis{T<:Real}The definition of Euler Angle and Axis to represent a 3D rotation.
- a: The Euler angle [rad].
- v: The unitary vector aligned with the Euler axis.
struct EulerAngles{T<:Real}The definition of Euler Angles, which is composed of three angles a1, a2, and a3 together with a rotation sequence rot_seq. The latter is provided by a symbol with three characters, each one indicating the rotation axis of the corresponding angle (for example, :ZYX). The valid values for rot_seq are:
- :XYX,- :XYZ,- :XZX,- :XZY,- :YXY,- :YXZ,- :YZX,- :YZY,- :ZXY,- :ZXZ,- :ZYX, and- ZYZ.
struct Quaternion{T<:Real}
The definition of the quaternion. It has four values of the same type. The quaternion representation is:
q0 + q1.i + q2.j + q3.kReferenceFrameRotations.Quaternion — Method.function Quaternion(q0::Number, q1::Number, q2::Number, q3::Number)Create the following quaternion:
q0 + q1.i + q2.j + q3.kArgs
- q0: Real part of the quaternion.
- q1: X component of the quaternion vectorial part.
- q2: Y component of the quaternion vectorial part.
- q3: Z component of the quaternion vectorial part.
Returns
The new quaternion.
ReferenceFrameRotations.Quaternion — Method.function Quaternion(v::Vector{T}) where T<:RealIf the vector v has 3 components, then create a quaternion in which the real part is 0 and the vectorial or imaginary part has the same components of the vector v. In other words:
q = 0 + v[1].i + v[2].j + v[3].kOtherwise, if the vector v has 4 components, then create a quaternion in which the elements match those of the input vector:
q = v[1] + v[2].i + v[3].j + v[4].kArgs
- v: Input vector. It must have three or four components.
Returns
If v has three components, then it returns the quaternion in which the real part is 0 and the imaginary part is v. Otherwise, it returns the quaternion with real part v[1] and imaginary part v[2:4].
ReferenceFrameRotations.Quaternion — Method.function Quaternion(r::Number, v::AbstractVector)Create a quaternion with real part r and vectorial or imaginary part v.
Args
- r: Real part.
- v: Vectorial or imaginary part.
Returns
The quaternion r + v[1].i + v[2].j + v[3].k.
ReferenceFrameRotations.angle2dcm — Function.function angle2dcm(angle_r1::Number, angle_r2::Number, angle_r3::Number, rot_seq::Symbol = :ZYX)Convert the Euler angles angle_r1, angle_r2, and angle_r3 with the rotation sequence rot_seq to a direction cosine matrix.
The rotation sequence is defined by a :Symbol. The possible values are: :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, and :ZYZ.
Args
- angle_r1: Angle of the first rotation [rad].
- angle_r2: Angle of the second rotation [rad].
- angle_r3: Angle of the third rotation [rad].
- rot_seq: (OPTIONAL) Rotation sequence (Default =- :ZYX).
Returns
The direction cosine matrix.
Remarks
This function assigns dcm = A3 * A2 * A1 in which Ai is the DCM related with the i-th rotation, i Є [1,2,3].
Example
dcm = angle2dcm(pi/2, pi/3, pi/4, :ZYX)
3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9}:
  3.06162e-17  0.5       -0.866025
 -0.707107     0.612372   0.353553
  0.707107     0.612372   0.353553ReferenceFrameRotations.angle2dcm — Method.function angle2dcm(eulerang::EulerAngles)Convert the Euler angles eulerang (see EulerAngles) to a direction cosine matrix.
Args
- eulerang: Euler angles (see- EulerAngles).
Returns
The direction cosine matrix.
Remarks
This function assigns dcm = A3 * A2 * A1 in which Ai is the DCM related with the i-th rotation, i Є [1,2,3].
Example
julia> angle2dcm(EulerAngles(pi/2, pi/3, pi/4, :ZYX))
3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9}:
  3.06162e-17  0.5       -0.866025
 -0.707107     0.612372   0.353553
  0.707107     0.612372   0.353553ReferenceFrameRotations.angle2quat — Function.function angle2quat(angle_r1::Number, angle_r2::Number, angle_r3::Number, rot_seq::AbstractString="ZYX")Convert the Euler angles angle_r1, angle_r2, and angle_r3 with the rotation sequence rot_seq to a quaternion.
The rotation sequence is defined by a :Symbol. The possible values are: :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, and :ZYZ.
Args
- angle_r1: Angle of the first rotation [rad].
- angle_r2: Angle of the second rotation [rad].
- angle_r3: Angle of the third rotation [rad].
- rot_seq: (OPTIONAL) Rotation sequence (Default =- :ZYX).
Returns
The quaternion.
Remarks
This function assigns q = q1 * q2 * q3 in which qi is the quaternion related with the i-th rotation, i Є [1,2,3].
Example
julia> angle2quat(pi/2, pi/3, pi/4, :ZYX)
Quaternion{Float64}:
  + 0.7010573846499779 - 0.09229595564125714.i + 0.5609855267969309.j + 0.43045933457687935.kReferenceFrameRotations.angle2quat — Method.function angle2quat(eulerang::EulerAngles)Convert the Euler angles eulerang (see EulerAngles) to a quaternion.
Args
- eulerang: Euler angles (see- EulerAngles).
Returns
The quaternion.
Remarks
This function assigns q = q1 * q2 * q3 in which qi is the quaternion related with the i-th rotation, i Є [1,2,3].
Example
julia> angle2quat(pi/2, pi/3, pi/4, :ZYX)
Quaternion{Float64}:
  + 0.7010573846499779 - 0.09229595564125714.i + 0.5609855267969309.j + 0.43045933457687935.kReferenceFrameRotations.angle2rot — Method.function angle2rot([T,] angle_r1::Number, angle_r2::Number, angle_r3::Number, rot_seq::Symbol = :ZYX)Convert the Euler angles angle_r1, angle_r2, and angle_r3 with the rotation sequence rot_seq to a rotation description of type T, which can be DCM or Quaternion.
The rotation sequence is defined by a :Symbol. The possible values are: :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, and :ZYZ.
Args
- T: (OPTIONAL) Type of the rotation description (Default =- DCM).
- angle_r1: Angle of the first rotation [rad].
- angle_r2: Angle of the second rotation [rad].
- angle_r3: Angle of the third rotation [rad].
- rot_seq: (OPTIONAL) Rotation sequence (Default =- :ZYX).
Returns
The rotation description according to the type T.
Example
julia> dcm = angle2rot(pi/2, pi/3, pi/4, :ZYX)
3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9}:
  3.06162e-17  0.5       -0.866025
 -0.707107     0.612372   0.353553
  0.707107     0.612372   0.353553
julia> q   = angle2rot(Quaternion,pi/2, pi/3, pi/4, :ZYX)
Quaternion{Float64}:
  + 0.7010573846499779 - 0.09229595564125714.i + 0.5609855267969309.j + 0.43045933457687935.kReferenceFrameRotations.angle2rot — Method.function angle2rot([T,] angle_r1::Number, angle_r2::Number, angle_r3::Number, rot_seq::Symbol = :ZYX)Convert the Euler angles eulerang (see EulerAngles) to a rotation description of type T, which can be DCM or Quaternion.
Args
- T: (OPTIONAL) Type of the rotation description (Default =- DCM).
- eulerang: Euler angles (see- EulerAngles).
Returns
The rotation description according to the type T.
Example
julia> dcm = angle2rot(EulerAngles(pi/2, pi/3, pi/4, :ZYX))
3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9}:
  3.06162e-17  0.5       -0.866025
 -0.707107     0.612372   0.353553
  0.707107     0.612372   0.353553
julia> q   = angle2rot(Quaternion,EulerAngles(pi/2, pi/3, pi/4, :ZYX))
Quaternion{Float64}:
  + 0.7010573846499779 - 0.09229595564125714.i + 0.5609855267969309.j +
  0.43045933457687935.kReferenceFrameRotations.angleaxis2quat — Method.function angleaxis2quat(a::Number, v::Vector)Convert the Euler angle a and Euler axis v, which must be a unit vector, to a quaternion.
Args
- a: Euler angle [rad].
- v: Unit vector that is aligned with the Euler axis.
Returns
A quaternion that represents the same rotation of the Euler angle and axis.
Remarks
It is expected that the vector v is unitary. However, no verification is performed inside the function. The user must handle this situation.
Example
julia> v = [1;1;1];
julia> v /= norm(v);
julia> angleaxis2quat(pi/2,v)
Quaternion{Float64}:
  + 0.7071067811865476 + 0.408248290463863.i + 0.408248290463863.j + 0.408248290463863.kReferenceFrameRotations.angleaxis2quat — Method.function angleaxis2quat(angleaxis::EulerAngleAxis{T}) where T<:RealConvert a Euler angle and Euler axis angleaxis (see EulerAngleAxis) to a quaternion.
Args
- angleaxis: Structure of type- EulerAngleAxiswith the Euler angle [rad] and a unit vector that is aligned with the Euler axis.
Returns
A quaternion that represents the same rotation of the Euler angle and axis.
Remarks
It is expected that the vector angleaxis.v is unitary. However, no verification is performed inside the function. The user must handle this situation.
Example
julia> v = [1;1;1];
julia> v /= norm(v);
julia> angleaxis2quat(EulerAngleAxis(pi/2,v))
Quaternion{Float64}:
  + 0.7071067811865476 + 0.408248290463863.i + 0.408248290463863.j + 0.408248290463863.kReferenceFrameRotations.compose_rotation — Method.@inline function compose_rotation(R1, [, R2, R3, R4, R5, ...])Compute a composed rotation using the rotations R1, R2, R3, R4, ..., in the following order:
 First rotation
 |
 |
R1 => R2 => R3 => R4 => ...
       |
       |
       Second rotationThe rotations can be described by Direction Cosine Matrices or Quaternions. Notice, however, that all rotations must be of the same type (DCM or quaternion).
The output will have the same type as the inputs (DCM or quaternion).
Args
- R1: First rotation (DCM or quaternion).
- R2, R3, R4, R5, ...: (OPTIONAL) Other rotations (DCMs or quaternions).
Returns
The composed rotation.
Example
julia> D1 = angle2dcm(+pi/3,+pi/4,+pi/5,:ZYX);
julia> D2 = angle2dcm(-pi/5,-pi/4,-pi/3,:XYZ);
julia> compose_rotation(D1,D2)
3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9}:
 1.0          0.0          5.55112e-17
 0.0          1.0          5.55112e-17
 5.55112e-17  5.55112e-17  1.0
julia> q1 = angle2quat(+pi/3,+pi/4,+pi/5,:ZYX);
julia> q2 = angle2quat(-pi/5,-pi/4,-pi/3,:XYZ);
julia> compose_rotation(q1,q2)
Quaternion{Float64}:
  + 1.0 + 0.0.i + 2.0816681711721685e-17.j + 5.551115123125783e-17.kReferenceFrameRotations.create_rotation_matrix — Function.function create_rotation_matrix(angle::Number, axis::Symbol = :X) where T<:RealCompute a rotation matrix that rotates a coordinate frame about the axis axis by the angle angle.
Args
- angle: Angle.
- axis: Axis, must be 'x', 'X', 'y', 'Y', 'z', or 'Z'.
Example
julia> create_rotation_matrix(pi/2, :X)
3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9}:
 1.0   0.0          0.0
 0.0   6.12323e-17  1.0
 0.0  -1.0          6.12323e-17ReferenceFrameRotations.dcm2angle — Function.function dcm2angle(dcm::DCM, rot_seq::Symbol=:ZYX)Convert the DCM dcm to Euler Angles given a rotation sequence rot_seq.
The rotation sequence is defined by a :Symbol. The possible values are: :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, and :ZYZ.
Args
- DCM: Direction Cosine Matrix.
- rot_seq: (OPTIONAL) Rotation sequence (Default =- :ZYX).
Returns
The Euler angles (see EulerAngles).
Example
julia> D = DCM([1. 0. 0.; 0. 0. -1; 0. -1 0.]);
julia> dcm2angle(D,:XYZ)
ReferenceFrameRotations.EulerAngles{Float64}(1.5707963267948966, 0.0, -0.0, :XYZ)ReferenceFrameRotations.dcm2quat — Method.function dcm2quat(dcm::DCM{T}) where T<:RealConvert the DCM dcm to a quaternion.
Args
- dcm: Direction Cosine Matrix that will be converted.
Returns
The quaternion that represents the same rotation of the DCM dcm.
Remarks
By convention, the real part of the quaternion will always be positive. Moreover, the function does not check if dcm is a valid direction cosine matrix. This must be handle by the user.
This algorithm was obtained from:
http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/Example
julia> dcm = angle2dcm(pi/2,0.0,0.0,:XYZ);
julia> q   = dcm2quat(dcm)
Quaternion{Float64}:
  + 0.7071067811865476 + 0.7071067811865475.i + 0.0.j + 0.0.kReferenceFrameRotations.ddcm — Method.function ddcm(Dba::DCM, wba_b::AbstractArray)Compute the time-derivative of the DCM dcm that rotates a reference frame a into alignment to the reference frame b in which the angular velocity of b with respect to a, and represented in b, is wba_b.
Args
- Dba: DCM that rotates the reference frame- ainto alignment with the reference frame- b.
- wba_b: Angular velocity of the reference frame- awith respect to the reference frame- brepresented in the reference frame- b.
Returns
The time-derivative of the DCM Dba (3x3 matrix of type SMatrix{3,3}).
Example
julia> D = DCM(eye(3));
julia> ddcm(D,[1;0;0])
3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9}:
 0.0   0.0  0.0
 0.0   0.0  1.0
 0.0  -1.0  0.0ReferenceFrameRotations.dquat — Method.function dquat(qba::Quaternion{T1}, wba_b::AbstractVector)Compute the time-derivative of the quaternion qba that rotates a reference frame a into alignment to the reference frame b in which the angular velocity of b with respect to a, and represented in b, is wba_b.
Args
- qba: Quaternion that rotates the reference frame- ainto alignment with the reference frame- b.
- wba_b: Angular velocity of the reference frame- awith respect to the reference frame- brepresented in the reference frame- b.
Returns
The quaternion with the time-derivative of qba.
Example
julia> q = eye(Quaternion);
julia> dquat(q,[1;0;0])
Quaternion{Float64}:
  + 0.0 + 0.5.i + 0.0.j + 0.0.kReferenceFrameRotations.inv_rotation — Method.@inline function inv_rotation(R)Compute the inverse rotation of R, which can be a Direction Cosine Matrix or Quaternion.
The output will have the same type as R (DCM or quaternion).
Args
- R: Rotation that will be inversed.
Returns
The inverse rotation.
Remarks
If R is a DCM, than its transpose is computed instead of its inverse to reduce the computational burden. The both are equal if the DCM has unit norm. This must be verified by the used.
If R is a quaternion, than its conjugate is computed instead of its inverse to reduce the computational burden. The both are equal if the quaternion has unit norm. This must be verified by the used.
Example
julia> D = angle2dcm(+pi/3,+pi/4,+pi/5,:ZYX);
julia> inv_rotation(D)
3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9}:
  0.353553  -0.492816  0.795068
  0.612372   0.764452  0.201527
 -0.707107   0.415627  0.572061
julia> q = angle2quat(+pi/3,+pi/4,+pi/5,:ZYX);
julia> inv_rotation(q)
Quaternion{Float64}:
  + 0.8200711519756747 - 0.06526868310243991.i - 0.45794027732580056.j - 0.336918398289752.kReferenceFrameRotations.quat2angle — Function.function quat2angle(q::Quaternion, rot_seq::Symbol = :ZYX)Convert the quaternion q to Euler Angles given a rotation sequence rot_seq.
The rotation sequence is defined by a :Symbol. The possible values are: :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, and :ZYZ.
Args
- q: Quaternion.
- rot_seq: (OPTIONAL) Rotation sequence (Default =- :ZYX).
Returns
The Euler angles (see EulerAngles).
Example
julia> q = Quaternion(cosd(45/2), sind(45/2), 0, 0);
julia> quat2angle(q,:XYZ)
ReferenceFrameRotations.EulerAngles{Float64}(0.7853981633974484, 0.0, -0.0, :XYZ)ReferenceFrameRotations.quat2angleaxis — Method.function quat2angleaxis(q::Quaternion)Convert the quaternion q to a Euler angle and axis representation.
Args
- q: The quaternion that will be converted.
Returns
The Euler angle and axis (see EulerAngleAxis).
Remarks
This function will not fail if the quaternion norm is not 1. However, the meaning of the results will not be defined, because the input quaternion does not represent a 3D rotation. The user must handle such situations.
Example
julia> q = Quaternion(cosd(45/2), sind(45/2), 0, 0);
julia> quat2angleaxis(q)
ReferenceFrameRotations.EulerAngleAxis{Float64}(0.7853981633974484, [1.0, 0.0, 0.0])ReferenceFrameRotations.quat2dcm — Method.function quat2dcm(q::Quaternion)Convert the quaternion q to a Direction Cosine Matrix.
Args
- q: Quaternion.
Returns
The Direction Cosine Matrix.
Example
julia> q = Quaternion(cosd(45/2), sind(45/2), 0, 0);
julia> quat2dcm(q)
3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9}:
 1.0   0.0       0.0
 0.0   0.707107  0.707107
 0.0  -0.707107  0.707107ReferenceFrameRotations.smallangle2dcm — Method.function smallangle2dcm(θx::Number, θy::Number, θz::Number)Create a direction cosine matrix from three small rotations of angles θx, θy, and θz about the axes X, Y, and Z, respectively.
Args
- θx: Angle of the rotation about the X-axis [rad].
- θy: Angle of the rotation about the Y-axis [rad].
- θz: Angle of the rotation about the Z-axis [rad].
Returns
The direction cosine matrix.
Remarks
No process of ortho-normalization is performed with the computed DCM.
Example
julia> smallangle2dcm(+0.01, -0.01, +0.01)
3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9}:
  1.0    0.01  0.01
 -0.01   1.0   0.01
 -0.01  -0.01  1.0ReferenceFrameRotations.smallangle2quat — Method.function smallangle2quat(θx::Number, θy::Number, θz::Number)Create a quaternion from three small rotations of angles θx, θy, and θz about the axes X, Y, and Z, respectively.
Args
- θx: Angle of the rotation about the X-axis [rad].
- θy: Angle of the rotation about the Y-axis [rad].
- θz: Angle of the rotation about the Z-axis [rad].
Returns
The quaternion.
Remarks
The quaternion is normalized.
Example
julia> smallangle2quat(+0.01, -0.01, +0.01)
Quaternion{Float64}:
  + 0.9999625021092433 + 0.004999812510546217.i - 0.004999812510546217.j + 0.004999812510546217.kReferenceFrameRotations.smallangle2rot — Method.function smallangle2rot([T,] θx::Number, θy::Number, θz::Number)Create a rotation description of type T from three small rotations of angles θx, θy, and θz about the axes X, Y, and Z, respectively.
The type T of the rotation description can be DCM or Quaternion.
Args
- T: (OPTIONAL) Type of the rotation description (Default =- DCM).
- θx: Angle of the rotation about the X-axis [rad].
- θy: Angle of the rotation about the Y-axis [rad].
- θz: Angle of the rotation about the Z-axis [rad].
Returns
The rotation description according to the type T.
Example
julia> dcm = smallangle2rot(+0.01, -0.01, +0.01);
julia> q   = smallangle2rot(Quaternion,+0.01, -0.01, +0.01);
julia> dcm = smallangle2rot(+0.01, -0.01, +0.01)
3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9}:
  1.0    0.01  0.01
 -0.01   1.0   0.01
 -0.01  -0.01  1.0
julia> q   = smallangle2rot(Quaternion,+0.01, -0.01, +0.01)
Quaternion{Float64}:
  + 0.9999625021092433 + 0.004999812510546217.i - 0.004999812510546217.j + 0.004999812510546217.kReferenceFrameRotations.vect — Method.@inline function vect(q::Quaternion{T}) where T<:RealReturn the vectorial or imaginary part of the quaternion represented by a 3x1 vector.
Args
- q: Quaterion.
Returns
The following vector: [q1; q2; q3].
Base.:* — Method.@inline function *(v::AbstractVector, q::Quaternion)Compute the multiplication v*q in which v is a quaternion with real part 0 and vectorial/imaginary part v.
Args
- v: Imaginary part of the quaternion that is the first operand of the multiplication.
- q: Second operand of the multiplication.
Returns
The quaternion v*q.
Base.:* — Method.@inline function *(λ::Number, q::Quaternion{T2})Multiply the quaternion q by the scalar λ.
Args
- λ: Scalar.
- q: Quaternion.
Returns
The quaternion λ*q.
Base.:* — Method.@inline function *(q::Quaternion, v::AbstractVector)Compute the multiplication q*v in which v is a quaternion with real part 0 and vectorial/imaginary part v.
Args
- q: First operand of the multiplication.
- v: Imaginary part of the quaternion that is the second operand of the multiplication.
Returns
The quaternion q*v.
Base.:* — Method.@inline function *(q::Quaternion, λ::Number)Multiply the quaternion q by the scalar λ.
Args
- q: Quaternion.
- λ: Scalar.
Returns
The quaternion q*λ.
Base.:* — Method.@inline function *(q1::Quaternion, q2::Quaternion)Compute the multiplication q1*q2.
Args
- q1: First operand of the multiplication.
- q2: Second operand of the multiplication.
Returns
The quaternion q1*q2.
Base.:+ — Method.@inline function +(qa::Quaternion, qb::Quaternion)Sum the quaternion qa with the quaternion qb.
Args
- qa: First operand of the sum.
- qb: Second operand of the sum.
Returns
The quaternion qa + qb.
Base.:- — Method.@inline function -(qa::Quaternion, qb::Quaternion)Subtract quaternion qb from quaternion qa.
Args
- qa: First operand of the subtraction.
- qb: Second operand of the subtraction.
Returns
The quaternion qa - qb.
Base.:/ — Method.@inline function /(λ::Number, q::Quaternion)Compute the division λ/q.
Args
- λ: First operand of the division (scalar).
- q: Second operand of the division (quaternion).
Returns
The quaternion λ/q.
Base.:/ — Method.@inline function /(q::Quaternion{T1}, λ::T1) where T1<:Real where T2<:RealCompute the division q/λ.
Args
- q: First operand of the division (quaternion).
- λ: Second operand of the division (scalar).
Returns
The quaternion q/λ.
Base.LinAlg.norm — Method.@inline function norm(q::Quaternion)Compute the Euclidean norm of the quaternion q.
Args
- q: Quaternion.
Returns
The Euclidean norm of q.
Base.conj — Method.@inline function conj(q::Quaternion{T}) where T<:RealCompute the complex conjugate of the quaternion q, which is:
q0 - q1.i - q2.j - q3.kArgs
- q: Quaternion.
Returns
The complex conjugate of the quaternion q.
Base.copy — Method.@inline function copy(q::Quaternion{T}) where T<:RealCreate a copy of the quaternion q.
Args
- q: Quaternion that will be copied.
Returns
The copy of the quaternion.
Base.eye — Method.@inline function eye(q::Quaternion{T}) where T<:RealCreate the identity quaternion (1 + 0.i + 0.j + 0.k) with the same type of another quaternion q.
Args
- q: A quaternion of type- T.
Returns
The identity quaternion of type T.
Example
julia> q1 = Quaternion{Float32}(cosd(45/2),sind(45/2),0.,0.);
julia> q2 = eye(q1)
Quaternion{Float32}:
  + 1.0 + 0.0.i + 0.0.j + 0.0.kBase.eye — Method.@inline function eye(::Type{Quaternion{T}}) where T<:RealCreate the identity quaternion (1 + 0.i + 0.j + 0.k) of type T.
Args
- Quaternion{T}, where- Tis the desired type. If- Tis omitted, then it falls back to- Float64.
Returns
The identity quaternion of type T.
Example
julia> eye(Quaternion{Float32})
Quaternion{Float32}:
  + 1.0 + 0.0.i + 0.0.j + 0.0.k
julia> eye(Quaternion{Float64})
Quaternion{Float64}:
  + 1.0 + 0.0.i + 0.0.j + 0.0.kBase.getindex — Method.@inline function getindex(q::Quaternion{T}, ::Colon) where T<:RealTransform the quaternion into a 4x1 vector of type T.
Args
- q: Quaternion.
Returns
A 4x1 vector of type T with the elements of the quaternion.
Base.imag — Method.@inline function imag(q::Quaternion{T}) where T<:RealReturn the vectorial or imaginary part of the quaternion represented by a 3x1 vector.
Args
- q: Quaterion.
Returns
The following vector: [q1; q2; q3].
Base.inv — Method.@inline function inv(q::Quaternion)Compute the inverse of the quaternion q:
conj(q)
-------
norm(q)Args
- q: Quaternion.
Returns
Inverse of the quaternion q.
Base.real — Method.@inline function real(q::Quaternion)Return the real part of the quaternion q.
Args
- q: Quaternion.
Returns
The scalar q0.
Base.show — Method.function show(io::IO, q::Quaternion{T}) where T<:RealPrint the quaternion q to the stream io.
Args
- io: Stream that will be used to print the quaternion.
- q: The quaternion that will be printed.
Base.zeros — Method.@inline function zeros(q::Quaternion{T}) where T<:RealCreate the null quaternion (0 + 0.i + 0.j + 0.k) with the same type of another quaternion q.
Args
- q: A quaternion of type- T.
Returns
The null quaternion of type T.
Example
julia> q1 = Quaternion{Float32}(cosd(45/2),sind(45/2),0,0);
julia> zeros(q1)
Quaternion{Float32}:
  + 0.0 + 0.0.i + 0.0.j + 0.0.kBase.zeros — Method.@inline function zeros(::Type{Quaternion{T}}) where T<:RealCreate the null quaternion (0 + 0.i + 0.j + 0.k) of type T.
Args
- Quaternion{T}, where- Tis the desired type. If- Tis omitted, then it falls back to- Float64.
Returns
The null quaternion of type T.
Example
julia> zeros(Quaternion{Float32})
Quaternion{Float32}:
  + 0.0 + 0.0.i + 0.0.j + 0.0.k
julia> zeros(Quaternion)
Quaternion{Float64}:
  + 0.0 + 0.0.i + 0.0.j + 0.0.k