0
101 Jan 07, 2011 at 18:07

Okay, after posting this on Code Project I realized this must be the better place to ask.

Heres my problem:
I try to implement a Laidlaw-like set of CSG-Operations.
I know (on paper) how to split the triangles, but it gets a bit difficult in code.

I have an intersection Segment on a triangle (and of course on it’s triangle plane) that goes from one boundary, to another one.
What I want is an orthognal Segment to the exisisting one, not orthogonal in the sense of pointing outside of the triangle, I’d like the segments to cross like this:

       | (This segment is supposed to go through the middle of the other one)
|
|
-----------
|
|


I need this to determine on which side some points (as well lying on the triangle plane are).

My algorithm so far for testing the side is:

        public static double WichSide(Segment3D seg, Vector3db P)
{
Vector3db cp1 = Vector3db.Cross(seg.P1 - seg.P0, P - seg.P0);
return Vector3db.Dot(new Vector3db(1,1,1), cp1);
}


I made some tests that suggested the algorithm works fine, but I’m not entirely sure. In this algorithm it (should) return a negatively signed double if the point is one the left and a positive signed double if its one the right.

PS: When I say segment in terms of determining the side, I actually mean a line that goes through the segment points.

I’m not particulary good at math, so please go easy on the explanation if you have a solution. Code or pseudo code would be appreciated.