#1
|
|||
|
|||
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. |
#2
|
|||
|
|||
I believe the following code should accomplish this:
Code:
object.translate(P1) object.lookat(P2) |
#3
|
|||
|
|||
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?
|
#4
|
|||
|
|||
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) |
#5
|
|||
|
|||
Thank you very much, it works now.
|
|
|