POV-Ray : Newsgroups : povray.general : Line-Plane intersection : Re: Line-Plane intersection Server Time
19 Nov 2024 15:43:57 EST (-0500)
  Re: Line-Plane intersection  
From: Josh English
Date: 12 Feb 2002 14:06:37
Message: <3C696707.3F9BF78E@spiritone.com>
I answered your question anyway:

The following macro should calculate the intersection if it exists
Note that it does not determine if the line intersects the triangle
defined by your three points. If the line segment doesn't intersect the
plane it will still find the solution

// --------------------------------------
#declare pa = <-1,-1,-1>;
#declare pb = <1,0,1>;
#declare pc = <-1,0,0>;

triangle { pa pb pc pigment { rgbf <1,1,0,0.5> } }

#declare la = <1,1,1>;
#declare lb = <-0.5,-1,-0.2>;

cylinder { la lb 0.01 pigment { rgb x } }

#macro PlaneAndLine(a,b,c,d,e) 
  // a,b,c are on the plane
  // d and e are on the line
  #local pn = vnormalize(vcross(a-b,c-b));
  #local ld = vnormalize(d-e);
  #local test = vdot(ld,pn);
  #local ps = <0,0,0>;
  #if ( abs(test) < 0.00001 )
     #debug "Line does not intersect plane"
  #else
     #local mu = vdot((a-d),pn)/vdot(ld,pn);
     #local ps = d + mu*ld;
  #end
  ps
#end

#declare ps = PlaneAndLine(pa,pb,pc,la,lb);
sphere { ps 0.05 pigment { rgb y } }

Josh English
eng### [at] spiritonecom
http://www.spiritone.com/~english


Post a reply to this message

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