Rotations
This example was generated on 2024-11-18T22:29:37.060.
Before diving into the creation of the axes graph, it is worth highlighting that transformations that express the relative orientation or its time-derivatives between two generic set of axes are represented by a Rotation
object, which stores a Direction Cosine Matrix (DCM) and its derivatives. This package leverages the already available ReferenceFrameRotations.jl to define the DCM objects.
A time-fixed rotation between two axes and its derivative can then be expressed as follows:
using StaticArrays
using FrameTransformations
using ReferenceFrameRotations
dcm = angle_to_dcm(π / 3, :Z)
δdcm = DCM(0I)
R = Rotation(dcm, δdcm)
2-element Rotation{2, Float64}:
[0.5000000000000001 0.8660254037844386 0.0; -0.8660254037844386 0.5000000000000001 0.0; 0.0 0.0 1.0]
[0.0 0.0 0.0; 0.0 0.0 0.0; 0.0 0.0 0.0]
R[1]
DCM{Float64}:
0.5 0.866025 0.0
-0.866025 0.5 0.0
0.0 0.0 1.0
R[2]
DCM{Float64}:
0.0 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0
A rotation object is returned by all the rotation functions that are applied to the FrameSystem
. It provide overloads to the basic algebraic operations so that multiplication and inversions can be efficiently computed leveraging the properties of rotation matrixes.
For example, to rotate a generic vector v
, we can simply do:
v = [1.0, -6.0, 3.0, 0.0, 5.0, 0]
R * v
6-element StaticArraysCore.SVector{6, Float64} with indices SOneTo(6):
-4.696152422706632
-3.8660254037844393
3.0
4.330127018922193
2.5000000000000004
0.0
For a static vector vector sv
:
sv = SA[1.0, -6.0, 3.0, 0.0, 5.0, 0]
R * sv
6-element StaticArraysCore.SVector{6, Float64} with indices SOneTo(6):
-4.696152422706631
-3.8660254037844393
3.0
4.330127018922193
2.5000000000000004
0.0
And for a Translation
t = Translation(1.0, -6.0, 3.0, 0.0, 5.0, 0)
R * t
Translation{2, Float64}:
[-4.696152422706631, -3.8660254037844393, 3.0]
[4.330127018922193, 2.5000000000000004, 0.0]
The inverse can instead be taken as:
inv(R)
2-element Rotation{2, Float64}:
[0.5000000000000001 -0.8660254037844386 0.0; 0.8660254037844386 0.5000000000000001 0.0; 0.0 0.0 1.0]
[0.0 0.0 0.0; 0.0 0.0 0.0; 0.0 0.0 0.0]
See the Rotation API for more information on this object.
This page was generated using Literate.jl.