Game Development Reference

In-Depth Information

{

p.y() = Bottom() - size.y();

}

}

1.4.1.6Ellipses

Ellipses can be very useful primitives, even if our intention is not necessarily to draw el-

lipses or circles. One common use for ellipses in user interfaces is to create constraints for

dynamic elements that move on the screen.

Ellipses are defined by two axes, the larger axis is called the major axis often referred to

with the letter
a
, and the smaller the minor axis referred to with the letter
b
, the semi-major

axis represents half the major axis and respectively the semi-minor axis represents half the

minor axis. The center of the ellipse is given by
C
.

Figure 29 - Ellipse centered at point c, defined by its axes a,b.

For our purposes, it's easier to see the ellipse using trigonometry, in its parametrical form,

such that:

Where
β
istheanglebetweenthe
x
axisandthemajoraxisoftheellipse,
C = { Xc, Yc }
and

α
is the parameter that varies from
0..2π
.

With this definition we can implement an ellipse in code.

class ellipse