Squashed 'LinearAlgebra/' changes from 9b2a047..493c19c

493c19c Fix ToVector3
35b6830 Support sending poses from Unity changes
6d74649 Compatibility

git-subtree-dir: LinearAlgebra
git-subtree-split: 493c19cbe22465ead382a42ff952b06a24f60dda
This commit is contained in:
Pascal Serrarens 2025-06-03 17:49:51 +02:00
parent 9b2a04746d
commit fd01740d76
3 changed files with 12 additions and 3 deletions

View File

@ -106,7 +106,7 @@ namespace LinearAlgebra {
// } // }
public Vector3 ToVector3() { public Vector3 ToVector3() {
float verticalRad = (float)(Math.PI / 2 - this.direction.vertical) * Angle.Deg2Rad; float verticalRad = (float)(90 - this.direction.vertical) * Angle.Deg2Rad;
float horizontalRad = this.direction.horizontal * Angle.Deg2Rad; float horizontalRad = this.direction.horizontal * Angle.Deg2Rad;
float cosVertical = (float)Math.Cos(verticalRad); float cosVertical = (float)Math.Cos(verticalRad);
float sinVertical = (float)Math.Sin(verticalRad); float sinVertical = (float)Math.Sin(verticalRad);

View File

@ -29,11 +29,18 @@ namespace LinearAlgebra {
} }
#if UNITY_5_3_OR_NEWER #if UNITY_5_3_OR_NEWER
public static SwingTwist FromQuaternion(Quaternion q) {
// q.ToAngles(out float right, out float up, out float forward);
UnityEngine.Vector3 angles = q.eulerAngles;
SwingTwist r = new SwingTwist(angles.y, angles.x, angles.z);
return r;
}
public Quaternion ToQuaternion() { public Quaternion ToQuaternion() {
Quaternion q = Quaternion.Euler(-this.swing.vertical, Quaternion q = Quaternion.Euler(-this.swing.vertical,
this.swing.horizontal, this.swing.horizontal,
this.twist); this.twist);
return q; return q;
} }
#endif #endif
} }

View File

@ -1,3 +1,4 @@
#if !UNITY_5_6_OR_NEWER
using NUnit.Framework; using NUnit.Framework;
namespace LinearAlgebra.Test { namespace LinearAlgebra.Test {
@ -15,3 +16,4 @@ namespace LinearAlgebra.Test {
} }
}; };
} }
#endif