javagraphicsgeometry

How can I find the intersecting point of three planes?


I'm trying to build render the raw data from a Quake 3 .map file with Java. The .map format stores brush (shape) information as a series of planes, but I'd like to convert them to points of the form (x,y,z). The math involved is a bit beyond me at this point, so does anyone have any advice on how I can do this? I'm fine with using external libraries if need be, but I'd rather use my own code if possible.

Some data to play with:

Dimensions:   64*64*64
Position:     All sides are equidistant from the origin (0,0,0)
Shape:     Cube
( 64 64 64 ) ( 64 -64 64 ) ( -64 64 64 )
( 64 64 64 ) ( -64 64 64 ) ( 64 64 -64 )
( 64 64 64 ) ( 64 64 -64 ) ( 64 -64 64 )
( -64 -64 -64 ) ( 64 -64 -64 ) ( -64 64 -64 )
( -64 -64 -64 ) ( -64 -64 64 ) ( 64 -64 -64 )
( -64 -64 -64 ) ( -64 64 -64 ) ( -64 -64 64 )

Edit:

This data is showing a cube, which has 6 sides. Each of these six sides can be stored as a plane, with three coordinates to show the position and orientation. Each row of the above data shows one plane, and all 6 of the rows make the 6 planes that make up a cube.

This image helps illustrate my point: Three Points Defining a Plane

Points p1, p2, and p3 are what I'm giving per row, in the above data.

The Quake 3 engine has to sort out what parts of the planes to keep at compile time, but I'm not interested in that at the moment. If you would like more information, feel free to ask!


Solution

  • I go to Wolfram Mathworld whenever I have questions like this. For this problem, try this page: Plane-Plane Intersection

    Equation 8 on that page gives the intersection of three planes. To use it you first need to find unit normals for the planes. This is easy: given three points a, b, and c on the plane (that's what you've got, right?), take the cross product of (a-b) and (a-c) to get a normal, then divide it by its own magnitude to get a unit normal.