WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 06-13-2007, 08:37 AM
Andrey Andrey is offline
Member
 
Join Date: Apr 2007
Posts: 21
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.
Reply With Quote
  #2  
Old 06-13-2007, 01:40 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I believe the following code should accomplish this:
Code:
object.translate(P1)
object.lookat(P2)
Reply With Quote
  #3  
Old 06-13-2007, 02:35 PM
Andrey Andrey is offline
Member
 
Join Date: Apr 2007
Posts: 21
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?
Reply With Quote
  #4  
Old 06-13-2007, 03:14 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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)
Reply With Quote
  #5  
Old 06-13-2007, 03:49 PM
Andrey Andrey is offline
Member
 
Join Date: Apr 2007
Posts: 21
Thank you very much, it works now.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:16 AM.


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