【发布时间】:2022-12-02 01:04:04
【问题描述】:
I need to get the angle of the blue line in the image. Assuming I have the angle of the red line, how would I get that?
【问题讨论】:
-
That would be vector math. Treating the red as a vector from the leftmost point to the rightmost
red = {xR - xL, yR - yL};, you'd then do a 2D vector rotation. Note for 45 degrees there's a massive simplification:cos(45 deg) == sin(45 deg) == 1 / sqrt(2). If you want the center of the circle as the origin, then your vector is the outer point - the origin point. Note this does not include scaling (scalar multiplication of the vector) as done in your images. -
@Rogue But
sin(45 deg)is40.514233degrees which is not the angle of the blue line? Yes the centre of the circle is the origin. -
Mental typo, was thinking of 30 deg.
sin(45 deg)is1/sqrt(2) ~= 0.7071, which is a scalar value (no units, i.e.degrees). Definitely not40.514233.
标签: java game-development angle