WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Object rotation (https://forum.worldviz.com/showthread.php?t=1116)

Andrey 06-13-2007 07:37 AM

Object rotation
 
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:
Code:

object.translate(P1)
object.lookat(P2)


Andrey 06-13-2007 01:35 PM

Thanks, but unfortunately 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 . 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.
Code:

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.


All times are GMT -7. The time now is 06:40 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC