NSPoint is a C-struct used in Cocoa to represent a point in the plane.
How do you translate, rotate, and do other geometric operations on NSPoint in an Objective-C style ?
So far, I’m using C functions to make these calculations, but in my opinion it doesn’t look good with the rest of the code.
-(NSPoint) rotateAroundNSPoint: (NSPoint)origin pointToRotate:(NSPoint)point andDegreesAngle:(float)angleD;
NSPoint rotateAround(NSPoint origin, NSPoint initialPos, float angleDegrees)
/* C-style function */
NSPoint pointD = rotateAround(point000, point001, 72*9);
/* Objective-C method */
NSPoint pointE = [self rotateAroundNSPoint:point000 pointToRotate:point001 andDegreesAngle:72*12];
Are there other alternatives ?
Cocoa defines macros pointing to functions like this so you could do that to keep a consistent style
e.g.
it would still be calling the same code, just looks a bit neater. You could also move the geometric functions into a common file as well, there is no need for them to be associated with a class
note: I just looked and cocoa actually uses inline functions so you could do that as well (the calling code looks the same either way)