Game Development Reference

In-Depth Information

n−
1

n−
1

=
x
n
−

a
i
x
n
+

a
i
x
i

i

i

n−
1

a
i
(
x
i
−

=
x
n
+

x
n
)

i

n−
1

=
x
n
+

a
i
v
i
.

i

So an affine combination can be thought of as a point plus a linear combination

of vectors.

We represent points and vectors relative to a given coordinate frame. In three

dimensions, or

3
, this consists of three linearly independent vectors
e
1
,
e
2
,and

e
3
(known as a basis) and a point
o
(known as an origin). Any vector in this space

can be constructed using a linear combination of the basis vectors:

R

v
=
x
e
1
+
y
e
2
+
z
e
3
.

In practice, we represent a vector in the computer by using the scale factors

(
x, y, z
) in an ordered list.

Similarly, we can represent a point as an affine combination of the basis vec-

tors and the origin:

x
=
o
+
x
e
1
+
y
e
2
+
z
e
3
.

Another way to think of this is that we construct a vector and add it to the origin.

This provides a one-to-one mapping between points and vectors.

1.2.2 Magnitude and Distance

As mentioned, one of the quantities of a vector
v
is its magnitude, represented by

3
,thisis

v

.In

R

=
x
2
+
y
2
+
z
2
.

v

We can use this to calculate the distance between two points
p
1
and
p
2
by taking

p
1
−

p
2

,or

dist(
p
1
,
p
2
)=
(
x
1
− x
2
)
2
+(
y
1
− y
2
)
2
+(
z
1
− z
2
)
2
.

If we scale a vector
v
by 1
/

, we end up with a vector of magnitude 1, or a

unit vector
. This is often represented by
v
.

v