Skip to content

Commit 1d6803c

Browse files
author
Dominique d'Argent
committed
Improve comment formatting
1 parent cb38823 commit 1d6803c

File tree

1 file changed

+33
-29
lines changed

1 file changed

+33
-29
lines changed

Foundation/NSAffineTransform.swift

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ private extension NSAffineTransformStruct {
132132
Creates an affine transformation matrix from translation values.
133133
The matrix takes the following form:
134134

135-
[ 1 0 tX ]
136-
[ 0 1 tY ]
137-
[ 0 0 1 ]
135+
[ 1 0 tX ]
136+
[ 0 1 tY ]
137+
[ 0 0 1 ]
138138
*/
139139
static func translation(tX tX: CGFloat, tY: CGFloat) -> NSAffineTransformStruct {
140140
return NSAffineTransformStruct(
@@ -148,9 +148,9 @@ private extension NSAffineTransformStruct {
148148
Creates an affine transformation matrix from scaling values.
149149
The matrix takes the following form:
150150

151-
[ sX 0 0 ]
152-
[ 0 sY 0 ]
153-
[ 0 0 1 ]
151+
[ sX 0 0 ]
152+
[ 0 sY 0 ]
153+
[ 0 0 1 ]
154154
*/
155155
static func scale(sX sX: CGFloat, sY: CGFloat) -> NSAffineTransformStruct {
156156
return NSAffineTransformStruct(
@@ -164,9 +164,9 @@ private extension NSAffineTransformStruct {
164164
Creates an affine transformation matrix from rotation value (angle in radians).
165165
The matrix takes the following form:
166166

167-
[ cos α -sin α 0 ]
168-
[ sin α cos α 0 ]
169-
[ 0 0 1 ]
167+
[ cos α -sin α 0 ]
168+
[ sin α cos α 0 ]
169+
[ 0 0 1 ]
170170
*/
171171
static func rotation(radians angle: CGFloat) -> NSAffineTransformStruct {
172172
let α = Double(angle)
@@ -182,9 +182,9 @@ private extension NSAffineTransformStruct {
182182
Creates an affine transformation matrix from a rotation value (angle in degrees).
183183
The matrix takes the following form:
184184

185-
[ cos α -sin α 0 ]
186-
[ sin α cos α 0 ]
187-
[ 0 0 1 ]
185+
[ cos α -sin α 0 ]
186+
[ sin α cos α 0 ]
187+
[ 0 0 1 ]
188188
*/
189189
static func rotation(degrees angle: CGFloat) -> NSAffineTransformStruct {
190190
let α = Double(angle) * M_PI / 180.0
@@ -198,13 +198,13 @@ private extension NSAffineTransformStruct {
198198
the `transformStruct`'s affine transformation matrix.
199199
The resulting matrix takes the following form:
200200

201-
[ m11_T m12_T tX_T ] [ m11_M m12_M tX_M ]
202-
T * M = [ m21_T m22_T tY_T ] [ m21_M m22_M tY_M ]
203-
[ 0 0 1 ] [ 0 0 1 ]
201+
[ m11_T m12_T tX_T ] [ m11_M m12_M tX_M ]
202+
T * M = [ m21_T m22_T tY_T ] [ m21_M m22_M tY_M ]
203+
[ 0 0 1 ] [ 0 0 1 ]
204204

205-
[ (m11_T*m11_M + m12_T*m21_M) (m11_T*m12_M + m12_T*m22_M) (m11_T*tX_M + m12_T*tY_M + tX_T) ]
206-
= [ (m21_T*m11_M + m22_T*m21_M) (m21_T*m12_M + m22_T*m22_M) (m21_T*tX_M + m22_T*tY_M + tY_T) ]
207-
[ 0 0 1 ]
205+
[ (m11_T*m11_M + m12_T*m21_M) (m11_T*m12_M + m12_T*m22_M) (m11_T*tX_M + m12_T*tY_M + tX_T) ]
206+
= [ (m21_T*m11_M + m22_T*m21_M) (m21_T*m12_M + m22_T*m22_M) (m21_T*tX_M + m22_T*tY_M + tY_T) ]
207+
[ 0 0 1 ]
208208
*/
209209
func concat(transformStruct: NSAffineTransformStruct) -> NSAffineTransformStruct {
210210
let (t, m) = (self, transformStruct)
@@ -221,9 +221,9 @@ private extension NSAffineTransformStruct {
221221
Applies the affine transformation to `toPoint` and returns the result.
222222
The resulting point takes the following form:
223223

224-
[ x' ] [ x ] [ m11 m12 tX ] [ x ] [ m11*x + m12*y + tX ]
225-
[ y' ] = T [ y ] = [ m21 m22 tY ] [ y ] = [ m21*x + m22*y + tY ]
226-
[ 1 ] [ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ]
224+
[ x' ] [ x ] [ m11 m12 tX ] [ x ] [ m11*x + m12*y + tX ]
225+
[ y' ] = T [ y ] = [ m21 m22 tY ] [ y ] = [ m21*x + m22*y + tY ]
226+
[ 1 ] [ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ]
227227
*/
228228
func applied(toPoint p: NSPoint) -> NSPoint {
229229
let x = (m11 * p.x) + (m12 * p.y) + tX
@@ -235,10 +235,10 @@ private extension NSAffineTransformStruct {
235235
/**
236236
Applies the affine transformation to `toSize` and returns the result.
237237
The resulting size takes the following form:
238-
239-
[ w' ] [ w ] [ m11 m12 tX ] [ w ] [ m11*w + m12*h ]
240-
[ h' ] = T [ h ] = [ m21 m22 tY ] [ h ] = [ m21*w + m22*h ]
241-
[ 0 ] [ 0 ] [ 0 0 1 ] [ 1 ] [ 0 ]
238+
239+
[ w' ] [ w ] [ m11 m12 tX ] [ w ] [ m11*w + m12*h ]
240+
[ h' ] = T [ h ] = [ m21 m22 tY ] [ h ] = [ m21*w + m22*h ]
241+
[ 0 ] [ 0 ] [ 0 0 1 ] [ 1 ] [ 0 ]
242242

243243
Note: Translation has no effect on the size.
244244
*/
@@ -253,13 +253,17 @@ private extension NSAffineTransformStruct {
253253
/**
254254
Returns the inverse affine transformation matrix or `nil` if it has no inverse.
255255
The receiver's affine transformation matrix can be divided into matrix sub-block as
256-
[ M t ]
257-
[ 0 1 ]
256+
257+
[ M t ]
258+
[ 0 1 ]
259+
258260
where `M` represents the linear map and `t` the translation vector.
259261

260262
The inversion can then be calculated as
261-
[ inv(M) -inv(M) * t ]
262-
[ 0 1 ]
263+
264+
[ inv(M) -inv(M) * t ]
265+
[ 0 1 ]
266+
263267
if `M` is invertible.
264268
*/
265269
var inverse: NSAffineTransformStruct? {

0 commit comments

Comments
 (0)