Perhaps I would organize the solution in this way.
Let (x0,y0,z0) be the current position of the ball/point.
Let (x',y',z') be the its constant velocity, with time t measured in
consistent units.
Then the parametric form of the point's trajectory is:
(x0 + t*x', y0 + t*y', z0 + t*z')
It remains only to provide an equation for the surface to be
intersected. This is quite easy for the sphere, whose equation, given
radius r and center:
(xc, yc, zc)
is of course:
(x - xc)^2 + (y - yc)^2 + (z - zc)^2 = r^2
Upon substituting the parametric expressions:
x = x0 + t*x'
y = y0 + t*y'
z = z0 + t*z'
you will obtain a quadratic equation for t, which may have one, two,
or no real roots. As discussed before, you are interested in the
smaller of any positive real roots (except that you may wish to check
for one positive and one negative root and interpret that a the point
emerging from inside the sphere). A root at time t = 0 would indicate
the point is one the sphere's surface "now", and this too may have
some special significance for your application.
Treatment of the frustum of the cone would be similar. However the
frustrum of a cone is necessarily less symmetrical than the sphere,
which manifests itself in awkward expressions for the general equation
for the cones surface.
I would apply a rigid transformation (rotation and translation of
coordinates, which would need to be applied equally to the
ball/point's trajectory) so that the axis of the cone becomes simply
the z-axis (say). Then your data for the cone would consist of two
points for the top and bottom circles positioned some equal distance
apart on the z-axis as they were originally, together with their
respective radii (for the top and bottom circles). That is:
(0,0,zA) with radius rA
(0,0,zB) with radius rB
Now the surface of the full (dual) cone consists of the rotation of a
line, e.g. the one in the xz-plane given by:
x = m (z - zB) + rB
where m = (rA - rB)/(zA - zB), all the way around the z-axis.
The equation of the full (dual cone) is then:
x^2 + y^2 = ( m(z - zB) + rB )^2
One substitutes the parametric expressions for x,y,z in terms of t as
before, and solves the resulting quadratic equation for any (positive)
real roots t. However there is an additional check to perform, given
such real roots t, to verify that the points of contact lie in the
frustum region and not beyond. This check is easily performed,
however, by evaluating the z-coordinate from t and seeing if this
z-value is between zA and zB.
Again there are circumstances such as a point emerging through the
frustum from within the cone whose significance is best determined by
your intended application.
Hopefully this account is sufficiently detailed for you to be able to
apply its principles to the specifics of your own notations (which I
assume will involve some programming!).
best wishes, mathtalk-ga |