Graphics Reference
In-Depth Information
10.2.2.3 Problem.
To find the intersection
q
, if any, of the ray
X
and the cone
Y
with radius r and height h centered at the origin with axis the z-axis.
Solution.
The cone
Y
is defined by
{
}
2
2
Y
=
(
)
2
+=
(
2
)
(
)
x y z
,,
x
y
r h
h
-
z
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
2
(
)
(
)
=
(
)
(
)
,
p
+
tv
++
p
tv
r h
h
--
p
tv
1
1
2
2
3
3
which reduces to
2
At
++=,
2
Bt
C
0
(10.2)
where
2
=+-
(
2
2
)
2
,
Av v
rhv
1
2
3
2
+
(
)
(
)
B
=
p v
+
p v
r h
h
-
p
33
,
v
and
11
2 2
2
2
.
2
2
=+-
(
)
(
)
Cp p
rhhp
-
3
Case
A = 0:
In this case the direction vector of the ray lies in the cone, that is, it is
parallel to a generating line for the cone.
B = 0:
The ray intersects the cone if and only if
p
lies on
Y
and satisfies its
equation.
B π 0:
In this case use equation (10.2) to solve for t and check whether
0 £ p
3
+ t v
3
£ h.
Case
A π 0:
In this case one has to analyze the solutions to the quadratic equation
(10.2) similar to what 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 actu-
ally intersect the cone.
If the ray did not intersect the sides of the cone and the cone has a bottom, then one
must still check if the ray intersects the bottom. This is done in the same way that
one checks whether a ray intersects the bottom of a cylinder.
A generalization of Problems 10.2.2.2 and 10.2.2.3 is finding the intersection of a
ray with an arbitrarily positioned cylinder or cone. The best way to deal with this
problem is to transform the problem to a normalized coordinate system to which the
above solutions apply.
10.2.2.4
Problem.
To find the intersection, if any, of the ray
X
and a polygon.
Solution.
One first checks whether the ray is parallel to the plane containing the
polygon. If it is, then there will be no intersection if
p
does not belong to the plane.
If
p
does belong to the plane, then the problem reduces to finding the intersection of
a ray in
R
2
with a polygon in
R
2
. We now have a two-dimensional clipping problem
of the type considered in Chapter 3. If the polygon is convex, then one can use a Cyrus-
Beck approach.