Oliver
Oliver

Reputation: 23510

iPhone - Drawing something at a given point using angle from center of view

I have a view with a point on its center.
I have an angle in degrees (or radian, that's not the problem). I have a circle which center is the center of the view, and the radius is R.

I'd like to draw :

How may I do that ?

Upvotes: 1

Views: 305

Answers (1)

Ladislav
Ladislav

Reputation: 7283

I think it you could calculate the image position with:

CGPoint center = self.view.center;
float x = radius * cos(angle);
float y = radius * sin(angle);

CGPoint newPoint = CGPointMake(center.x + x, center.y + y);

Let me know if it worked.

As for drawing an arc you would have two points, one is newPoint that is calculated above (on circle depending the angle) and point above the center intersecting the circle which is calculated easily:

CGPoint pointAboveCenter = CGPointMake(center.x, center.y + radius);

Upvotes: 1

Related Questions