0

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

2
  • Are the coordinates of O at (0, 0)?
    – norok2
    Jan 7, 2020 at 22:34
  • 1
    The question is confusing. Either theta or a are unnecessary to find b
    – JohanC
    Jan 7, 2020 at 22:36

3 Answers 3

2

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.

2
  • This answer makes most sense, as the problem description with only a picture doesn't tell whether theta is between 0 and 2 pi, nor whether it's sign changes if it would be to the left, nor whether theta would always be measured starting from the up-direction.
    – JohanC
    Jan 7, 2020 at 22:40
  • Thank you very much for your answer i'm going to try it now!
    – Finn Hunt
    Jan 7, 2020 at 22:40
1

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) )

2
  • Thank you very much i've spotted my error and corrected it and now the code is working a charm! Thank you.
    – Finn Hunt
    Jan 7, 2020 at 22:41
  • @FinnHunt Be careful that theta is calculated by atan2, otherwise you can get surprises when a is on the Y-axis.
    – JohanC
    Jan 7, 2020 at 22:50
0

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).

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.