I'm sorry if this turns out to be a trivial answer I have not been able to figure out how to find the orientation of an irregular polygon (given as an array). By orientation I mean the angle between 0 and the long axis of the object.
Searching around I found a function in MatLab called regionprops() that is almost exactly what I need.
https://www.mathworks.com/help/images/ref/regionprops.html
Is there a JavaScript equivalent that I just cannot find, or would it be advisable to learn how to include MatLab in my project?