Graphics Reference
In-Depth Information
how efficient ray intersection tests are it is better not to have to perform them at all.
One should do whatever is possible to avoid the tests altogether. To that end we
mention one useful step ([Ritt90]). If an object has a bounding box, then find a good
bounding rectangle in the screen of the projection of the corners of this box and check
if the pixel that defines the current ray lies in this rectangle. These computations
will typically be simpler than any ray intersection test for the three-dimensional
object.
We shall use the following notation throughout this section: X will denote a ray
from a point p in a direction v and L will denote the line through p with direction
vector v .
10.2.2.1 Problem. To find the intersection q , if any, of the ray X and the (n - 1)-
dimensional sphere S with center a and radius r.
Solution. This problem is solved in the same as that for the ray-circle intersection
problem already handled in Section 6.5.
The next problems assume that we are dealing with rays in R 3 .
10.2.2.2 Problem. To find the intersection q , if any, of the ray X and the cylinder
Y with radius r and height h centered at the origin with axis the z-axis.
Solution.
First of all, note that the cylinder Y is defined by
{
}
Y = (
)
2
2
2
x y z
,,
x
+=
y
r
and
0
££
z
h
.
Let p = (p 1 ,p 2 ,p 3 ), v = (v 1 ,v 2 ,v 3 ), and q = p + t v . Then we must have
2
2
(
)
(
)
2
ptv
+
++
p tv
=
r
,
1
1
2
2
which reduces to
2
At
++=,
2
Bt
C
0
(10.1)
where
2
2
2
22
A
=+
v
v
,
B
=
p v
+
p v
,
and
C
=+-
p
p
r
.
11
2 2
1
2
1
2
Case A = 0: In this case the ray is parallel to the axis of the cylinder. One must check
for the special case where the ray lies in the cylinder, that is, p 2 + p 2 = r 2 .
Case A π 0: In this case one has to analyze the solutions to the quadratic equation
(10.1) as we did in the case of spheres. If a solution is found, then one
must check that 0 £ p 3 + t v 3 £ h. Only then will the ray actually inter-
sect the cylinder.
If the cylinder has a top and/or bottom and the ray did not intersect the sides of
the cylinder, then we need to find the intersection of the ray with the planes z = 0 and
z = h. Given such an intersection q = (q 1 ,q 2 ,q 3 ), the ray intersects the bottom or top
if q 2
+ q 2
£ r 2 .
Search WWH ::




Custom Search