Currently, I’m working on a plugin and want to calculate the smallest angle between the lines that two parts make.
The black line represents the line of the part, and the green is the angle I want (smallest angle made between the parts).
Here’s a video of how my work, and what doesn’t work:
The black text above the red text is the angle calculated.
As you can see, the angles calculated when my mouse is on the left side are not correct.
In the video:
Left Side (wrong):
Right Side (correct, I want this on the left side, too):
The code for it is calculated here with angle1 being part1 (the part that moves with the mouse)'s Y orientation, and angle2 being part2 (the part that is horizontal and not moving)'s orientation.
AngleDifference = function(angle1,angle2,modulusInt)
local modulusInt = modulusInt or 360
local indicator = angle1%modulusInt - angle2%modulusInt
return indicator%90,indicator
--return angle1%modulusInt - angle2%modulusInt
end,
The black text in the video is indicator%90, while the red text is indicator.
Do any of y’all know how to calculate angles between lines/parts correctly?
I appreciate any help on how to fix this or how to calculate the angle equation.