Merge branch 'main' of https://git.passer.life/RoboidControl/RoboidControl-Csharp
This commit is contained in:
commit
828223f548
@ -12,8 +12,8 @@ namespace LinearAlgebra
|
||||
// public static float Rad2Deg = 360.0f / ((float)Math.PI * 2);
|
||||
// public static float Deg2Rad = ((float)Math.PI * 2) / 360.0f;
|
||||
|
||||
public const float Deg2Rad = 360.0f / ((float)Math.PI * 2); //0.0174532924F;
|
||||
public const float Rad2Deg = ((float)Math.PI * 2) / 360.0f; //57.29578F;
|
||||
public const float Rad2Deg = 360.0f / ((float)Math.PI * 2); //0.0174532924F;
|
||||
public const float Deg2Rad = ((float)Math.PI * 2) / 360.0f; //57.29578F;
|
||||
|
||||
/// <summary>
|
||||
/// Clamp the angle between the given min and max values
|
||||
|
@ -1,3 +1,8 @@
|
||||
using System;
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
using Vector3Float = UnityEngine.Vector3;
|
||||
#endif
|
||||
|
||||
namespace LinearAlgebra
|
||||
{
|
||||
|
||||
@ -32,6 +37,23 @@ namespace LinearAlgebra
|
||||
this.horizontal += 180;
|
||||
this.vertical = 180 - this.vertical;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3Float ToVector3()
|
||||
{
|
||||
float verticalRad = (Angle.pi / 2) - this.vertical * Angle.Deg2Rad;
|
||||
float horizontalRad = this.horizontal * Angle.Deg2Rad;
|
||||
float cosVertical = (float)Math.Cos(verticalRad);
|
||||
float sinVertical = (float)Math.Sin(verticalRad);
|
||||
float cosHorizontal = (float)Math.Cos(horizontalRad);
|
||||
float sinHorizontal = (float)Math.Sin(horizontalRad);
|
||||
|
||||
float x = sinVertical * sinHorizontal;
|
||||
float y = cosVertical;
|
||||
float z = sinVertical * cosHorizontal;
|
||||
|
||||
Vector3Float v = new(x, y, z);
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
using System.Numerics;
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
using Quaternion = UnityEngine.Quaternion;
|
||||
#endif
|
||||
|
||||
namespace LinearAlgebra
|
||||
{
|
||||
|
||||
@ -27,6 +32,15 @@ namespace LinearAlgebra
|
||||
SwingTwist r = new SwingTwist(up, right, forward);
|
||||
return r;
|
||||
}
|
||||
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
public Quaternion ToQuaternion() {
|
||||
Quaternion q = Quaternion.Euler(-this.swing.vertical,
|
||||
this.swing.horizontal,
|
||||
this.twist);
|
||||
return q;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
#if !UNITY_5_6_OR_NEWER
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace LinearAlgebra.Test
|
||||
@ -167,3 +168,4 @@ namespace LinearAlgebra.Test
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user