Hi! I’m sure this is a simple math equation but I’m having trouble figuring it out.
Im trying to figure out a formula to identify the angle marked red, in relation to the horizontal line y. The two points A and B is known.
local y = y2 - y1
local x = x2 - x1
local theta = math.atan2(y, x)
(Assuming X is the horizonal axis.)
4 Likes
Let me just delete the draft I was doing because I was making this way more complicated then it needed to be lmao. So tired I forgot about atan2 and the other math functions.
1 Like
@skilpus3000
For explanation math.atan2
is essentially the math.atan
function (arctangent; inverse tangent; etc) except for that it handles for the introduction of the negative quadrants.
If your unfamiliar with what the tangent
function is, it is essentially a trigometric function.
Tangent of theta is the opposite side length over the adjacent side length, therefore the inverse tangent of the opposite side length over the adjacent side length is theta (the angle)!
2 Likes