1 Tutorials LightWave 3D Rocket Science 101: A Simple Kinematics Expressions Library Qua Jan 26, 2011 3:11 am
Admin
Admin
A few basic equations can describe many of the
motions of objects in the real world. Most
of these equations are just 1D, which means
they represent motion along a line, or a single
animation channel. More complex 3D motions
arise when these equations are applied to the
X, Y and Z animation channels independently. For
example, an object falling under the influence
of gravity experiences a constant acceleration
in the down (-Y) direction. If it is
initially moving up, it slows to a stop and
reverses. Any motion in the X or Z directions
however is not changed by the acceleration
of gravity. This means a basic falling
motion can be made from a constant acceleration
on the Y channel, and constant speed on the
X and Z channels.
In the world of math the moment
when Time is 0 is very special. All these equations
respect that. If you want things to start at
some other time, like 3.7, add that time wherever
you see the expression variable "Time". If
the motion is to proceed from time zero, it is
necessary to know the initial conditions of the
item: its position, speed, as well as any acceleration. These
values will be available to the Expressions,
either as "Value", the initial
position, "InitialSpeed", or "InitialAcceleration".
The "Value" variable is already
defined, since it is the existing keyframed position.
Given the initial conditions,
the position at any time can be calculated from
the speed, which itself is calculated from the
acceleration. We are now assuming that
the acceleration is constant. This condition
happens to match the effect of gravity almost
exactly. In fact, for many simple motions, even
a constant speed (with no acceleration) is useful.
To move an item, apply the Position expression
to it. To accelerate an item from 0 to
60 in 6 seconds with a constant acceleration,
equate 60 (m/s) with the initial acceleration
times the 6 secs over which it is applied. This
leads to 60m/s = 6s * InitialAcceleration, so
the InitialAcceleration is 10 m/s2. For
60 miles per hour, some conversion is required. Similarly,
braking from a constant speed of 60m/s in one
second requires a negative acceleration (deceleration)
of -60 m/s2.
<blockquote>
Expression Name:
InitialSpeed
Definition:
0
Expression Name:
InitialAcceleration
Definition:
0
Expression Name:
Position
Definition:
Value + [InitialSpeed]*Time + 0.5*[InitialAcceleration]*Time*Time
</blockquote>
Since the acceleration due to
gravity is so commonly useful, it deserves its
own special expression variable, here defined
in Earth standard meters per second per second
(m/s2). For convenience an expression
to describe moving under the influence of gravity
will be defined also. Falling can be applied
to the Y channel of an item to make it drop with
natural acceleration.
<blockquote>
Expression Name:
Gravity
Definition:
-9.8
Expression Name:
Falling
Definition:
Value + 0.5 * [Gravity] * Time
* Time
</blockquote>
Example 1: What goes up must come down
If an object is thrown up with
some initial speed, it will gradually come to
a stop and fall back down, accelerating all the
way. In the expressions interface, set
the InitialSpeed definition to 1.0, and
make a new expression for the Y channel, and
apply it:
<blockquote>
Expression Name:
YPosition
Definition:
Value + (0.5*[Gravity]*Time*Time) + ([InitialSpeed]*Time)
</blockquote>
The YPosition expression
combines a constant motion up with initial speed,
with an increasing down motion coming from Falling.
This is the standard kinematics equation X =
V0 T + 1/2 a T2 ,
by the way.
Example 2:Launching
For a 2D example, we will launch
something in the X direction, and Up, by giving
some item an initial speed on both the X and
Y channels, and letting gravity do its thing
on the Y channel. Apply Position to the
X channel, and leave YPosition on Y. Items
animated in this way are always launched at 45
degrees, because the X and Y motions use the
same initial speed. For extra credit, change
the launch to some other angle (called Angle)
by replacing the initial speed in the X and Y
motions by cos(Angle)*InitialSpeed and
sin(Angle)*InitialSpeed, respectively.
The sin() and cos() functions divide a line at
a certain angle into Y and X components, respectively.
<blockquote>
Expression Name:
Angle
Definition:
45
Expression Name:
YPosition
Definition:
Value + (0.5*[Gravity]*Time*Time) + (sin([Angle])*[InitialSpeed]*Time)
Expression Name:
XPosition
Definition:
Value + cos([Angle])*[InitialSpeed]*Time + 0.5*[InitialAcceleration]*Time*Time
</blockquote>]
motions of objects in the real world. Most
of these equations are just 1D, which means
they represent motion along a line, or a single
animation channel. More complex 3D motions
arise when these equations are applied to the
X, Y and Z animation channels independently. For
example, an object falling under the influence
of gravity experiences a constant acceleration
in the down (-Y) direction. If it is
initially moving up, it slows to a stop and
reverses. Any motion in the X or Z directions
however is not changed by the acceleration
of gravity. This means a basic falling
motion can be made from a constant acceleration
on the Y channel, and constant speed on the
X and Z channels.
In the world of math the moment
when Time is 0 is very special. All these equations
respect that. If you want things to start at
some other time, like 3.7, add that time wherever
you see the expression variable "Time". If
the motion is to proceed from time zero, it is
necessary to know the initial conditions of the
item: its position, speed, as well as any acceleration. These
values will be available to the Expressions,
either as "Value", the initial
position, "InitialSpeed", or "InitialAcceleration".
The "Value" variable is already
defined, since it is the existing keyframed position.
Given the initial conditions,
the position at any time can be calculated from
the speed, which itself is calculated from the
acceleration. We are now assuming that
the acceleration is constant. This condition
happens to match the effect of gravity almost
exactly. In fact, for many simple motions, even
a constant speed (with no acceleration) is useful.
To move an item, apply the Position expression
to it. To accelerate an item from 0 to
60 in 6 seconds with a constant acceleration,
equate 60 (m/s) with the initial acceleration
times the 6 secs over which it is applied. This
leads to 60m/s = 6s * InitialAcceleration, so
the InitialAcceleration is 10 m/s2. For
60 miles per hour, some conversion is required. Similarly,
braking from a constant speed of 60m/s in one
second requires a negative acceleration (deceleration)
of -60 m/s2.
<blockquote>
Expression Name:
InitialSpeed
Definition:
0
Expression Name:
InitialAcceleration
Definition:
0
Expression Name:
Position
Definition:
Value + [InitialSpeed]*Time + 0.5*[InitialAcceleration]*Time*Time
</blockquote>
Since the acceleration due to
gravity is so commonly useful, it deserves its
own special expression variable, here defined
in Earth standard meters per second per second
(m/s2). For convenience an expression
to describe moving under the influence of gravity
will be defined also. Falling can be applied
to the Y channel of an item to make it drop with
natural acceleration.
<blockquote>
Expression Name:
Gravity
Definition:
-9.8
Expression Name:
Falling
Definition:
Value + 0.5 * [Gravity] * Time
* Time
</blockquote>
Example 1: What goes up must come down
If an object is thrown up with
some initial speed, it will gradually come to
a stop and fall back down, accelerating all the
way. In the expressions interface, set
the InitialSpeed definition to 1.0, and
make a new expression for the Y channel, and
apply it:
<blockquote>
Expression Name:
YPosition
Definition:
Value + (0.5*[Gravity]*Time*Time) + ([InitialSpeed]*Time)
</blockquote>
The YPosition expression
combines a constant motion up with initial speed,
with an increasing down motion coming from Falling.
This is the standard kinematics equation X =
V0 T + 1/2 a T2 ,
by the way.
Example 2:Launching
For a 2D example, we will launch
something in the X direction, and Up, by giving
some item an initial speed on both the X and
Y channels, and letting gravity do its thing
on the Y channel. Apply Position to the
X channel, and leave YPosition on Y. Items
animated in this way are always launched at 45
degrees, because the X and Y motions use the
same initial speed. For extra credit, change
the launch to some other angle (called Angle)
by replacing the initial speed in the X and Y
motions by cos(Angle)*InitialSpeed and
sin(Angle)*InitialSpeed, respectively.
The sin() and cos() functions divide a line at
a certain angle into Y and X components, respectively.
<blockquote>
Expression Name:
Angle
Definition:
45
Expression Name:
YPosition
Definition:
Value + (0.5*[Gravity]*Time*Time) + (sin([Angle])*[InitialSpeed]*Time)
Expression Name:
XPosition
Definition:
Value + cos([Angle])*[InitialSpeed]*Time + 0.5*[InitialAcceleration]*Time*Time
</blockquote>]