|
|
Wasn't it Shark who wrote:
>In POVray, how do you calculate the intersection of two lines given a point
>on each line and their vectors?
>Is there a handy include file somewhere with a macro that does this?
You could declare (but not render) an extremely thin cylinder around one
of the lines and then use trace().
In most cases there would be no intersection, so do remember to check
for failures.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|
|
|
Shark wrote:
> In POVray, how do you calculate the intersection of two lines given a point
> on each line and their vectors?
> Is there a handy include file somewhere with a macro that does this?
Below are some old macros I once made.
(I don't have time to check if they still work.)
Tor Olav
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Copyright Tor Olav Kristensen
// http://subcube.com
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Projection of the vector v1 in the direction of the vector v2.
#macro vproject(v1, v2)
(v2*vdot(v1, v2)/vdot(v2, v2))
#end // macro vproject
#macro inv_vproject(v1, v2)
(v2/vdot(v2, v1)*vdot(v1, v1))
#end // macro inv_vproject
// Find the two points on the lines which is closest to each other
#macro ln2ln(pLine1, vLine1, pLine2, vLine2, p1, p2)
#local vPN = pLine2 - pLine1;
#local vPQ = vPN - vproject(vPN, vcross(vLine1, vLine2));
#local vQS = inv_vproject(vproject(vPQ, vLine1) - vPQ, vLine2);
#declare p1 = pLine1 + vQS + vPQ;
#declare p2 = pLine2 + vQS;
#end // macro ln2ln
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
Post a reply to this message
|
|
|
|
Tor Olav Kristensen <tor### [at] TOBEREMOVEDgmailcom> wrote:
> Shark wrote:
> > In POVray, how do you calculate the intersection of two lines given a point
> > on each line and their vectors?
> > Is there a handy include file somewhere with a macro that does this?
>
> Below are some old macros I once made.
> (I don't have time to check if they still work.)
Yes, these worked splendidly! Thanks!
Shark
Post a reply to this message
|
|