views:

64

answers:

2

basically I am trying to model some map brushes that have the following format:

Each brush defines a solid region. Brushes define this region as the intersection of four or more planes. Each plane is defined by three noncolinear points. These points must go in a clockwise orientation:

1--2----------------->
|
3
|
|
|
|
|
,

Each brush statement looks like this:

 {
  ( 128 0 0 ) ( 128 1 0 ) ( 128 0 1 ) GROUND1_6 0 0 0 1.0 1.0
  ( 256 0 0 ) ( 256 0 1 ) ( 256 1 0 ) GROUND1_6 0 0 0 1.0 1.0
  ( 0 128 0 ) ( 0 128 1 ) ( 1 128 0 ) GROUND1_6 0 0 0 1.0 1.0
  ( 0 384 0 ) ( 1 384 0 ) ( 0 384 1 ) GROUND1_6 0 0 0 1.0 1.0
  ( 0 0 64 ) ( 1 0 64 ) ( 0 1 64 ) GROUND1_6 0 0 0 1.0 1.0
  ( 0 0 128 ) ( 0 1 128 ) ( 1 0 128 ) GROUND1_6 0 0 0 1.0 1.0
 }

That's probably just a bit confusing when you first see it. It defines a rectangular region that extends from (128,128,64) to (256,384,128). Here's what a single line means:

  ( 128 0 0 ) ( 128 1 0 ) ( 128 0 1 ) GROUND1_6 0 0 0 1.0 1.0
   1st Point   2nd Point   3rd Point   Texture

I need to find the intersection points so I can draw the shape only using a method that can draw 2d panels in 3d space. The following code would draw a triangle in space for example:

beginShape();
vertex(x0,y0,z0);
vertex(x1,y1,z1);
vertex(x2,y2,z2);
vertex(x0,y0,z0);
endShape();
A: 

http://mathworld.wolfram.com/Plane-PlaneIntersection.html

This is how you find where three planes intersect. Since you're not working in 4dim (it's a game, right? we see in 3D) then the 3 plane solution given here should be sufficient.

drachenstern
A: 

No. I was looking for the non-trivial pseudo-code to find all intersection points of N planes where some can be parallel and others not, but for which the planes and their intersections create a 2-sphere topology.

The non-trivial pseudo-code would be either a) someone has already solved this problem, and you're just in code-reuse mode, or b) they're solving the problem for you.

Or c) this is a math problem and not a programming problem. Have you consulted any math professors for assistance on this? There is a math stackoverflow property (two I think!)

The only way I know of to quickly find the points of intersection is to but the vectors into the formula I linked previously. That would give you the points of intersection quite quickly. You've already got all the bits you need to calculate this information.

http://stackoverflow.com/questions/30080/how-to-know-if-a-line-intersects-a-plane-in-c-basic-2d-geometry

and

http://www.google.com/search?q=plane+intersection+.net

drachenstern