rotation function with 4 arguments..??

edited June 2016 in Library Questions

Hi Everyone !

I am working on a project (I would love to share with u all) that involves visualizing data received from gyro sensor using arduino. I got the basic code which uses toxiclibs library to convert the quaternion values (recieved through calculation in arduino) of the rotation to 4 values- Rotation angle in radians and rotation axis x,y,z (as described in the toxiclibs documentation).

And then uses rotate function with the 4 values as argument to rotate. which works!! Here is the part of code I am talking about -
float[] axis = quat.toAxisAngle(); rotate(axis[0], -axis[1], axis[3], axis[2]);

My question is how does this kind of rotation function exactly works?? There is no description about this kind of rotate function even in Processing refernce. Also more importantly I need to track the new coordinates of rotated object after rotation.

I am stuck here.. tried a couple of ideas. Didn't worked out. Need some inspiration from you guys.

Thanks !

Answers

  • edited June 2016 Answer ✓

    My question is how does this kind of rotation function exactly works??

    Does the rotation formula work in your sketch?

    I found this:

    rotate(double theta, double x, double y) Concatenates the current Graphics2D Transform with a translated rotation transform.

    from

    https://docs.oracle.com/javase/7/docs/api/java/awt/Graphics2D.html

    maybe it's this rotate(double theta, double x, double y) plus z-axis?

    Also more importantly I need to track the new coordinates of rotated object after rotation.

    afaik look at screenX and screenY please (also look at modelX etc.)

    https://www.processing.org/reference/screenX_.html

    Best, Chrisir ;-)

  • Answer ✓

    You say yourself what it's doing

    4 values- Rotation angle in radians and rotation axis x,y,z (as described in the toxiclibs documentation).

    So it's a rotation but around the axis defined by the last 3 parameters rather than, say, the x axis. If you were rotating around x axis then this last 3 would be 1, 0, 0

  • @Chrisir modelX modelY modelZ worked. Thanx a lot !! I never knew these functions existed. Things are now a lot easier. Also switching to these function for thigs I did earlier.

    @koogs Ok.. So does it means the axis of rotation is in a way a line from origin to the point (x,y,z)..

    Thanks.!!

Sign In or Register to comment.