POV-Ray : Newsgroups : povray.advanced-users : Question for the Math Geniuses (Geniuii? Genies?) : Re: Question for the Math Geniuses (Geniuii? Genies?) Server Time
29 Jul 2024 18:23:12 EDT (-0400)
  Re: Question for the Math Geniuses (Geniuii? Genies?)  
From: David Fontaine
Date: 23 Feb 2001 17:49:40
Message: <3A96E8A2.409DA121@faricy.net>
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] faricynet>  ICQ 55354965
My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.