POV-Ray : Newsgroups : povray.general : POV-related math question : Re: POV-related math question Server Time
5 Aug 2024 10:20:39 EDT (-0400)
  Re: POV-related math question  
From: Dan Byers
Date: 2 Oct 2002 20:45:06
Message: <web.3d9b920b9b98c28e7c10c2df0@news.povray.org>
Thanks to everyone who responded! :)  I was digging thru my bookshelf
looking for my Java book and I stumbled across my old algebra book.  Inside
were listed a few different ways to solve the intersection of a pair of
linear equations.  I turned that into a macro, and it works! (believe me,
no one was more surprised than I!).  For the curious (or bored), here's the
macro:

#macro LineIntersect( v1Start, v1End, v2Start, v2End)
//-------------------------------------------------------------------
// returns a vector with the point that represents the intersection
// of a pair of lines... assumes Z is zero and that both lines are
// neither parallel, superimposed, or vertical...
//-------------------------------------------------------------------
 #local v1 = v1End - v1Start;
 #local rise1 = v1.y;
 #local run1 = v1.x;
 #local k1 = v1Start.y;
 #local h1 = v1Start.x;

 #local v2 = v2End - v2Start;
 #local rise2 = v2.y;
 #local run2 = v2.x;
 #local k2 = v2Start.y;
 #local h2 = v2Start.x;

 #local run3 = run2 / run1;
 #local myX = (((run2*k2) - (rise2*h2)) - (run2*((run1*k1) - (rise1*h1))/
run1)) / ((run2*rise1/run1) - rise2);
 #local myY = ((run1*k1) - (rise1*h1) + (rise1*myX)) / run1;
 <myX, myY, 0>
#end

--------------
dan
http://hometown.aol.com/goofygrafx


Post a reply to this message

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