Giter VIP home page Giter VIP logo

coordinate-frame-converter's Introduction

Graphics enthusiast, three.js collaborator, open source maintainer, former Mars helicopter operator & rover tool designer. If you like my work consider becoming a Github Sponsor. Open for contract work for robotics and data visualization, shader development, interactive 3d graphics, and contributions to any of the following projects!

โœจ Project Highlights

๐Ÿช Robotics & NASA JPL

๐ŸŒฑ Miscellaneous

coordinate-frame-converter's People

Contributors

gkjohnson avatar

Stargazers

 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

coordinate-frame-converter's Issues

Redundant Quaternion.Euler(Quaternion.eulerAngles) is needed

The ToQuaternion function requires that the formed quaternion be stuff into Quaternion.Euler(Quaternnion.eulerAngles) to avoid inconsistencies when using the AngleExtraction class functions. For example

Quaternion q = Quaternion.Euler(90, -27, 170);
Matrix4x4 mat;

// Outputs (0, -90, 0), which is not equivalent!
mat = Matrix4x4.TRS(Vector3.zero, q, Vector3.one);
Debug.Log(AngleExtraction.ExtractEulerZXY(mat, out eulerResult) * Mathf.Rad2Deg);

// Outputs (163, -27, 170), which is!
mat = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(q.eulerAngles), Vector3.one);
Debug.Log(AngleExtraction.ExtractEulerZXY(mat, out eulerResult) * Mathf.Rad2Deg);

Why is this happening?

Address the floating point precision issue

Unity uses floats for a lot of its operations, which means there can be quite a bit of accumulated error as rotations are converted. If the quaternions, vectors, and matrices were all doubles it would address the problem.

Right now the extractAngleXYZ functions check against an epsilon when checking how to extract.

Convert matrix

How to convert right hand matrix to left hand matrix(Unity) and back? Right hand matrix: right-handed coordinate system where positive X-axis points to the right, positive Y-axis away from the viewer and positive Z-axis points up. In the context of characters this means that positive X is right, positive Y is forward, and positive Z is up.

Consider removing `ToQuaternion`

ToQuaternion basically only works with properly with Unity-frame axes because we have to assume certain conventions when pulling the new rotation order out of the axis.

There even seem to be subtle rotation offsets when consistently converting to a different frame like XYZ instead of XY-Z. Possibly because the euler application for quaternions assumes the axis conventions? This should be investigated (the problem can be seen when rotating like in the example image)

Either way, it might make things less confusing if it wasn't there

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.