Convert global rotations to local rotations
in
Programming Questions
•
3 years ago
I have a gyroscope on a rocket. It outputs an angle for X, Y, and Z (relative to a fixed frame).
Since Processing's rotateX(), rotateY(), and rotateZ() are relative to the local frame, how might I convert my gyro values to be accepted into Processing's functions? I attempted to do an applyMatrix() but was seeing the same results (might have applied an incorrect matrix though.)
Since Processing's rotateX(), rotateY(), and rotateZ() are relative to the local frame, how might I convert my gyro values to be accepted into Processing's functions? I attempted to do an applyMatrix() but was seeing the same results (might have applied an incorrect matrix though.)
- pushMatrix();
- translate(.......); // center matrix in view window
- // Draw XYZ Fixed Frame
- stroke(0xFFFF00FF);
- line(0, 0, 0, 100, 0, 0);
- stroke(0xFFFFFF00);
- line(0, 0, 0, 0, 100, 0);
- stroke(0xFF00FFFF);
- line(0, 0, 0, 0, 0, 100);
- // Rotations should go here
- // rotateX(), rotateY(), and rotateZ() are relative to the moving frame not the fixed frame.
- // Multiple rotations on different axis will therefore be invalid.
- // Draw cute box
- box(40);
- // Draw box's local XYZ
- stroke(0xFFFF00FF);
- line(0, 0, 0, 100, 0, 0);
- stroke(0xFFFFFF00);
- line(0, 0, 0, 0, 100, 0);
- stroke(0xFF00FFFF);
- line(0, 0, 0, 0, 0, 100);
- popMatrix();
1