Search code examples
c#coordinatesorientationemgucveuler-angles

How to determine the orientation / rotation of a triangle?


I'm using Emgu CV to find an isosceles triangle in an image, from this triangle that's been detected I'm attempting to determine the orientation (front, left, right, and back side) and what the rotation of the triangle is (ex: -30 degrees).

Triangle orientation

I'm able to detect where this triangle is and what each of the three coordinates are, I'm just not sure how to continue on finding orientation and angle of rotation. Would this be a function of Emgu CV, or just simple math; and how would I go about it?


Solution

  • Find the two sets of co-ordinates closest together (Pythagoras's theorem makes that simple).

    That's your short side.

    The point not used on that side is the front.

    Left and right are just the lines clockwise and anticlockwise from the front.

    The angle can be found using simple trigonometry between the first line you just found and a hypothetical line you are measuring the angle from.

    You will need to look up the relevant math but each of those steps is reasonably straightforwards on its own once you break it down like that.