I imagine that this is a simple question, but I\'m getting some strange results with my current code and I don\'t have the math background to fully understand why. My goal
-(NSMutableArray *)GetPointsForCircle
{
NSMutableArray *Points = [[NSMutableArray alloc] init];
CGPoint CenterPoint = CGPointMake(160, 230);
CGPoint Point;
for (float Angel = 0; Angel <= 360; Angel+= 60)
{
Point.x = CenterPoint.x + 100 * cos(Angel);
Point.y = CenterPoint.y + 100 * sin(Angel);
[Points addObject:[NSValue valueWithCGPoint:Point]];
}
return Points;
}
- (CGPoint)pointOnCircle:(int)thisPoint withTotalPointCount:(int)totalPoints
{
CGPoint centerPoint = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height / 2);
float radius = 100.0;
float angle = ( 2 * M_PI / (float)totalPoints ) * (float)thisPoint;
CGPoint newPoint;
newPoint.x = (centerPoint.x) + (radius * cosf(angle));
newPoint.y = (centerPoint.y) + (radius * sinf(angle));
return newPoint;
}