# Chapter 2. Applied Geometry

Before we proceed with specific computer-graphics subjects, we will discuss some mathematics, which we will often use in this book. You can skip the first four sections of this chapter if you are very familiar with vectors and determinants. After this general part, we will deal with some useful algorithms needed for the exercises at the end of this chapter and for the topics in the remaining chapters. For example, in Chapters 6 and 7 we will deal with polygons that are faces of 3D solid objects. Since polygons in general are difficult to handle, we will divide them into triangles, as we will discuss in the last section of this chapter.

# VECTORS

We begin with the mathematical notion of a vector, which should not be confused with the standard class Vector, available in Java to store an arbitrary number of objects. Recall that we have used this Vector class in Section 1.5 to store polygon vertices.

A vector is a directed line segment, characterized by its length and its direction only. Figure 2.1 shows two representations of the same vector a = PQ = b = RS. Thus a vector is not altered by a translation. Figure 2.1. Two equal vectors

The sum c of the vectors a and b, written

c = a + b

can be obtained as the diagonal of a parallelogram, with a, b and c starting at the same point, as shown in Figure 2.2.