View Full Version : Object rotation
Andrey
06-13-2007, 07:37 AM
Hello,
There are two points P1 and P2. Is there any simple way using Vizard commands to superpose the object (cylinder) with the vector which starts at P1 and ends at P2? In other words: how to rotate the object to make it directed from P1 to P2?
Thanks.
farshizzo
06-13-2007, 12:40 PM
I believe the following code should accomplish this:object.translate(P1)
object.lookat(P2)
Andrey
06-13-2007, 01:35 PM
Thanks, but unfortunately <lookat> does not help. May be I did not explain the problem well: the object is vertical cylinder like a stick. It is necessary to coincide ends of this stick with points P1 and P2. No problem to coincide the first end with P1 using <translate>. How to coincide the second end with P2 without long iteration procedure?
farshizzo
06-13-2007, 02:14 PM
The code I posted should work if the cylinder is oriented along its local z-axis. If the cylinder is oriented upward along its local y-axis, then you would need to perform another pre-rotation after the lookat.object.translate(P1)
object.lookat(P2)
object.rotate(0,90,0,'',viz.RELATIVE_LOCAL)
Andrey
06-13-2007, 02:49 PM
Thank you very much, it works now.
vBulletin® v3.8.7, Copyright ©2000-2025, vBulletin Solutions, Inc.