Re: Dead Reckoning
Re: Dead Reckoning
- Subject: Re: Dead Reckoning
- From: Marco S Hyman <email@hidden>
- Date: Fri, 09 Oct 2015 22:10:25 -0700
The code is in Swift. #define is not an option.
> There’s very little reason to use macros for things like this, when an inline function is as efficient and safer.
IMHO function calls also help readability. My version looks like this:
private let π = M_PI
private let d2r = π / 180 // degrees to radians adjustment
private let r2d = 180 / π // radians to degrees adjustments
private func degreesToRadians(degrees: Double) -> Double {
return degrees * d2r
}
private func radiansToDegrees(radians: Double) -> Double {
return radians * r2d
}
Yeah, "π = M_PI" wasn’t really needed.
Marc
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden