1010package geom_test
1111
1212import (
13- "math"
1413 "testing"
1514
1615 "github.com/richardwilkes/toolbox/v2/check"
@@ -58,25 +57,11 @@ func TestNewScaleMatrix(t *testing.T) {
5857func TestNewRotationMatrix (t * testing.T ) {
5958 c := check .New (t )
6059
61- // Test 90 degree rotation (π/2 radians)
62- m := geom .NewRotationMatrix (math .Pi / 2 )
63-
64- // cos(π/2) = 0, sin(π/2) = 1
65- // For clockwise rotation: ScaleX = cos, SkewX = -sin, SkewY = sin, ScaleY = cos
66- c .True (xmath .Abs (m .ScaleX ) < 0.0001 ) // Should be ~0
67- c .True (xmath .Abs (m .SkewX + 1 ) < 0.0001 ) // Should be ~-1
68- c .Equal (float32 (0 ), m .TransX )
69- c .True (xmath .Abs (m .SkewY - 1 ) < 0.0001 ) // Should be ~1
70- c .True (xmath .Abs (m .ScaleY ) < 0.0001 ) // Should be ~0
71- c .Equal (float32 (0 ), m .TransY )
72- }
73-
74- func TestNewRotationByDegreesMatrix (t * testing.T ) {
75- c := check .New (t )
76-
7760 // Test 90 degree rotation
78- m := geom .NewRotationByDegreesMatrix (90 )
61+ m := geom .NewRotationMatrix (90 )
7962
63+ // cos(90) = 0, sin(90) = 1
64+ // For clockwise rotation: ScaleX = cos, SkewX = -sin, SkewY = sin, ScaleY = cos
8065 c .True (xmath .Abs (m .ScaleX ) < 0.0001 ) // Should be ~0
8166 c .True (xmath .Abs (m .SkewX + 1 ) < 0.0001 ) // Should be ~-1
8267 c .Equal (float32 (0 ), m .TransX )
@@ -116,10 +101,10 @@ func TestMatrixScale(t *testing.T) {
116101
117102 c .Equal (float32 (2 ), scaled .ScaleX )
118103 c .Equal (float32 (0 ), scaled .SkewX )
119- c .Equal (float32 (20 ), scaled .TransX ) // Translation is also scaled
104+ c .Equal (float32 (20 ), scaled .TransX )
120105 c .Equal (float32 (0 ), scaled .SkewY )
121106 c .Equal (float32 (3 ), scaled .ScaleY )
122- c .Equal (float32 (60 ), scaled .TransY ) // Translation is also scaled
107+ c .Equal (float32 (60 ), scaled .TransY )
123108
124109 // Original matrix should be unchanged
125110 c .Equal (float32 (1 ), m .ScaleX )
@@ -132,7 +117,7 @@ func TestMatrixRotate(t *testing.T) {
132117 c := check .New (t )
133118
134119 m := geom .NewIdentityMatrix ()
135- rotated := m .Rotate (math . Pi / 2 ) // 90 degrees
120+ rotated := m .Rotate (90 )
136121
137122 c .True (xmath .Abs (rotated .ScaleX ) < 0.0001 ) // Should be ~0
138123 c .True (xmath .Abs (rotated .SkewX + 1 ) < 0.0001 ) // Should be ~-1
@@ -146,20 +131,6 @@ func TestMatrixRotate(t *testing.T) {
146131 c .Equal (float32 (1 ), m .ScaleY )
147132}
148133
149- func TestMatrixRotateByDegrees (t * testing.T ) {
150- c := check .New (t )
151-
152- m := geom .NewIdentityMatrix ()
153- rotated := m .RotateByDegrees (90 )
154-
155- c .True (xmath .Abs (rotated .ScaleX ) < 0.0001 ) // Should be ~0
156- c .True (xmath .Abs (rotated .SkewX + 1 ) < 0.0001 ) // Should be ~-1
157- c .Equal (float32 (0 ), rotated .TransX )
158- c .True (xmath .Abs (rotated .SkewY - 1 ) < 0.0001 ) // Should be ~1
159- c .True (xmath .Abs (rotated .ScaleY ) < 0.0001 ) // Should be ~0
160- c .Equal (float32 (0 ), rotated .TransY )
161- }
162-
163134func TestMatrixMultiply (t * testing.T ) {
164135 c := check .New (t )
165136
@@ -181,13 +152,12 @@ func TestMatrixMultiply(t *testing.T) {
181152
182153 c .Equal (float32 (2 ), combined .ScaleX )
183154 c .Equal (float32 (0 ), combined .SkewX )
184- c .Equal (float32 (20 ), combined .TransX ) // Translation after scale
155+ c .Equal (float32 (20 ), combined .TransX )
185156 c .Equal (float32 (0 ), combined .SkewY )
186157 c .Equal (float32 (3 ), combined .ScaleY )
187- c .Equal (float32 (60 ), combined .TransY ) // Translation after scale
158+ c .Equal (float32 (60 ), combined .TransY )
188159}
189160
190- //nolint:gocritic // The "commented out code" is actually explanation
191161func TestMatrixTransformPoint (t * testing.T ) {
192162 c := check .New (t )
193163
@@ -214,7 +184,7 @@ func TestMatrixTransformPoint(t *testing.T) {
214184 c .Equal (float32 (21 ), result3 .Y ) // 7 * 3
215185
216186 // Test 90-degree rotation (point (1,0) should become (0,1))
217- rotation := geom .NewRotationByDegreesMatrix (90 )
187+ rotation := geom .NewRotationMatrix (90 )
218188 p2 := geom .NewPoint (1.0 , 0.0 )
219189 result4 := rotation .TransformPoint (p2 )
220190
@@ -226,8 +196,8 @@ func TestMatrixTransformPoint(t *testing.T) {
226196 p3 := geom .NewPoint (3.0 , 4.0 )
227197 result5 := combined .TransformPoint (p3 )
228198
229- c .Equal (float32 (16 ), result5 .X ) // (3 + 5) * 2 = 16
230- c .Equal (float32 (18 ), result5 .Y ) // (4 + 5) * 2 = 18
199+ c .Equal (float32 (16 ), result5 .X )
200+ c .Equal (float32 (18 ), result5 .Y )
231201}
232202
233203func TestMatrixString (t * testing.T ) {
0 commit comments