From f1a550e7f33448d0fecfed1ae0b48737d637d218 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Fri, 7 Mar 2025 12:23:15 +0100 Subject: [PATCH] Removed dependecies on UnityEngine --- LinearAlgebra/Matrix.cs | 9 ++++++++- LinearAlgebra/Quaternion.cs | 4 ++++ test/UnitTest1.cs | 6 +++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/LinearAlgebra/Matrix.cs b/LinearAlgebra/Matrix.cs index e1b453c..4d37dda 100644 --- a/LinearAlgebra/Matrix.cs +++ b/LinearAlgebra/Matrix.cs @@ -4,8 +4,8 @@ using Passer.LinearAlgebra; #if UNITY_5_3_OR_NEWER using Vector3Float = UnityEngine.Vector3; using Vector2Float = UnityEngine.Vector2; -#endif using Quaternion = UnityEngine.Quaternion; +#endif public readonly struct Slice { public uint start { get; } @@ -91,6 +91,7 @@ public class Matrix2 { return new Matrix2(result); } +#if UNITY_5_3_OR_NEWER public Vector3Float GetRow3(int rowIx) { uint cols = this.nCols; Vector3Float row = new() { @@ -100,6 +101,7 @@ public class Matrix2 { }; return row; } +#endif public void SetRow(int rowIx, Matrix1 v) { for (uint ix = 0; ix < v.size; ix++) this.data[rowIx, ix] = v.data[ix]; @@ -430,6 +432,7 @@ public class Matrix1 { return new Matrix1(result); } +#if UNITY_5_3_OR_NEWER public static Matrix1 FromQuaternion(Quaternion q) { float[] result = new float[4]; result[0] = q.x; @@ -438,6 +441,7 @@ public class Matrix1 { result[3] = q.w; return new Matrix1(result); } +#endif public Vector2Float vector2 { get { @@ -453,6 +457,8 @@ public class Matrix1 { return new Vector3Float(this.data[0], this.data[1], this.data[2]); } } + +#if UNITY_5_3_OR_NEWER public Quaternion quaternion { get { if (this.size != 4) @@ -460,6 +466,7 @@ public class Matrix1 { return new Quaternion(this.data[0], this.data[1], this.data[2], this.data[3]); } } +#endif public Matrix1 Clone() { float[] data = new float[this.size]; diff --git a/LinearAlgebra/Quaternion.cs b/LinearAlgebra/Quaternion.cs index b1146ed..57f8f5d 100644 --- a/LinearAlgebra/Quaternion.cs +++ b/LinearAlgebra/Quaternion.cs @@ -1,5 +1,7 @@ using System; +#if UNITY_5_3_OR_NEWER using Quaternion = UnityEngine.Quaternion; +#endif namespace Passer.LinearAlgebra { public class QuaternionOf { @@ -15,6 +17,7 @@ namespace Passer.LinearAlgebra { this.w = w; } +#if UNITY_5_3_OR_NEWER public static Matrix2 ToRotationMatrix(Quaternion q) { float w = q.x, x = q.y, y = q.z, z = q.w; @@ -64,6 +67,7 @@ namespace Passer.LinearAlgebra { return new Quaternion(x, y, z, w); } +#endif } // public class Quaternion : QuaternionOf { diff --git a/test/UnitTest1.cs b/test/UnitTest1.cs index f32d4b8..be1bd9c 100644 --- a/test/UnitTest1.cs +++ b/test/UnitTest1.cs @@ -3,7 +3,7 @@ using System; using System.Threading; using NUnit.Framework; -using Passer.RoboidControl; +using RoboidControl; namespace ControlCore.test { public class Tests { @@ -29,7 +29,7 @@ namespace ControlCore.test { [Test] public void Test_SiteServer() { - SiteServer siteServer = new SiteServer(7681); + SiteServer siteServer = new SiteServer(7681); ulong milliseconds = (ulong)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); ulong startTime = milliseconds; @@ -63,7 +63,7 @@ namespace ControlCore.test { [Test] public void Test_ThingMsg() { - SiteServer siteServer = new SiteServer(); + SiteServer siteServer = new SiteServer(7681); Participant participant = new Participant("127.0.0.1"); Thing thing = new Thing(participant) { name = "First Thing",