views:

160

answers:

2

This is somewhat hard to describe, so bare with me. Essentially I have a triangle in 3D space defined by its 3 vertices, p0, p1, and p2.

I wish to calculate a plane in this 3D space which lies along both p0 and p1 and faces a third point, p2.

This plane is to be defined by a position and normalised direction/

In addition to lying along p0 and p1, and facing p2, the plane should also be perpendicular to the plane created by p0, p1, and p2

I've struggled with this for quite a while and any help anyone can offer is greatly appreciated.

+1  A: 

Unless I'm misunderstanding what you're asking, a vector from the line to p2 will be the normal to the plane you're trying to define. Basically, you construct a line at right angles to the line p0-p1, running through p2.

Jerry Coffin
+2  A: 

Your question is ill-posed. For any plane that lies on p0 and p1 there will be some point on that plane that "faces" point p2. So all that's left to compute is some plane along p0 and p1.

normal = normalize(cross(p1-p0, pX-p0))  //pX is anything except p1
planePoint = p0

EDIT: see comments

here is an example of my comment explanation

octave:14> p0
p0 =

0 0 0

octave:15> p1
p1 =

0 0 5

octave:16> p2
p2 =

5 0 0

octave:17> cross(p1-p0, cross(p1-p0,p2-p0))
ans =

-125 0 0

You'll notice that the sign is wrong, play with the order of parameters in the cross product to get it facing the right way. Also don't forget to normalize...but it wont affect the direction. Also check to make sure the norm after each cross product isn't near 0, otherwise there is no unique answer.. (triangle forms a line)

Chris H
Ah yes, I should've clarified. My apologies. In addition to lying along p0 and p1, and facing p2, the plane should also be perpendicular to the plane created by p0, p1, and p2.
Fascia
then normal = normalize(cross(p1-p0, normalize(cross(p1-p0,p2-p0)))) and the planePoint is still p0.
Chris H
That worked really well, thank you for your help. It seems almost obvious now that you've spelt it out for me.
Fascia