How to calculate end-point at a given center plus an radius and angle?
Posted
by mystify
on Stack Overflow
See other posts from Stack Overflow
or by mystify
Published on 2010-04-26T11:32:24Z
Indexed on
2010/04/26
11:33 UTC
Read the original article
Hit count: 160
iphone
I'm trying to do some basic quartz core drawing with arcs, but have an F in math ;-)
I have a point:
CGPoint center = CGPointMake(100.0f, 100.0f);
CGFloat radius = 50.0f;
CGFloat startAngle = 20.0f / 180.0f * M_PI;
CGFloat endAngle = 150.0f / 180.0f * M_PI;
CGContextAddArc(c, center.x, center.y, radius, startAngle, endAngle, 0);
Now I want to draw a little dot on the middle of the arc. I mean, not the center point, but the little curve (arc) which is made up between the angles 20-150 degrees. I looked into quartz but unfortunately, there seems no helper function to calculate this.
Probably some hardcore trigonometric logic with atan and stuff of this kind needed?
© Stack Overflow or respective owner