Giter Site home page Giter Site logo

juliaspace / referenceframerotations.jl Goto Github PK

View Code? Open in Web Editor NEW
56.0 7.0 11.0 3.01 MB

A toolbox to represent 3D rotations of coordinate frames for Julia language.

License: Other

Julia 100.00%
julia direction-cosine-matrices quaternion euler-angles dcm 3d-rotation reference-frame

referenceframerotations.jl's Introduction

referenceframerotations.jl's People

Contributors

chrisrackauckas avatar fingolfin avatar hyrodium avatar juliatagbot avatar juliohm avatar mortenpi avatar ronisbr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

referenceframerotations.jl's Issues

Refactor EulerAngles and EulerAngleAxis

I think we can potentially simplify things if we refactor these two representations. Could you please clarify if one can be easily represented in terms of the other? I understand that EulerAngleAxis is a rotation around an arbitrary unitary vector whereas EulerAngles are rotations specified in terms of the canonical basis. Can the latter be written in terms of the former as a sequence of rotations with pre-defined static vectors? What is the benefit of keeping them separate as two separate structs?

After we sort out the redundancy, I think we could make things more static and turn rot_seq simply a utility function. We could write something like basis(:X) to get (1,0,0) an basis(:XY) to return a list of such basis vectors. Does that make sense?

This will help define conversion methods.

Use `Quaternions.Quaternion` instead of `ReferenceFrameRotations.Quaternion`?

Hi! I'm a maintainer of Quaternions.jl, and I wonder if we can replace ReferenceFrameRotations.Quaternion with Quaternions.Quaternion. Before 2022, Quaternions.jl was not well-maintained, but the package is now ready to be used in other packages. See my post on Julia discourse for more information.

If this change is acceptable, I will be glad to open a PR.
I think the hardest part of the migration is avoiding type piracy. (e.g. Quaternion(u::UniformScaling{T}) should not be defined.)

dcm_to_quat followed by quat_to_dcm return a different DCM

Hi

First, I've been using ReferenceFrameRotations.jl for some time for 3D rotation, it's great, thanks for making it available
My issue here is with the following operation:

q = dcm_to_quat(dcm1)
dcm2 = quat_to_dcm(q)

In most cases, dcm1 == dcm2. But for some values this doesn't happen. Here one of the cases I found:

julia> dcm1 = DCM([-0.997512 0.0704939 0.0; 0.0704939 0.997512 0.0; 0.0 0.0 1.0])
3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9} with indices SOneTo(3)×SOneTo(3):
 -0.997512   0.0704939  0.0
  0.0704939  0.997512   0.0
  0.0        0.0        1.0

julia> q = dcm_to_quat(dcm1)
Quaternion{Float64}:
  + 0.7071067811865476 + 0.0.i + 0.0.j + 0.0.k

julia> dcm2 = quat_to_dcm(q)
3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9} with indices SOneTo(3)×SOneTo(3):
 0.5  0.0  0.0
 0.0  0.5  0.0
 0.0  0.0  0.5

Any idea of what it can be?

No function of angle2dcm or dcm2angle

Hi,

I am trying to using your Rotations.jl. The julia version is 0.4.5.

After "using Rotations", I tried to use the function angle2dcm or dcm2angle, julia couldn't find the functions. Instead I got errors as follows.

Couldn't find angle2dcm
Perhaps you meant angle
ERROR: "angle2dcm" is not defined in module Main
in error at /Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/sys.dylib
in which_module at /Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/sys.dylib
in call at /Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/sys.dylib

Jianghai

Add Base.convert to convert between different rotation representations

@ronisbr I am trying to refactor some code in the Meshes.jl + GeoStats.jl ecosystem and noticed that it would be much easier to work with rotations from ReferenceFrameRotations.jl if they implemented Base.convert instead of different functions angle_to_dcm, quaternion_to_dcm, ... for the pairs:

Base.convert(::Type{DCM}, a::EulerAngles) = angle_to_dcm(a)
Base.convert(::Type{DCM}, q::Quaternion) = quarternion_to_dcm(a)
...

That way users can always call the same function convert regardless of representation and Julia decides what to do. Can I submit a PR with this feature? It should be backward compatible.

Can you elaborate on why you have chosen specific names for the conversions? Are you aware that Julia can do pretty cool conversions in the presence of convert methods like converting a vector of rotation objects to direction cosine matrix:

# prefix Vector with DCM to perform implicit conversion
DCM[EulerAngles(...), Quaternion(...), ...]

problem with dcm_to_quat for simple rotation

A matrix represented a simple rotation; swapping the x and y.

julia> dcm = [0 1 0;1 0 0;0 0 1] |> SMatrix{3,3,Float64}
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 0.0  1.0  0.0
 1.0  0.0  0.0
 0.0  0.0  1.0

It doesn't rotate back.

julia> dcm_to_quat(dcm) |> quat_to_dcm
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 0.5  0.0  0.0
 0.0  0.5  0.0
 0.0  0.0  0.5

How to use rotation objects to compute coordinates of a given point?

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 do R*[1,2,3] to retrieve the coordinates of the point. Now, suppose we are on a different frame of reference like R = 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 to DCM first?

Cannot update to latest version?

For some reason I cannot update ReferenceFrameRotations to the latest version because of a conflict with SatelliteToolbox, that I am also using by the way:

(@v1.8) pkg> status --outdated ReferenceFrameRotations
Status `~/.julia/environments/v1.8/Project.toml`
⌅ [74f56ac7] ReferenceFrameRotations v1.0.1 (<v3.0.0): SatelliteToolbox

Any ideas? Should I delete ~/.julia/registries/General.tar.gz and recreate it?

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

DCM optimizations

The DCM representation is currently an alias for SMatrix. That is nice but we could do even better if we specify properties of rotation matrices that are not implemented by a generic SMatrix. That is what Rotations.jl does with inv == transpose for example.

Maybe DCM should be a new type of StaticMatrix, and that is possible with StaticArrays.jl interface:

# inherit most basic methods like SMatrix
struct DCM{T} <: StaticArray{3,T} end

# add specific methods for rotations
inv(D::DCM) = transpose(D)
...

Product between a quaternion and a pure quaternion

The product of a unit quaternion and a vector has non-zero real part. By product definition it must be zero.

using ReferenceFrameRotations
q = Quaternion(cos(π/6), 0,  0, sin(π/6))
v =  [3, -1.5,  -0.354];
q * v
Quaternion{Float64}:
  + 0.177 + 3.34808⋅i + 0.200962⋅j - 0.306573⋅k

Julia 1.6.1, ReferenceFrameRotations.jl, v 1.0.1

Remove `eye` in favor of `I`

eye was deprecated in Julia v0.7 and removed in Julia v1.0. We should change the way we are creating identities (DCM and Quaternion) to match the new format in Julia.

Add ClockwiseAngle for 2D applications

I know the package only implements 3D rotations, but it would be nice to add this tiny struct for convenience and have conversion methods with DCM. Something as simple as

struct ClockwiseAngle{T}
  a::T
end

function Base.convert(::Type{<:DCM}, cw::ClockwiseAngle)
    s, c = sincos(cw.a)
    @SMatrix [c s; -s c]
end

I can submit a PR for that if you feel that it is useful.

How to cite this package?

Hi, I've been using this package for a long time and I love it. Really good work.

I wanted to know, how do I cite it? Are there any citations to the theory used to write the package? Where can I find it?

Best regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.