Calculating angle a segment forms with a ray
Posted
by
kr1zz
on Game Development
See other posts from Game Development
or by kr1zz
Published on 2014-08-20T15:30:15Z
Indexed on
2014/08/20
16:37 UTC
Read the original article
Hit count: 415
I am given a point C and a ray r starting there. I know the coordinates (xc, yc) of the point C and the angle theta the ray r forms with the horizontal, theta in (-pi, pi]. I am also given another point P of which I know the coordinates (xp, yp): how do I calculate the angle alpha that the segment CP forms with the ray r, alpha in (-pi, pi]?
Some examples follow:
I can use the the atan2 function.
© Game Development or respective owner