![]() |
|
#2
|
|||
|
|||
|
Here is a sample function that takes any sensor object and calculates the speed of it:
Code:
import viz
viz.go()
sensor = viz.add('testtrack_all.dls')
def CalculateSpeed(obj):
#Get current and last position
current_pos = obj.getPosition()
last_pos = getattr(obj,'last_pos',None)
if last_pos is None:
#This is first call, so save position and set speed to 0
obj.last_pos = current_pos
obj.speed = 0.0
else:
#Compute speed using last position
obj.speed = vizmat.Distance(current_pos,last_pos) / viz.elapsed()
obj.last_pos = current_pos
print obj.speed
vizact.ontimer(0,CalculateSpeed,sensor)
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating a Vizard Sensor Plugin | farshizzo | Plug-in development | 25 | 08-01-2019 01:24 AM |
| speed on animation path | whj | Vizard | 8 | 11-17-2008 08:41 PM |
| wiimote and sensor bar | masaki | Vizard | 1 | 03-06-2008 04:07 PM |
| Multiple Copies of same sensor plugin | RedSpikeyThing | Plug-in development | 2 | 02-12-2008 03:10 PM |
| using sensor data in Physics1.py | Eunice | Vizard | 4 | 01-03-2006 06:18 AM |