I try to write a rotation system for a theoratical flight device. My main problem is that I practically nearly never rotate around the axes of the coordinate system, but around the axes of the vehicle (pitch, roll, jaw). An object rolled around it's own z axis changes a following pitch rotation around its x axis.
My furthest idea is to use a position vector and three direction vectors of the vehicle which describe the positions {1,0,0},{0,1,0},{0,0,1}. I guess this vectors could somehow be used to store the axes of the object. When rotating the vehicle I would rotate two of this points around the axis symbolised by the the remaining point.
As vectors I use javafx.geometry.Point3D
.
So far I have this code for my start rotation which don't respects the vehicles rotation which it gets over time. Further is rotates a JavaFX shape which is also not my goal. (I want to have and transform raw coordinates for other uses than just drawing them)
final Point3D isFacing = new Point3D(0, 0, 1).normalize();
final Point3D shouldFace = position.subtract(goalDirection).normalize();
final double rotationAngle = Math.toDegrees(Math.acos(isFacing.dotProduct(shouldFace)));
final Point3D rotationAxis = isFacing.crossProduct(shouldFace).normalize();
Rotate rotate = new Rotate(rotationAngle, rotationAxis);
model.getTransforms().addAll(rotate);
How to store the parameters?
How to compute the rotations?