Closed juliohm closed 4 years ago
Hi @juliohm !
First off, I really appreciate your work @ronisbr, it is super useful.
Nice!! I am glad it is being useful :)
The idea here is to provide some tools to rotate reference frames. It is assumed that all frames are right-handed and orthonormal.
Let's suppose you have an origin frame, which is called o
, and a destination frame, which is called d
. We know, for example, that those frames are related by the following rotations (Euler angles):
Hence, we can construct, for example, a DCM that rotates the o
reference frame into alignment to d
:
julia> Ddo = angle_to_dcm(0.3, 0.1, 1.3, :XYZ)
3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9} with indices SOneTo(3)×SOneTo(3):
0.266162 0.928414 0.259238
-0.958744 0.227124 0.17095
0.0998334 -0.294044 0.950564
Now, if a vector v
has the representation [1,2,3]
in the o
reference frame, then its representation in the d
reference frame can be found by:
julia> v_o = [1,2,3]
3-element Array{Int64,1}:
1
2
3
julia> v_d = Ddo*v_o
3-element StaticArrays.SArray{Tuple{3},Float64,1,3} with indices SOneTo(3):
2.900705997639297
0.008353646752887522
2.3634371013093065
The same can be accomplished by Quaternions, which is another method to represent rotations:
julia> qdo = angle_to_quat(0.3, 0.1, 1.3, :XYZ)
Quaternion{Float64}:
+ 0.7816408973671287 + 0.14872367635093683.i - 0.05098406742924803.j + 0.6035887677252959.k
julia> vect(qdo\v_o*qdo)
3-element StaticArrays.SArray{Tuple{3},Float64,1,3} with indices SOneTo(3):
2.9007059976392973
0.008353646752887467
2.3634371013093065
That is really nice @ronisbr , thanks for clarifying the workflow. We are adding ReferenceFrameRotations.jl as a dependency in GeoStats.jl: https://github.com/JuliaEarth/GeoStatsBase.jl/pull/55
Closing the issue, and looking forward to playing with the rotations. :+1:
Nice!! If you need any help, please, let me know.
First off, I really appreciate your work @ronisbr, it is super useful. I am doing some research on how to operate with coordinate transformations efficiently and really liked the approach of this package. I wonder if you have an example of how these reference frames are used to compute coordinates of a point?
Say for example that we have a point with coordinates (1,2,3) with respect to the canonical Euclidean basis (i.e. (1,0,0), (0,1,0), (0,0,1)), which I understand can be easily constructed with
R = DCM(I)
. For this rotation object, we can simply doR*[1,2,3]
to retrieve the coordinates of the point. Now, suppose we are on a different frame of reference likeR = EulerAngles(0.5,0.5,0.5)
, how do you compute the coordinates of the point with respect to this frame? Do we need to convert toDCM
first?