Skip to content

Commit 1a36095

Browse files
authored
Merge pull request #797 from ikesyo/cgfloat-pi
2 parents 1f2db58 + 684601b commit 1a36095

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Foundation/NSAffineTransform.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ public struct AffineTransform : ReferenceConvertible, Hashable, CustomStringConv
117117
[ 0 0 1 ]
118118
*/
119119
public init(rotationByDegrees angle: CGFloat) {
120-
let α = Double(angle) * M_PI / 180.0
121-
self.init(rotationByRadians: CGFloat(α))
120+
let α = angle * .pi / 180.0
121+
self.init(rotationByRadians: α)
122122
}
123123

124124
/**
@@ -145,8 +145,8 @@ public struct AffineTransform : ReferenceConvertible, Hashable, CustomStringConv
145145
[ 0 0 1 ]
146146
*/
147147
public mutating func rotate(byDegrees angle: CGFloat) {
148-
let α = Double(angle) * M_PI / 180.0
149-
return rotate(byRadians: CGFloat(α))
148+
let α = angle * .pi / 180.0
149+
return rotate(byRadians: α)
150150
}
151151

152152
/**
@@ -413,4 +413,4 @@ extension NSAffineTransform : _StructTypeBridgeable {
413413
public func _bridgeToSwift() -> AffineTransform {
414414
return AffineTransform._unconditionallyBridgeFromObjectiveC(self)
415415
}
416-
}
416+
}

TestFoundation/TestNSAffineTransform.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,19 @@ class TestNSAffineTransform : XCTestCase {
173173
checkPointTransformation(noop, point: point, expectedPoint: point)
174174

175175
let tenEighty = NSAffineTransform()
176-
tenEighty.rotate(byRadians: CGFloat(6 * M_PI))
176+
tenEighty.rotate(byRadians: 6 * .pi)
177177
checkPointTransformation(tenEighty, point: point, expectedPoint: point)
178178

179179
let rotateCounterClockwise = NSAffineTransform()
180-
rotateCounterClockwise.rotate(byRadians: CGFloat(M_PI_2))
180+
rotateCounterClockwise.rotate(byRadians: .pi / 2)
181181
checkPointTransformation(rotateCounterClockwise, point: point, expectedPoint: NSPoint(x: CGFloat(-10.0), y: CGFloat(10.0)))
182182

183183
let rotateClockwise = NSAffineTransform()
184-
rotateClockwise.rotate(byRadians: CGFloat(-M_PI_2))
184+
rotateClockwise.rotate(byRadians: -.pi / 2)
185185
checkPointTransformation(rotateClockwise, point: point, expectedPoint: NSPoint(x: CGFloat(10.0), y: CGFloat(-10.0)))
186186

187187
let reflectAboutOrigin = NSAffineTransform()
188-
reflectAboutOrigin.rotate(byRadians: CGFloat(M_PI))
188+
reflectAboutOrigin.rotate(byRadians: .pi)
189189
checkPointTransformation(reflectAboutOrigin, point: point, expectedPoint: NSPoint(x: CGFloat(-10.0), y: CGFloat(-10.0)))
190190
}
191191

0 commit comments

Comments
 (0)