Graphics Reference
In-Depth Information
B.1.5
Velocity: Speed and Direction
In computer graphics applications, we often need to work with objects that are in
motion. One convenient way to implement this functionality is by associating a
vector, V e ,
V e = x e y e z e ,
with each moving object representing the corresponding object's velocity. During
each timer update, we can update the object's position P o by
P o ←−
P o +
V e .
In this way, the object's position will be continuously updated, creating a constant
movement, and thus convey a sense of motion for the user. In this case, our object
is moving in the V e direction with a speed of
. It is important to separate the
speed from the direction of the movement because:
V e
Collision. When the in-motion object collides with another object, we must
define and compute the results of the collision. In our case, we can ap-
proximate the collision behavior by working separately with the speed and
direction of the colliding objects' velocities. For example, to avoid com-
plex physics, we can approximate a perfectly elastic collision by keeping
the speed of the colliding objects constant and only changing the directions
of the velocities to repulse the colliding objects away from each other.
Acceleration/deceleration. If we need to speed up or slow down the ob-
ject, we should change the magnitude of the velocity without altering the
direction. For example, to accelerate the object in the same direction by
five percent, we can compute the new speed as
newSpeed
=
V e ×
1
.
05
and compute the new velocity as
V e .
V e ←−
newSpeed
×
Unit of velocity.
WC unit
update interval .
For all of our tutorials,
25
1000
1
40
10 3 sec
update interval
=
25 msec
=
25
×
=
sec
=
sec
.
Search WWH ::




Custom Search