Need help to understand what and how the tools work

Have jReality programming problems or questions? Post them here.
Post Reply
cznlzq
Posts: 17
Joined: Mon 5. Mar 2012, 22:55

Need help to understand what and how the tools work

Post by cznlzq » Sun 12. May 2013, 22:12

I'm taking look at two tools: TranslateTool and DraggingTool. At first glance, I think they are the same like they are used to move the component from one place to another place. But once I look at the codes, I found that they are different and I get lost.

I think I understand how the translateTool work, clearly it applies the transformation matrix on the component
using:
MatrixBuilder.euclidean(comp.getTransformation())
.times(tc.getTransformationMatrix(trafo).toDoubleArray(null))
.assignTo(comp);

However, I cannot understand how the DraggingTool works.
It has to calculate the conjugation of the local2world: evolution.conjugateBy(local2world.getInverse())
and then it puts the evolution matrix on the right of the component transformation matrix to generate the result matrix:
comp.getTransformation().getMatrix(result.getArray());
result.multiplyOnRight(evolution);
comp.getTransformation().setMatrix(result.getArray());

I cannot understand why here it has to use the conjugate, and actually I found that the rotateTool also uses it.

Would some one please help me to understand the local2world and conjugate stuff and what's the difference for the translateTool and DraggingTool?

Thank you.

benjamin.kutschan
Posts: 48
Joined: Mon 16. May 2011, 16:29

Re: Need help to understand what and how the tools work

Post by benjamin.kutschan » Mon 20. May 2013, 20:34

Hi,
I did a simple test. I replaced the Input slots of the Translate Tool (TranslateTool.java, line 60)with the ones of the Dragging tool. So I could compare the behaviour of the two.
In the Dragging Tool moving sideways or up-and-down appears to commute, i.e. you can't make the object return to the initial position with a different rotation.
If you move in circles with the TranslateTool the object rotates slowly around its center.
Also I checked, where the TranslateTool is actually being used. Nowhere.
This leads me to the conclusion that the TranslateTool is probably a simpler, worse and probably older version of the DraggingTool.

User avatar
steffen
Posts: 186
Joined: Fri 16. Jun 2006, 13:30
Location: TU Berlin
Contact:

Re: Need help to understand what and how the tools work

Post by steffen » Mon 27. May 2013, 23:25

The "evolution" matrix gives says how the PointerTransformation (see http://www3.math.tu-berlin.de/jreality/ ... troduction), has changed since it's last position. I.e., it is a matrix which gives the new PointerTransformation when multiplied (from the right) to the previous PointerTransformation. For dragging we want to apply this delta matrix to the local transformation, but it needs to be converted to the local frame of reference first. This is done by

Code: Select all

evolution.conjugateBy(local2world.getInverse())
and the result is then multiplied from the right to the local transformation.

Hope this helps!

Post Reply