Game Development Reference
In-Depth Information
We can also use a version that is solved in terms of
x
instead:
In this case,
c
is the
x
-intercept rather than the
y
-intercept.
There are a number of other variations on how to express a line. However,
many of them are slightly more difficult to work with from a programming stand-
point in that they have more than one term on the left side of the equal sign. For
example, rather than a slope, we could substitute in values that result in the slope
of the line:
Note that in the above equation
x
2
cannot be equal to
x
1
lest we encounter a
“division by zero� error and cause a catastrophic and untimely end to our faux
universe.
There is really only one simple rule to remember about the linear function. If
m
< 0, the line is descending. If
m
> 0, the line is ascending. (For that matter,
if
m
= 0, the line is horizontal.) Because the slope is, for all intents and purposes, the
only defining characteristic of the linear function,
m
is the only value that changes
the
effect
of the function. Changing the value of
b
merely moves the line around in
space. We can see examples of these changes in Figure 10.1.
FIGURE 10.1
The graph of three linear functions with different values for
m
and
b
.
Note that a negative value of
m
creates a descending line.