View Single Post
Old 02-10-2004, 06:24 AM
lucalatini lucalatini is offline
Join Date: Feb 2004
Posts: 5
Progressive Motion Of The Viewpoint


I'm trying to implement navigation with keypresses. I would like to make the viewpoint translate (o rotate) in a smooth and gradual way along a fixed distance (or angle). Thus, I use viz.move and viz.rotate within a cycle. But I have found some problems:

1. Sometimes the cycle does not work correctly. Here is a very simple example (running in Vizard 2.14 also if it is pure Python) to explain the problem.

#----- Example program--------
import math

a = 7.0
for x in range(10):
a = a + 0.1
print a

a = 70
for x in range(10):
a = a + 1
print a

a = 0.70
for x in range(10):
a = a + 0.01
print a
It is interesting to note that the comparison a<value is true when a==7.5 and not when a==75 or 0.75. That is, in the former case the < operator behaves as a <= operator. Maybe I'm missing something obvious, but I don't understand the reason for this difference.

2. In endless_maze demo it is possible to set the velocity of the translation by means of time.clock() used within a timer cycle. The difference between two time recordings is divided by 0.016: why this value? and is there an alternative way to set the velocity of the movement?

Reply With Quote