Graphics Reference
In-Depth Information
Y
X
Fig. 6.1.
A vector represented by a short line segment. However, although the vector
has magnitude, it does not have direction.
Y
3
(
x
2
,
y
2
)
r
(
x
1
,
y
1
)
(
x
3
,
y
3
)
2
s
(
x
4
,
y
4
)
1
1
2
3
X
Fig. 6.2.
Two vectors
r
and
s
have the same magnitude and opposite directions.
The line's direction can be determined by first identifying the vector's tail
and then measuring its components along the
x
-and
y
-axes. For example,
in Figure 6.2 the vector
r
has its tail defined by (
x
1
,y
1
)=(1
,
2) and its
head by (
x
2
,y
2
)=(2
,
3). Vector
s
, on the other hand, has its tail defined by
(
x
3
,y
3
)=(2
,
2) and its head by (
x
4
,y
4
)=(1
,
1). The
x
-and
y
-components
for
r
are computed as follows:
x
r
=(
x
2
−
x
1
)
y
r
=(
y
2
−
y
1
)
x
r
=2
−
1=1
y
r
=3
−
2=1
whereas the components for
s
are computed as follows:
x
s
=(
x
4
−
x
3
)
y
s
=(
y
4
−
y
3
)
x
s
=1
−
2=
−
1
y
s
=1
−
2=
−
1
x
s
=
−
1
y
s
=
−
1
It is the negative values of
x
s
and
y
s
that encode the vector's direction. In
general, given that the coordinates of a vector's head and tail are (
x
h
,y
h
)and