totesnotrosalyn
09/25/2024 at 06:39:36 AM PDT
I can’t seem to figure out the math to generate a heading from a start and end point. Any help?
I can’t seem to figure out the math to generate a heading from a start and end point. Any help?
You can use the atan2 function to get the angle from one point to another
the atan2 function calculates the arc tangent and adds some angle values depending on the sign of the change in x and change in y. tan(angle) = y/x so atan(y/x) = angle.
Here’s a desmos interactive I made that you can use. The main arctangent function is on the left-hand sidemenu. Rendering functions were put in the “other stuff for rendering” folder. You can drag the blue and red points.