pradyunsg
pradyunsg

Reputation: 19406

Python - Pygame Drawing Angle

I need to draw an angle(in Pygame), given it's
1. Measure of the angle (θ)
2. Endpoints of the base(A & B)

Image showing A,B,C and θ
Here I know
1. Measure of θ (in radians and degrees)
2. (x,y) of A and B
3. Measure of BC
My Question
How do I calculate the position of the Co-ordinates(x,y) of point C.

Upvotes: 0

Views: 370

Answers (1)

Emanuele Paolini
Emanuele Paolini

Reputation: 10162

Let BC be the length of the corresponding segment, theta be the angle in radians. Then compute the slope alpha of BC and then the coordinates of C like that:

alpha = atan2(A.y-B.y, A.x-B.x) - theta
C.x = B.x + BC * cos(alpha)
C.y = B.y + BC * sin(alpha)

Upvotes: 1

Related Questions