GithubHelp home page GithubHelp logo

gaschler / rotationconverter Goto Github PK

View Code? Open in Web Editor NEW
259.0 259.0 73.0 168 KB

Simple HTML+JS page to convert between different 3D rotation formats, quaternion, Rodrigues angles, etc.

License: MIT License

HTML 100.00%

rotationconverter's People

Contributors

andreasplesch avatar foohyfooh avatar gaschler avatar malibrud 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  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

rotationconverter's Issues

Precission issue with quaternions

While entering quaternions to convert them to Euler angles, the quaternion on the output side is not identical to the input side.

For example, entering the values

X:0 Y:0 Z:-0,7071072 W:-0,7071062

on the left side (degree selected) results in

[ 0, 0, -0.7071073, -0.7071063 ]

on the right side (also degree selected). Both values that are not 0 are altered by 0,0000001. This precision is not needed for my use case, but still, there seems to be an issue.

Quaternion to Rotation Matrix differs from Eigen Library

Hi, I was using the online tool (https://www.andre-gaschler.com/rotationconverter/) and was getting weird results so I checked against Eigen and the results were different. I feel like there is a bug somewhere.

To reproduce error:

  1. On the online tool, enter a Euler Angle rotation of -90 deg about x with convention XYZ.

  2. Tool outputs:

Quaternion [x y z w] = [-0.070, 0, 0, 0.707], and
R [ 1 0 0
0 0 1
0 -1 0 ]

  1. Create program using Eigen in C++ to convert from Quaternion to Rotation matrix:
Eigen::Quaternionf q = Eigen::Quaternionf(0.7071068 , 0, 0, -0.7071068 );
// Note eigen quaternion format is [w x y z]
Eigen::Matrix3f m(q);
std::cout << "R:\n" << m << "\n";
  1. Terminal output:

R:
-1.19209e-07 1 0
-1 -1.19209e-07 -0
-0 0 1

Notice 4 is very different than 2.

Is this a bug or am I doing something wrong? Thanks.

Would you accept a PR to optionally change the Quaternion format?

Hi there,

First of all, thanks for the great tool. I use it all the time.

Right now quaternions are [x, y, z, w]. In all of my work however the format used is [w, x, y, z]. This makes for an annoying conversion everytime I want to use the output. I think it would be great if there was a selector for using [x, y, z, w] vs [w, x, y, z] format. Could this be added if I wrote the code for it?

Thanks

Requires webpage reload sometimes to get correct result

Input:
Euler ZYX (rad)

And I was reading output:
Euler ZYX (degree)

Basically converting rad to degree
Y component of output was zero. And when I opened the website again, it gave me correct result in which Y component was non-zero

I had the page open for long and doing lot of computations

Math Error

For this rotation matrix
rotation_matrix = [[-0.8829475929 , -0.1294039002,-0.4512850306],
[0.0000000000,-0.9612616959, 0.2756373558],
[-0.4694715628,0.2433733398, 0.8487437005]]

I expect the following results in Angle Axis (radians)

  • array([-0.73690633, 0.41537825, 2.95556985])

But instead, I get the following:

  • [ -0.7369063, 0.4153783, 2.9555698 ]

For this second rotation matrix (mirrored from the first)
rotation_matrix = [[-0.8829475929 , 0.1294039002,0.4512850306],
[0.0000000000,-0.9612616959, 0.2756373558],
[0.4694715628,0.2433733398 , 0.8487437005]]

I expect the following results in Angle Axis (radians)

  • array([-0.73690633, -0.41537825, -2.95556985])

But instead, I get the following:

  • [ 0.7691948, 0.4335785, 3.0850716 ]

Notice how my expected results are mirrored and symmetric (which matches my inputs & expectation) whereas the actual results are not symmetric.

Negative in Mobile Version

First off, want to say that this is a super cool app and I've wanted to do the same for a long time! I want to be able to use it on my phone but I unfortunately cannot add a negative sign? Is this an issue on my end or something that can someday be worked on implementing?

Thanks!

A question regarding Euler angles from quaternion

I'm having this quaternion (x,y,z,w):

-0.299166,-0.106895,-0.0551278,0.946591

My (C++ based) conversion gives a rotation matrix, which is pretty much identical to the R given in your page https://www.andre-gaschler.com/rotationconverter/ for the given quaternion:

R: 0.971, 0.168,-0.169,-0.040, 0.815, 0.578, 0.235,-0.555, 0.798

I'm having a doubt regarding the 'yaw' value. The coordinate system, which generates this quaternion, has the following axis convention: X is getting larger towards right, Y is getting larger towards the sky and Z is getting negative, if moving forward. Hence my code adapts to Euler Angles by sorting the values Euler like (NED, x forward/north, y right/east, z down):

float calculateRotation(const rs2_quaternion &quaternion)
{
    // http://www.chrobotics.com/library/understanding-euler-angles
    // The original axis naming is different from Euler. Align
    float w = quaternion.w;
    float x = -quaternion.z;
    float z = -quaternion.y;
    float y = quaternion.x;

    float pitch = -asin(2.0 * (x * z - w * y)) * 180.0 / M_PI;
    float roll = atan2(2.0 * (w * x + y * z), w * w - x * x - y * y + z * z) * 180.0 / M_PI;
    float yaw = atan2(2.0 * (w * z + x * y), w * w + x * x - y * y - z * z) * 180.0 / M_PI;

    return yaw;
}

The values returned for 'yaw' exactly reflect the rotation of my device around the y axis (Euler's z).

I'm now having a little doubt regarding the Euler Angle conversion of your page https://www.andre-gaschler.com/rotationconverter/: Whereas my calculation for the given quaternion gives 11.9819 degrees, which is ok for me, since I rotated right a bit, the only matching value is the Y value, if I choose "YXZ", but the sign is inverted, so -11.9818413 instead.

The same for these two examples:

Q: 0.27421,-0.359027,-0.139633,0.881142
R: 0.703, 0.049,-0.709,-0.443, 0.811,-0.383, 0.556, 0.583, 0.592
Yaw: 50.1589

Your value for yaw: Y=-50.1588726, if YXZ is selected.

Or:

Q: 0.961622,0.00379452,-0.274343,-0.00216471
R: 0.849, 0.006,-0.528, 0.008,-1.000, 0.002,-0.528,-0.006,-0.849
Yaw: 148.153

Your value for yaw: Y=-148.1534521, if YXZ is selected.

In all cases your and my conversion of Q to R or R to Q give identical results. Just the yaw sign is different...

Any idea, why this might be the case?

multiple axis rotation convertion to itself mismatches

I've tried to convert the rotation of (-0.305291, -6.4072, 91.6871) in the order XZY to the same order again.
This results in rotations shifted by 180°
image

The same bug happens with any angle greater than 90° or less then -90°
The rotation (91, 91, 91) will fail for any rotation order mapping to itself.

This looks like a minor thing to me, because the resulting angle is basically the same.
Its just rotated in the opposite direction bus resulting in the same position.
By reentering the resulting angle as input ,the rotation matrix and quaterion stays the same.

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.