Graphics Reference
In-Depth Information
Given the following conditions:
v
=
i
−
j
R
=
21 and
r
=
2
i
+
j
we find that
v
in
=−
i
Therefore,
n
=
i
+
j
Using Eq. (5.6) gives
2
i
i
2
n
n
·
v
in
+
j
·
−
i
v
out
=
v
in
−
=
−
i
−
+
j
√
2
2
2
n
2
−
i
1
2
v
out
=
−
i
−
+
j
v
out
=
j
Using Eq. (5.10) gives
n
v
in
=
i
·
t
−
r
+
j
·
2
j
−
2
i
−
j
p
=
r
+
2
i
+
j
+
−
i
n
·
v
in
i
+
j
·
−
i
i
+
j
·
−
2
i
+
j
p
=
2
i
+
j
+
−
i
=
2
i
+
j
−
i
−
1
p
=
i
+
j
Therefore, P has coordinates 11, which confirms our prediction.
5.3 A line reflecting off a plane
You have probably already guessed that the above vector equations will work just as well in 3D
as they do in 2D. Therefore, they will describe how a ray will bounce off a surface. To compute
the direction of the reflected vector, all we need is the plane's surface normal and the incoming
vector, which means that the equation describing
v
out
still holds:
v
out
=
v
in
−
2
n
ˆ
·
v
in
n
ˆ
and the position vector for P is
n
v
in
·
t
−
r
p
=
r
+
n
·
v
in