WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #14  
Old 09-12-2006, 08:34 PM
pbeeson pbeeson is offline
Member
 
Join Date: Aug 2006
Posts: 31
Here is code that works with the Test.wrl I posted earlier. The view is at an angle to the hallway, so a line straight ahead should intersect the wall which is 4.3 meters away. But, this particular line misses the intersection with the closest wall and intersects another wall in the environment (> 10 meters away).

This shows the different results sometimes returned by viz.phys.intersectLine() and viz.intersect().

Code:
import viz, math

viz.go()

env = viz.add('Test.wrl')
env.collidemesh()
env.disable(viz.DYNAMICS)

start_pos=[10.5, 1.3, -21.43391, 23.975]

view=viz.get(viz.MAIN_VIEWPOINT)
view.translate(start_pos[0], start_pos[1], start_pos[2])
view.rotate(0,1,0,start_pos[3], viz.BODY_ORI,viz.ABSOLUTE)

def dist(x1,y1,x2,y2):
    return math.sqrt(pow(x1-x2,2)+pow(y1-y2,2))

def timerCallback(num): 
    end_pos=[start_pos[0]+100*math.sin(start_pos[3]*math.pi/180),
             start_pos[1],
             start_pos[2]+100*math.cos(start_pos[3]*math.pi/180)]
    inters_obj = viz.phys.intersectLine(start_pos[0:3], end_pos)
    print inters_obj.intersectPoint
    print dist(inters_obj.intersectPoint[0],inters_obj.intersectPoint[2],
               start_pos[0],start_pos[2])
    inters_obj = viz.intersect(start_pos[0:3], end_pos)
    print ''
    print inters_obj.intersectPoint
    print dist(inters_obj.intersectPoint[0],inters_obj.intersectPoint[2],
               start_pos[0],start_pos[2])
    print '\n\n'

    

viz.callback(viz.TIMER_EVENT, timerCallback)
viz.starttimer(1, 1, -1)

Last edited by pbeeson; 09-13-2006 at 07:26 AM.
Reply With Quote
 


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 12:22 PM.


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