Game Development Reference
In-Depth Information
Figure 9.9
You can translate and invert parabolas simultaneously.
set
h
to -2, you invert the parabola, and if you set
a
to -3, you shift it to the right.
You arrive at a parabola similar to the one Figure 9.9 illustrates.
In Figure 9.9, since the value of
a
is a negative value (-3), the parabola has a
negative slope. The coordinates defining the vertex are (0, -3), so
3 is the line of
symmetry.
Arbitrary Vertex Positions
In addition to translating the vertex of the parabola along the
x
axis, you can
move it vertically, along the
y
axis. Toward this end, consider what happens if you
add a constant
k
to the basic quadratic equation you have worked with in the
previous sections. Here is the new form of the equation:
2
aðx hÞ
þ k
This form of the equation allows you to adjust the
y
-intercept of the parabola.
When you assign a value to
k
, you can translate the position of the vertex of the
parabola up or down relative to the
y
axis.
As Figure 9.10 illustrates, if you assign a positive value to
k
, then you translate the
vertex of the equation upward on the
y
axis. If the value of
a
is positive, then
the vertex of the parabola opens upward, so the coordinates (
x, y þ k
) establish