@@ -49,6 +49,9 @@ public struct AffineTransform: Equatable, CustomDebugStringConvertible {
4949 /// [ x y ]
5050 /// [ z w ]
5151 /// ```
52+ /// - Remark: The matrices in some graphics frameworks, such as WinUI's `Matrix` and
53+ /// CoreGraphics' `CGAffineTransform`, take the transpose of this matrix. The reason for
54+ /// this difference is left- vs right-multiplication; the values are identical.
5255 public var linearTransform : SIMD4 < Double >
5356 /// The translation applied after the linear transformation.
5457 public var translation : SIMD2 < Double >
@@ -73,14 +76,13 @@ public struct AffineTransform: Equatable, CustomDebugStringConvertible {
7376 }
7477
7578 public static func rotation( radians: Double , center: SIMD2 < Double > ) -> AffineTransform {
76- // Making the sine negative so that positive rotations are clockwise
77- let sine = sin ( - radians)
79+ let sine = sin ( radians)
7880 let cosine = cos ( radians)
7981 return AffineTransform (
8082 linearTransform: SIMD4 ( x: cosine, y: - sine, z: sine, w: cosine) ,
8183 translation: SIMD2 (
82- x: - center . x * cosine - center . y * sine + center. x,
83- y: center. x * sine - center. y * cosine + center. y
84+ x: - center . x * cosine + center . y * sine + center. x,
85+ y: - center . x * sine - center . y * cosine + center. y
8486 )
8587 )
8688 }
@@ -95,7 +97,8 @@ public struct AffineTransform: Equatable, CustomDebugStringConvertible {
9597 )
9698
9799 public func inverted( ) -> AffineTransform ? {
98- let determinant = linearTransform. x * linearTransform. w - linearTransform. y * linearTransform. z
100+ let determinant =
101+ linearTransform. x * linearTransform. w - linearTransform. y * linearTransform. z
99102 if determinant == 0.0 {
100103 return nil
101104 }
0 commit comments