openbase / bco.dal

Domotic Abstraction Layer
Other
1 stars 2 forks source link

getUnitTransformation erroneous behaviour #52

Closed THuppke closed 7 years ago

THuppke commented 7 years ago

Imho, Units.getUnitTransformation(UnitConfig unitConfigA, UnitConfig unitConfigB) returns the exact opposite of what it is supposed to return. The transformation returned is the one leading from B to A.

I could not track the behavior to its origin, but the effects are noticeable when for example calling ((AbstractUnitRemote)Units.getUnit(x, y)).getTransformation().get() which will then return the transformation from x to the root location and not the other way around.

DivineThreepwood commented 7 years ago

"returns the exact opposite of what it is supposed to return" Is the "supposed" based on the javadoc?

jdaberkow commented 7 years ago

I wrote a simple test by myself and can not reproduce this issue.

After assigning the position (2; 2; 2) to a random testUnit, getUnitTransformation(testUnit) gives me the following correct transformation:

1.0, 0.0, 0.0, -2.0
0.0, 1.0, 0.0, -2.0
0.0, 0.0, 1.0, -2.0
0.0, 0.0, 0.0, 1.0

Please keep in mind that this is the transformation from the root coordinate system to the coordinate system of the unit and not a vector that points from root to testUnit. So everything is working at least as intended.

Still I would acknowledge that it is maybe in fact more helpful in the most cases to get the vice-versa transformation, when only a single unit is considered with respect to the root.

THuppke commented 7 years ago

In that case, I had a misconception of what the function is supposed to return. In AbstractUnitRemote the javadoc says:

    /**
     * Method returns the transformation between the root location and this unit.
     * 
     * @return a transformation future
     * @throws InterruptedException is thrown if the thread was externally interrupted.
     */

For me, it would have been more clear if it would have said "between the root coordinate system and this unit's coordinate system. Because this way I interpreted it in the way, that if I get the 3x3 matrix of the Transformation, I have the rotation of the object and if I get the last 1x3 vector, I have the position of the object.