Game Development Reference
In-Depth Information
1.4G EOMETRY
In this section we will review some geometry concepts that are often used when developing
user interfaces. We will develop a library of classes that give us access to different geomet-
rical shapes in an easy to use way.
1.4.1 Shapes
During development of user interfaces we will rely on different shapes to create visual ef-
fects, but also as tools that help us constrain elements within areas and perform intersection
testing to see if elements overlap.
We primarily will focus on the geometrical representation of shapes and the mathematical
formulas to model them and implement some of the most commonly used operations in the
context of user interface development.
1.4.1.1 Points
A point is the most atomic geometrical shape we have, it represents a position in space, for
our cases we are only concerned with 2D and 3D space, so points will be represented by
X,Y coordinates for 2 dimensional space (R 2 )
X,Y,Z for 3 dimensional space (R 3 ).
Itisoftenthecasethatdeveloperstakeadvantageofthefactthattherepresentationofpoints
and vectors are the same. For simplicity when a point is required, the vector class is used.
While there may be some valid reasons to use the vector class to represent points (such as
an optimized vector class that takes advantage of hardware accelerated floating point opera-
tions), it is preferable to provide a distinction between the two. The key advantage of mak-
ing distinct types for points and vectors is that the code becomes self-documenting, as we
Search WWH ::




Custom Search