Limit Rotations of Components (RotateTool)

Have jReality programming problems or questions? Post them here.
Post Reply
luko.de.be
Posts: 3
Joined: Wed 2. Jun 2010, 13:30

Limit Rotations of Components (RotateTool)

Post by luko.de.be » Wed 2. Jun 2010, 13:49

Hey,

I am trying to adapt the JReality RotateTool in such a way, that rotations can be limited.
I am using the standard implementation, in which an Inputslot "TrackballTransformation" is registered. I can receive the transformation of this slot via the ToolContext.
Now, I`d like to limit transformations, so that for example only transformations within a quarter sphere or half sphere are possible. This would result in the user not being able to turn the picked component upside down. That`s exactly what I want.
Now, the question I am facing is, whether I need to receive the components transformation and check, whether it is valid, i.e. whithin the defined sphere.
Also that might better be accomplished by adding a TransformationListener to the component.

Maybe there is an easier way than those custom calculations/implementations. Is it possible to limit movements of my devices? There is the toolconfig.xml. Can I set delimiters already whithin the configuration? That`ll be great.

Well, sorry for possible lacks of explanation. Hope, someone can offer a suggestion.

Best regards,

luko

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

Re: Limit Rotations of Components (RotateTool)

Post by steffen » Thu 3. Jun 2010, 13:29

Hi Luko,

look into de.jreality.tools.RotateTool (under src-tool/). In the last line of the perform-method, the new Matrix is applied (i.e., the matrix is set for the transformation). My suggestion would be to move that line in a protected method (e.g., apply(Matrix result)). Then you can inherit RotateTool and overwrite that method. There you can check first if you allow the rotation or not...

Steffen.

luko.de.be
Posts: 3
Joined: Wed 2. Jun 2010, 13:30

Re: Limit Rotations of Components (RotateTool)

Post by luko.de.be » Fri 4. Jun 2010, 10:40

Hey Steffen,
that's exactly what i was doing the last days.
My work is still in progress, but thx for your reply. at the moment i am only declining rotations around specified axes by using the rotation quaternion, e.g. fix x- and z-axis.
Next step will be limiting the rotations around the axes.
Whenever i find a working solution i will post it in here.
Best regards,

Luko

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

Re: Limit Rotations of Components (RotateTool)

Post by steffen » Wed 9. Jun 2010, 16:48

To limit the rotation to a half sphere you can just look at the image of (0,0,1) under the transformation - only allow a rotation that when the z-component is non-negative.

paul peters
Posts: 17
Joined: Thu 6. Mar 2008, 15:18
Location: TU Berlin, Germany
Contact:

Re: Limit Rotations of Components (RotateTool)

Post by paul peters » Wed 9. Jun 2010, 17:18

You probably already know, but still: there is a very useful class for such manipulations:

de.jreality.math.FactoredMatrix
Paul Peters

luko.de.be
Posts: 3
Joined: Wed 2. Jun 2010, 13:30

Re: Limit Rotations of Components (RotateTool)

Post by luko.de.be » Tue 22. Jun 2010, 11:54

Hey. Thx for your numerous replies.
I fortunately also found the factored Matrix.
We limited our expectations to only limiting rotations around defined axis - for a start. I did that through the rotationquaternion which is, as you know i guess, quite handy to work with. I guess, noone is interested in that bit of code, but if so, let me know.

Future work will surely be adding the bounds to that tool. Just do not know yet, when i will implement it.

Thx again t y'all.
Cya next time.

Post Reply