Calculating the 2D orientation of a right triangle from edges's positions.

Hello,

I am using a Wiimote IR camera to track 3 IR leds set as 3 edges of a right/rectangled triangle. I want to track the azimuth of the triangle, which is moving and rotating in space but always faces the camera.

I'd like to be sure my method to calculate the azimuth from the edges's cartesian coordinates provided by the camera is correct:
First, I calculate the distances between the three points. The point which has the smallest distances between the two others is the "reference" point (the point facing the hypothenuse).
Second, I substract the position of this point from the two others to translate them to a virtual center to prepare the following conversion.
Third, I convert the coordinates of these two points from cartesian to polar.
Fourth, I calculate the average of those points's phases (angle) and get what I want.

Is it correct ? Also, if anyone knows an alternative avoiding the cartesian to polar conversion it might help too.

Thank you in advance.

I am using a Wiimote IR camera to track 3 IR leds set as 3 edges of a rectangular triangle.

Is that anything like a round square?

PaulS:

I am using a Wiimote IR camera to track 3 IR leds set as 3 edges of a rectangular triangle.

Is that anything like a round square?

Sorry it seems I made a bad translation from french language. I meant "right triangle". I have corrected my first message too.

I'm thinking that a picture (or series of pictures) is going to be necessary to understand what you are trying to do.

All right, here we go.

First picture displays the position of IR LEDs on hand constituting a right triangle.

Second picture displays the possible images provided by the sensor over angular range (the hand won't mode over ±90°).

Third picture displays the operations to get the orientation from the edges's positions.

main+3_leds_small.png

How do you keep the three LEDs in plane? If you don't, how to you determine the relationship of the plane that contains the 3 LEDs to some 3D coordinate system?

In light of the pictures, this:

First, I calculate the distances between the three points. The point which has the smallest distances between the two others is the "reference" point (the point facing the hypothenuse).

makes sense.

Second, I substract the position of this point from the two others to translate them to a virtual center to prepare the following conversion.

This is what the green arrow in the last picture illustrates, right?

Third, I convert the coordinates of these two points from cartesian to polar.

Which gives distance and angle to the non-corner point.

Fourth, I calculate the average of those points's phases (angle) and get what I want.

This is where I lose you, because I do not know what it is you want.

PaulS:

Second, I substract the position of this point from the two others to translate them to a virtual center to prepare the following conversion.

This is what the green arrow in the last picture illustrates, right?

Indeed.

Fourth, I calculate the average of those points's phases (angle) and get what I want.

This is where I lose you, because I do not know what it is you want.

What I want is the orientation of the red arrow. I think I get it (orange angle) by calculating the difference between grey angles (rather than averaging as written before). Is it correct ?

I think I get it (orange angle) by calculating the difference between grey angles

No. The difference between the grey angles should be 90 degrees, since the LEDs form a right triangle. The smaller angle plus 45 degrees should give the angle to the red vector. Adding the two gray angles and dividing by 2 (averaging) should give the same value.

Thanks PaulS !

Every augmented reality solution faces the same problem, and the solutions are fairly well known. Depending what runtime environment you're working in, it can be as simple as calling a marker tracking algorithm to generate a coordinate transform defining the relationship between your viewport's coordinate system and the object you're tracking.