Meonardo - 1 year ago 132

Objective-C Question

I have 5 subviews(White) added to the superview(Gray), when I rotate the superview I want to know the angle(like 1 and 2) of each of the subview with the red circle.(the center of the subviews and the red circle are ON the same circle)

**Start Position:**

**Rotated Position:**

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

From your comment you appear to want to determine the coordinates of the centres of your five circles for a given rotation. The centres will all lie on a circle. So your question boils down to what are the coordinates of a point on a circle of radius *r* for an angle *θ*. The parametric equations for a circle give you that:

x=rcosθ

y=rsinθ

The angle, *θ*, in these equations is measured in *radians* from the positive x-axis in an anti-clockwise direction. If your angle are in degrees you will find the `M_PI`

constant for *π* useful as:

360 degrees = 2

πradians

The rest is simple math, take your angle of rotation to give you the angle for A (remembering to adjust for 0 being the x-axis and measuring anti-clockwise if needed), the other centres are multiples of 72 degrees (0.4 *π* radians) from this.

HTH

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**