[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

1914.0. "Intersection of a ray with a plane?" by DNEAST::JACKSON_KELL () Tue Nov 29 1994 18:48

    I'm not much of a math whiz, but I know where to find some ;-)

    Maybe you fine folks could help me with a few formula's and a brief
    explanation of how to tell when a ray intersects with a plane?
    
    What I have is a 3D shape with a surface made up of triangles (for a
    raytracer) and what I want to do is pick a point inside that shape and
    draw a ray to the outside of that shape and be able to tell if the ray
    intersects with a surface, a line, or a point on the 3D shape and
    exactly where it intersects. 
    
    I'm working on an algorythm for morphing one set of smoothed triangles
    into another, but I'm stuck here.
    
    	-Chris J.
T.RTitleUserPersonal
Name
DateLines
1914.1AUSSIE::GARSONachtentachtig kacheltjesWed Nov 30 1994 03:3427
    re .0
    
    Theoretically speaking you can determine whether a line intersects a
    plane by determining whether the line is perpendicular to the normal of
    the plane. If a and b are two vectors in the plane and c is the line
    then this is equivalent to evaluating (a * b) � c where * is here used
    to represent the vector cross product and � represents the dot product.
    
    This ignores issues such as
    
    * the plane may be finite
    * the ray is semi-infinite
    
    In practice this would be a waste of time (I think). It would be better
    just to go ahead and try to find the point of intersection. If there is
    none then this will come out of the algebra anyway. Finding the
    intersection is just basic algebra if you have the equation of the
    plane, say Ax+By+Cz = D, and the equation of the line, x, y and z as
    linear functions of a parameter t. It is only necessary to solve for t
    and substitute back in the equation for the line. The sign of t will
    tell you whether the ray (as opposed to the line) will intersect.
    
    Presumably you would have to do that for each triangle. I'm not sure
    how you tell whether the point of intersection is inside the triangle.
    
    I'm sure there are good algorithms around for this that are optimised
    somewhat over the simplistic approach outlined above.
1914.2AZUR::DESOZAJean-Pierre Sophia-Antipolis, DTN 828-5559Wed Nov 30 1994 08:2020
In this case, the plane is typically finite, it's a facet. and there may be
tousands of them.

I think that there is first a 3D-clipping step. Its purpose is to eliminate
unnecessary computations: Only facets in the 1/2 space containing the ray
are candidates to intersection. Imagine the ray starting from your eye.
You don't need to consider any facet behind your head.

Consider a pyramid or a cone starting from the origin of the ray with an 
aperture to be determined, and sort the facets that lie inside or outside the 
pyramid or cone. 

Then process the subset of facets that lie inside the pyramid or cone. 

If this is not what is interesting you, then the details on an intersection 
algorithm are surely in some book on projective or computational geometry.

For example I remember that for intersecting straight lines the most efficient
algorithm was based on a parametric representation of the lines rather another
one because it saved just one multiplication or division. 
1914.3Back to basicsAZUR::DESOZAJean-Pierre Sophia-Antipolis, DTN 828-5559Wed Dec 07 1994 12:1827
I've reviewed my computer graphics books :-)

A plane can be represented by its distance d to origin O and by a normal 
vector N. (Imagine the plane tangent to a sphere centered on the origin)

The points of the plane when projected on an axis normal to the plane are also
at a distance d off the origin: The projection is obtained by a dot product
with the vector N:  (u.v = Xu * Xv + Yu * Yv + Zu * Zv in 3D space)

If P belongs to the plane:
	 OP.N - d = 0	(OP is the vector from the origin to the point P.)

A straight line is defined by a point R and a vector V.
	M belongs to the straight line iff there is such a lambda as
	RM = lambda x V

The point I of intersection of the straight line and the plane veryfies both
relationships.
	RI = lambda x V
	and
	OI.N - d = 0

	as OI = OR + RI
	we get	OR.N + RI.N - d = 0 (distributivity of dot product)
	i.e.	OR.N + (lambda x V).N - d = 0

Hence: lambda = (d - OR.N)/V.N