rotate object in relation of sth. else
Probably a simple question:
How do I rotate an object (node3d) in relation to another objects local coordinate system? For instance, I want to relatively rotate object1 by 1 degree in relation to the z-axis of object2s local coordinate system (roll of 1 degree according to object2). In another example I want to relatively rotate object1 by 1 degree in relation to the main view (roll of 1 degree according to main view). |
You can use the matrix.preEuler methods to rotate objects relative to arbitrary coordinate frames. Here is how you would roll object1 relative to object2's coordinate frame:
Code:
m = object2.getMatrix() Let me know if I misunderstood your question or you need more specific examples. |
3 Attachment(s)
This is not exactly what I meant.
For illustrating I attached some screen shots: Left picture: Start position. object1 = blue torus, object2 = white torus) Middle picture: Your end position. Your code seems to copy the complete orientation of object2 to object1 Right picture: Desired end position. I want to rotate object1 according to the orientation of object2. Kinda object1.setEuler([0,0,45],viz.REL_LOCAL_of_object2) |
Ok, it sounds like you want a hierarchical relationship between object1 and object2. In this case you would simply add object1 as a child to object2. When object2 is rotated, object1 will automatically rotate in object2's reference frame. If for some reason you don't want a to use a hierarchical relationship, then here is some code to manually compute the matrix:
Code:
euler = viz.Matrix.euler(0,0,roll) |
Me gusta el code. Porque yo tengo code similar, pero esto code es mas fácil.
También, Penguin usted puede utilizar un objeto Link para esto, si no te gusta hierarchical. |
Vous êtes fou mec. J'ai comme vous, mais vous êtes fou.
|
Thank you, the code works best for me! I only did some minor changes: translating to origin before rotating:
Code:
euler = viz.Matrix.euler(0,0,roll) |
All times are GMT -7. The time now is 09:48 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC