From f311b347e2d1f0ba173516e93f3c24299a9c70bc Mon Sep 17 00:00:00 2001 From: fairendil Date: Sat, 4 Nov 2023 06:48:18 +0300 Subject: [PATCH] There was a bug in the TransformFromCoordSys and TransformToCoordSys methods. The bug occurred when calculating the BaseChangeMatrix and a copy of the coordinate system was rotated instead of the base coordinate system rotation. This resulted in the OffsetToBase being added twice, causing an issue in the transformation process. --- src/Spatial/Euclidean/CoordinateSystem.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Spatial/Euclidean/CoordinateSystem.cs b/src/Spatial/Euclidean/CoordinateSystem.cs index ed53dd1..5f3584a 100644 --- a/src/Spatial/Euclidean/CoordinateSystem.cs +++ b/src/Spatial/Euclidean/CoordinateSystem.cs @@ -161,9 +161,9 @@ public CoordinateSystem BaseChangeMatrix get { var matrix = Build.DenseOfColumnVectors(XAxis.ToVector(), YAxis.ToVector(), ZAxis.ToVector()); - var cs = new CoordinateSystem(this); - cs.SetRotationSubMatrix(matrix.Transpose()); - return cs; + var baseCs = new CoordinateSystem(); + baseCs.SetRotationSubMatrix(matrix.Transpose()); + return baseCs; } } @@ -256,7 +256,7 @@ public static CoordinateSystem Rotation(Angle angle, Vector3D v) /// A rotated coordinate system public static CoordinateSystem Rotation(Angle yaw, Angle pitch, Angle roll) { - var cs = new CoordinateSystem(); + var cs = new CoordinateSystem(); var cosY = yaw.Cos; var sinY = yaw.Sin; var cosP = pitch.Cos; @@ -276,7 +276,7 @@ public static CoordinateSystem Rotation(Angle yaw, Angle pitch, Angle roll) cs[1, 2] = sinY * sinP * cosR - cosY * sinR; cs[2, 2] = cosP * cosR; - return cs; + return cs; } /// /// Rotates around Z @@ -354,7 +354,7 @@ public static CoordinateSystem Translation(Vector3D translation) /// /// Creates a rotating coordinate system /// - /// A 3×3 matrix with the rotation portion + /// A 3�3 matrix with the rotation portion /// A rotated coordinate system /// A rotating coordinate system public static CoordinateSystem SetRotationSubMatrix(Matrix r, CoordinateSystem coordinateSystem)