@@ -133,6 +133,69 @@ public void SkewTest()
133133 Assert . Equal ( new PointF ( 30 , 30 ) , pout ) ;
134134 }
135135
136+ [ Fact ]
137+ public void TransformMatrix4x4_AffineMatchesMatrix3x2 ( )
138+ {
139+ PointF p = new ( 13 , 17 ) ;
140+ Matrix3x2 m3 = Matrix3x2Extensions . CreateRotationDegrees ( 45 , PointF . Empty ) ;
141+ Matrix4x4 m4 = new ( m3 ) ;
142+
143+ PointF r3 = PointF . Transform ( p , m3 ) ;
144+ PointF r4 = PointF . Transform ( p , m4 ) ;
145+
146+ Assert . Equal ( r3 . X , r4 . X , ApproximateFloatComparer ) ;
147+ Assert . Equal ( r3 . Y , r4 . Y , ApproximateFloatComparer ) ;
148+ }
149+
150+ [ Fact ]
151+ public void TransformMatrix4x4_Identity ( )
152+ {
153+ PointF p = new ( 42.5F , - 17.3F ) ;
154+ PointF result = PointF . Transform ( p , Matrix4x4 . Identity ) ;
155+
156+ Assert . Equal ( p . X , result . X , ApproximateFloatComparer ) ;
157+ Assert . Equal ( p . Y , result . Y , ApproximateFloatComparer ) ;
158+ }
159+
160+ [ Fact ]
161+ public void TransformMatrix4x4_Translation ( )
162+ {
163+ PointF p = new ( 10 , 20 ) ;
164+ Matrix4x4 m = Matrix4x4 . CreateTranslation ( 5 , - 3 , 0 ) ;
165+ PointF result = PointF . Transform ( p , m ) ;
166+
167+ Assert . Equal ( 15F , result . X , ApproximateFloatComparer ) ;
168+ Assert . Equal ( 17F , result . Y , ApproximateFloatComparer ) ;
169+ }
170+
171+ [ Fact ]
172+ public void TransformMatrix4x4_Scale ( )
173+ {
174+ PointF p = new ( 10 , 20 ) ;
175+ Matrix4x4 m = Matrix4x4 . CreateScale ( 2 , 3 , 1 ) ;
176+ PointF result = PointF . Transform ( p , m ) ;
177+
178+ Assert . Equal ( 20F , result . X , ApproximateFloatComparer ) ;
179+ Assert . Equal ( 60F , result . Y , ApproximateFloatComparer ) ;
180+ }
181+
182+ [ Fact ]
183+ public void TransformMatrix4x4_Projective ( )
184+ {
185+ // A taper matrix with M14 != 0 produces W != 1, requiring perspective divide.
186+ PointF p = new ( 100 , 50 ) ;
187+ Matrix4x4 m = Matrix4x4 . Identity ;
188+ m . M14 = 0.005F ; // perspective component
189+
190+ PointF result = PointF . Transform ( p , m ) ;
191+
192+ // W = x*M14 + M44 = 100*0.005 + 1 = 1.5
193+ // X = x*M11 + M41 = 100, Y = y*M22 + M42 = 50
194+ // result = (100/1.5, 50/1.5)
195+ Assert . Equal ( 100F / 1.5F , result . X , ApproximateFloatComparer ) ;
196+ Assert . Equal ( 50F / 1.5F , result . Y , ApproximateFloatComparer ) ;
197+ }
198+
136199 [ Theory ]
137200 [ InlineData ( float . MaxValue , float . MinValue ) ]
138201 [ InlineData ( float . MinValue , float . MaxValue ) ]
0 commit comments