|
#1
|
|||
|
|||
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. |
#2
|
|||
|
|||
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) |
#3
|
|||
|
|||
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? |
#4
|
|||
|
|||
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 |
#5
|
|||
|
|||
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. |
#6
|
|||
|
|||
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?
|
#7
|
|||
|
|||
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 Code:
1.0 2.1 3.89 4.43509876 |
Thread Tools | |
Display Modes | Rate This Thread |
|
|