Open pollend opened 8 years ago
The Quat4 class already has shortestArcQuat. Does that already do what you need?
The method could use some more Javadoc for sure, especially on what it actually computes. Maybe something along these lines: http://eigen.tuxfamily.org/dox/classEigen_1_1QuaternionBase.html#ac35460294d855096e9b687cadf821452
I manage to produce something similar with using shortestArcQuat two times. one for the rotating in the horizontal and one for the vertical plane. A lookat function is probably not necessary at all since you can reproduce it. Might be a nice little helper function.
Quat4f horizontalRotation =Quat4f.shortestArcQuat(Vector3f.north(),new Vector3f(tangent).setY(0).normalize());
Quat4f verticalRotation = Quat4f.shortestArcQuat(new Vector3f(tangent).setY(0).normalize(),new Vector3f(tangent));
verticalRotation.mul(horizontalRotation);
location.setLocalRotation( verticalRotation);
I think a lookat function would be really useful for Quat4. The basic use would be for having an object point in the direction of another entity.
https://docs.unity3d.com/ScriptReference/Quaternion.LookRotation.html