Sunday, August 2, 2009

Get third coordinate from point in triangle.?

I have 3 3D points (A, B, C) and 1 2D point (P). I know that P is in the triangle ABC. I want the third coordinate from P.





This is how i do it now, but i'f afraid it's incorrect:





PROCEDURE GetZUitVlak(A, B, C: Vector.Vector4D; P: Vector.Vector3D): REAL;


VAR


n, m: Vector.Vector4D;


d: REAL;


BEGIN


n := B.Sub(A);


m := C.Sub(A);


n := n.VecProd(m);





d := - n.Get(0)*B.Get(0) - n.Get(1)*B.Get(1) - n.Get(2)*B.Get(2);


(* d = -nX*BX - nY*BY - nZ*BZ *)


RETURN (-d -n.Get(0)*P.Get(0)-n.Get(1)*P.Get(1))/n....


(* RETURN (-d - nX*PX - nY*pY)/nZ *)


END GetZUitVlak;





(Excuse me for my bad english).





Thanks in advance, Wouter ibens

Get third coordinate from point in triangle.?
It seems to be working... I'd have explicitly solved the equation of the plane (using the matrix of the three points -- by the way, "d" equals the determinant of this matrix), but your finding the normal is actually equivalent.


No comments:

Post a Comment