iphone - determine angle between two points on a circle with respect to center -
i have ring(width 25px) uiview
. when user selects on ring, want calculate angle between the points selected on fixed point on circle considering center of circle. have found few examples not taking center consideration.
what optimum way ?
you'll have handle code (i'm java developer), simplest way angle between 2 points on circle (measured against center) recall geometry of situation. triangle formed 2 points on circumference of circle , circle's center isosceles.
an isosceles triangle, recall, has (at least) 2 sides of same length -- radial segments 2 points. bisecting angle results in radial segment perpendicular , bisects line connecting 2 points. forms pair of right triangles, radius hypotenuse, , half distance between 2 points 'opposite' side.
moving factor of 2 denominator , recognizing twice radius is, calculate distance between 2 points (on circumference), , divide diameter. value sine of half-angle (you desire whole angle). take arcsine, , you'll have half angle:
θ/2 = sin-1(d/d)
with d
distance between 2 points, , d
diameter of circle. since diameter given, , distance between 2 points simple calculate, getting point should easy, , need double value calculated whole angle between 2 points.
Comments
Post a Comment