View Full Version : Accelerated motion
Lenticularis
05-30-2018, 02:45 PM
Is there a simple solution to implement accelerated motion in Vizard?
Or do I have to use the normal vizact.move function and combine it with the formula "v = a · t + v"?
Any ideas?
Are you moving the viewpoint or some objects? Can you describe a bit the application you are creating?
Lenticulariss
05-31-2018, 06:13 AM
Objects. I want to move an object (let's say a car) forward for a certain duration and with a certain average velocity. But with accelerated movement, not with constant velocity.
Example: vizact.move(0,0,6, velocity)
--> In this function I can define the direction of movement and the duration of the movement, I can also specify a certain velocity. But now I want to accelerate this movement by let's say 1 m/s^2 (so that the velocity is rising for the specified amount of time)
Lenticularis
06-01-2018, 04:38 AM
Moving an object.
Vizact.move(0,0,velocity,time) --> I can indicate a velocity and a duration of the movement. How to implement accelerated movement?
You could apply a force (http://docs.worldviz.com/vizard/#Forces.htm) using physics or register a function with vizact.onupdate (http://docs.worldviz.com/vizard/#commands/vizact/onupdate.htm) where the object's position is set each frame.
Lenticularis
06-07-2018, 10:57 AM
I tried the following code. Do you see mistakes?
def Movement():
Object.setPosition(0,0,0)
v0 = 0
t = 0
a = 1
while t < time:
s = v0*t + 0.5*a*t**2
vizact.ontimer2(0.1,0,Object.setPosition,0,0,s)
t = t+0.1
I was not really expecting it to work since it was only a "quick and dirty" solution. But I actually don't see where the problem is.
Lenticularis
06-08-2018, 06:00 AM
Never mind. Managed to do it with an even simpler solution. It is not entirely precise, but it works quite well. It isn't even shaking. Here is the code I used:
def Movement():
Object.setPosition(0,0,0)
v0 = 0
t = 0
a = 5
while t < time:
s = v0*t + 0.5*a*t**2
Object.setPosition(0,0,s)
t = t+0.0168 #Adjustement based on processing speed of computer (lazy amateur workaround)
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.