|
![](/i/fill.gif) |
If you have triangle ABC, the cross-product of A-C (CA) and B-C (CB) will
give you a vector perpendicular to the triangle. Cross-product of <u,v,w>
and <x,y,z> is <vz-wy,wx-uz,uy-vx>. The x,y,z components of this new
vector are the coefficients for the equation of a plane, Ax+By+Cz=D. To
find D, plug one of the original points in for x, y and z. Now that we
have the equation, it is simply a matter of solving for y: y=(D-Ax-Cz)/B
double GetY(double Ax, double Ay, double Az,
double Bx, double By, double Bz,
double Cx, double Cy, double Cz,
double _X, double _Z)
{
double _A, _B, _C, _D;
_A = (Ay-Cy)*(Bz-Cz) - (Az-Cz)*(By-Cy);
_B = (Az-Cz)*(Bx-Cx) - (Ax-Cx)*(Bz-Cz);
_C = (Ax-Cx)*(By-Cy) - (Ay-Cy)*(Bx-Cx);
_D = _A*Ax + _B*Ay + _C*Az;
return (_D - _A*_X - _C*_Z) / _B;
}
--
David Fontaine <dav### [at] faricy net> ICQ 55354965
My raytracing gallery: http://davidf.faricy.net/
Post a reply to this message
|
![](/i/fill.gif) |