Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Foundation/NSAffineTransform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ public struct AffineTransform : ReferenceConvertible, Hashable, CustomStringConv
[ 0 0 1 ]
*/
public init(rotationByDegrees angle: CGFloat) {
let α = Double(angle) * M_PI / 180.0
self.init(rotationByRadians: CGFloat(α))
let α = angle * .pi / 180.0
self.init(rotationByRadians: α)
}

/**
Expand All @@ -145,8 +145,8 @@ public struct AffineTransform : ReferenceConvertible, Hashable, CustomStringConv
[ 0 0 1 ]
*/
public mutating func rotate(byDegrees angle: CGFloat) {
let α = Double(angle) * M_PI / 180.0
return rotate(byRadians: CGFloat(α))
let α = angle * .pi / 180.0
return rotate(byRadians: α)
}

/**
Expand Down Expand Up @@ -413,4 +413,4 @@ extension NSAffineTransform : _StructTypeBridgeable {
public func _bridgeToSwift() -> AffineTransform {
return AffineTransform._unconditionallyBridgeFromObjectiveC(self)
}
}
}
8 changes: 4 additions & 4 deletions TestFoundation/TestNSAffineTransform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,19 @@ class TestNSAffineTransform : XCTestCase {
checkPointTransformation(noop, point: point, expectedPoint: point)

let tenEighty = NSAffineTransform()
tenEighty.rotate(byRadians: CGFloat(6 * M_PI))
tenEighty.rotate(byRadians: 6 * .pi)
checkPointTransformation(tenEighty, point: point, expectedPoint: point)

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

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

let reflectAboutOrigin = NSAffineTransform()
reflectAboutOrigin.rotate(byRadians: CGFloat(M_PI))
reflectAboutOrigin.rotate(byRadians: .pi)
checkPointTransformation(reflectAboutOrigin, point: point, expectedPoint: NSPoint(x: CGFloat(-10.0), y: CGFloat(-10.0)))
}

Expand Down