Finn Hunt
Finn Hunt

Reputation: 103

How to find the point on a circle when a point within it is projected out on to it?

I need to find the coordinates of a point on a circle (point b in the picture) using the variables shown in the picture.

enter image description here

I know this is quite a maths related problem but i'm writing the program which this is going to be part of in python. I've tried the following code and had no luck, i've check the angle its passing though and that's correct. I've also tried the angle in radians and degrees both with no luck.

    int_x = r * math.cos(angle)
    int_y = r * math.sin(angle)

Please ask any questions about the problem

Thank you

Upvotes: 0

Views: 154

Answers (3)

cmxu
cmxu

Reputation: 972

If the circle center is known to be (c_x, c_y) and the point a is at (a_x, a_y). Then we simply construct a line from the center through point a of length r. This is simply a similar triangle. We compute the hypotenuse of the triangle to be

h = sqrt((a_x - c_x)^2 + (a_y-c_y)^2)

and then we know that

(b_x, b_y) = (c_x + (a_x - c_x) * r/h, c_y + (a_y - c_y) * r/h).

Then you don't need to worry about angles at all! Hope that helps.

Upvotes: 2

user0
user0

Reputation: 195

I cannot comment (not enough rep), so this answer is only to indicate that in Changming's answer https://stackoverflow.com/a/59636967/12575476, it should be r/h instead of h/r (twice).

Upvotes: 0

bensenberner
bensenberner

Reputation: 168

Given the position of angle in the diagram, if you were to draw a triangle that encloses angle, you'd find that int_x is opposite the angle and int_y is adjacent, which means you have your equations flipped (i.e. int_x = r * sin.cos(angle) )

Upvotes: 1

Related Questions