WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 10-18-2007, 08:37 AM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
Movement Question

So I'm trying to move an object (a picture) forward and backward a certain distance for a certain period of time. What I can't get it to do in this case is to move some fixed amount (e.g. 2 m) for X amount of seconds. In this example in the following code, I need to it to be able to go 2 m forward for .01 s then 2 m backward for .01 and do that sequence for 1 min (which is why I have "60/freq." Because I thought that would give me how many time .01 s went into 60 s. After a minute I want it to change to move 2 m forward for 2 seconds and 2 m backward for 2 seconds and to do that "60/freq" times (i.e. 30 times). ETC ETC ETC. Then I have the whole sequence looping 5 times (so it'll go through (.01, 2, .03, .0, .05, .06) a total of 5 times).

def WriteFlag():
print "Movement Transition Made"

movefreq = [.01, 2, .03, .04, .05, .06]
sequences = []
for freq in movefreq:
MoveRoom = vizact.sequence(vizact.move(0,0,2,freq), vizact.move(0,0,-2,freq), 60/freq)
sequences.append(MoveRoom)
sequences.append( vizact.call( WriteFlag ) )
MovingRoom = vizact.sequence(sequences, 5)



Here's my problem. I can't get it to move X distance for Y seconds. If I switch it so the code looks like "vizact.move(0,0,freq,2). Then it'll move the specified distance in 2 seconds. But I can't get it to do the other thing that I want (above). I was thinking that maybe I'm specifying it to move for too short of an amount of time????? Or maybe I need it to move too far too quickly? I mean, asking something to move 2m in .01 seconds is kind of quick. Is there some threshold that I need to be above?

Also I was wondering how I could make them both vairable (i.e. how far the picture moves and for how long). I was thinking about creating two lists in that case "dist and freq" and then having something like vizact.move(0,0, dist, freq). Would that work or am I missing something?

Last edited by Elittdogg; 10-18-2007 at 08:46 AM.
Reply With Quote
  #2  
Old 10-18-2007, 09:54 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
With the vizact.move() command you specify the velocity to move with, and the amount of time to move at that velocity. So your code should look something like this:
Code:
MoveRoom = vizact.sequence(vizact.move(0,0,2.0/freq,freq), vizact.move(0,0,-2.0/freq,freq), 60/freq)
Reply With Quote
  #3  
Old 11-26-2007, 12:45 PM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
The problem with this is that it makes the transitions very very very quickly if I put decimals in the list "movetime."

movetime = [.05, .25, .75, 1, 2]
sequences = []
for time in movetime:
MoveRoom = vizact.sequence(vizact.move(0,0,(0.12/time),time), vizact.move(0,0,(-0.12/time),time), (30/time))
sequences.append(MoveRoom)
sequences.append( vizact.call( WriteFlag ) )
MovingRoom = vizact.sequence(sequences, 1)

If I make the code:
MoveRoom = vizact.sequence(vizact.move(0,0,(0.5/time),time), vizact.move(0,0,(-0.5/time),time), (30/time))

and I make movetime [1, 2, 3, 4, etc] then it'll move .5 m/s for 1 second and then .25 m/s for 2 seconds...etc....all of the movements will result in moving .5 meters for a total of 1 minute. But when I have the above (if I want it to move .12 meters in .05 seconds or .25 seconds, etc.) it moves really fast for a second and then moves on to the next number in the list. It doesn't perform what I want it to and it doesn't do it for 1 minute either. Is there some problem with decimals? Am I making a wrong conversion? I tried changing the end (instead of 30/time to 600/time but that didn't change anything--if anything it made it transition faster. Am I missing something?
Reply With Quote
  #4  
Old 11-26-2007, 12:52 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Then don't put decimals in your movetime list. Keep in mind that dividing two integers in Python will yield another integer that is the floor of the division. Example:
Code:
print 1 / 2 #prints 0
print 1 / 2.0 #prints 0.5
So you will need to either use floating point values in your movetime list or use floating point values for your distance.
Reply With Quote
  #5  
Old 11-26-2007, 12:58 PM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
what's a floating point value?

Like if I want it to move .12 meters in .5 seconds how would I code that?

I'm not familiar with floating point values.

Even if I make it 1/20.0 instead of .05 it doesn't work. It still moves really fast and transitions WAY before a minute has passed.

Last edited by Elittdogg; 11-26-2007 at 01:01 PM.
Reply With Quote
  #6  
Old 11-26-2007, 01:04 PM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
Also, even if I make it 1/2.0 it goes really fast and doesn't last one minute. Maybe I'm just confusing myself?
Reply With Quote
  #7  
Old 11-26-2007, 01:06 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
In most programming languages, non-fractional numbers are referred to as integers and fractional numbers are referred to as floats or floating point values. For example the following are integers:
Code:
1
2
3
4
and the following are floats
Code:
1.0
2.1
3.89
4.43509876
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 03:36 PM.


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