CGPoint
public extension CGPoint
-
Rotate this point around a given point, by an angle given in degrees.
Declaration
Swift
func rotated(around inCenter: CGPoint, byDegrees inDegrees: CGFloat, precisionInDecimalPlaces inPrecision: UInt8? = nil) -> CGPoint
Parameters
around
Another point, that is the “fulcrum” of the rotation.
byDegrees
The rotation angle, in degrees. 0 is no change. - is counter-clockwise, + is clockwise.
precisionInDecimalPlaces
The precision, in decimal places to the right of the decimal. This is optional, and, if omitted, uses full precision.
Return Value
The transformed point.
-
This was inspired by this SO answer. Rotate this point around a given point, by an angle given in radians.
Declaration
Swift
func rotated(around inCenter: CGPoint, byRadians inRadians: CGFloat, precisionInDecimalPlaces inPrecision: UInt8? = nil) -> CGPoint
Parameters
around
Another point, that is the “fulcrum” of the rotation.
byRadians
The rotation angle, in radians. 0 is no change. - is counter-clockwise, + is clockwise.
precisionInDecimalPlaces
The precision, in decimal places to the right of the decimal. This is optional, and, if omitted, uses full precision. The range is 0…14.
Return Value
The transformed point.