|
Functions
A function accepts zero or more values,
performs some set of operations on them, and returns one value
as the result. The values accepted by the function are
called the parameters, or arguments of
the function. Almost all functions have at least one parameter (pi() is
one exception).
Lingo provides many functions, such as power(),
sin(), log(), and abs(). If
you write a handler that returns a value, it operates
as a function. Also, in this tutorial any set of operations that you perform
with a variable will be called a function of that variable. For example,
"x + 2" is a function of x.
In math you would write "f(x) = x + 2".
When a function f(x) is graphed, the line or curve that
is drawn is the set of points (x, y), where y = f(x).
Types of Functions
The common types of functions in this tutorial are linear, polynomial,
trigonometric, and parametric.
A linear function can be simplified to
the form ax + b, where a and b
are constants. When a linear function is graphed, it is a straight line.
This is the most common type of function used and the most important to
understand. Finding the right linear function for a particular need is
described in Shifting & Scaling Numbers.
In a polynomial function, the variable
is raised to some power. An example is x2 + 5.
There may be many terms of x raised to different powers
in the function. The graph of a polynomial function is a curve.
The trigonometric functions used in this
tutorial are sin(), cos(), and atan(),
which are described in Sine & Cosine
Definitions. They are useful in parametric animation for creating
circular paths and oscillating motion
in general. In incremental animation they are used to find the x
and y components of a direction (angle).
Parametric functions are a special type
of function. In the above three types, the graphs consist of points (x,
f(x)). But in parametric functions, the graph consists of points
(f(p), g(p)), where f and g are other functions (non-parametric)
and p is a parameter with a defined range. p
is often associated with time. So a parametric function
consists of several parts.

This parametric function consists
of three parts: f(p), g(p),
and p:0->1. f(p) is a combination of linear and trigonometric
functions, and g(p) is a linear function.
Parametric functions are the idea behind parametric
animation. Not only location, but all properties being animated
are each a function of the parameter.
|