5

The situation is as follows:

I have a circle with a diameter of $20$ and a center at $(0,0)$. A point $P$ inside that circle is at $(2,0)$.

How do I calculate the distance from $P$ to the edge of the circle for a given angle $\theta$?

Alvaro Fuentes
  • 823
  • 7
  • 21

3 Answers3

3

A different solution without having to solve an equation is by rotating the axis back and forth. (more suitable for mathematical programs)

r is the radius of the circle.

O is the origin at [0, 0].

P is any point within the circle [Px, Py].

Q is point at perimeter of the circle

θ is angle from point P to Q positive with x-axis

R is the rotation matrix with R = [cosθ -sinθ; sinθ cosθ]

R' is the inverse rotation matrix

Now rotate such that x-axis is parallel to PQ. Describe point P and Q as P'and Q' in the new axis orientation.

P' = R'P

because of the parallel alligned the following formula's are true:

Q' = [Q'x, Q'y] = [r * cosφ, r * sinφ], with φ is angle from O to Q (positive with rotated x-axis)

Q'y = P'y

Substitute φ for P'y gives:

Q'x = r * sin(arccos(P'y/r))

Now all that is left to do is rotate the axis back how it was

Q = RQ'

you can now use pythagoras to get the length PQ

Remco
  • 31
1

Let the centre of the circle be $O$, and let the point $(2,0)$ be $P$. Draw a line $PQ$ to the periphery of the circle, making an angle $\theta$ with the positive $x$-axis. We want to find the length of $PQ$.

Consider the triangle $OPQ$. We have $\angle OPQ=180^\circ-\theta$. By the Cosine Law, with $x=PQ$, we have $$100=x^2+4-(2x)(2\cos(180^\circ-\theta))=x^2+4+4x\cos\theta.$$ This is a quadratic equation in $x$: Solve.

André Nicolas
  • 507,029
  • I think I need math lessons, I'm in over my head! :) Where does the 4 come from? I do not know how to solve quadratic equations, I need to learn more. Thanks very much, I will try to work this out. – user114508 Dec 10 '13 at 01:48
  • The cosine law says that if $ABC$ is a triangle, with sides $a,b,c$ ($c$ opposite angle $C$, then $c^2=a^2+b^2-2ab\cod(\theta)$. In our case. $PQ$ is the $b$, so the $4$ is $b^2$. Quadratic equations are solved using the Quadratic Formula. Look it up and ask me if you have trouble. The quadratic equation here is $x^2+4x\cos\theta-96=0$. The relevant root in unsimplified form is $\frac{-4\cos\theta+\sqrt{16\cos^2\theta+384}}{2}$. – André Nicolas Dec 10 '13 at 03:23
  • If you need more detail, just ask. You may want to add to your question, or use a comment. – André Nicolas Dec 10 '13 at 03:25
0

The distance from $(2,0)$ to $(20,0)$ + the distance from $(2,0)$ to $(0,0)$ equals the radius.

user99680
  • 6,708
  • And for a given angle? – user114508 Dec 09 '13 at 04:01
  • I'm not sure I understand: if you're at $(a,b)$ inside of the circle, then the distance from $(a,b)$ to $(0,0)$ is $\sqrt {a^2+b^2}$. Then substract the radius from this distance. Is that what you meant? – user99680 Dec 09 '13 at 04:03
  • I think the part you missed is the last part "for a given degree" (angle I should have said). Thanks – user114508 Dec 10 '13 at 01:52