POV-Ray : Newsgroups : povray.general : Help with "programmatically" determining intersection : Re: Help with "programmatically" determining intersection Server Time
3 May 2024 07:28:36 EDT (-0400)
  Re: Help with "programmatically" determining intersection  
From: Le Forgeron
Date: 17 Mar 2016 12:49:19
Message: <56eae00f@news.povray.org>
Le 17/03/2016 17:05, Bald Eagle a écrit :
> 
> 
>> > I don't think that will work because your curves are moving in 2
>> > dimensions. What you'd need to do is check if the line between the
>> > current point and the previous point of curve 1 *crosses* the line
>> > between the current point and the previous point of curve 2.
> I read that 5 times and finally got ya.
> That _sounds_ good - but:  HOW do we do that "checking"?

if you have 2 pair of points, making 2 segments (forget for the time being a curve
between the points),
you can check if the segments intersect with a bit of math (ah, again).

1. the points of second segment must be on each side of the line defined by the first
segment.

( a simple matter of having the line equation ax+by+c = 0 for that line, then the sign
of ax+by+c for the P3 and P4 must be opposite, aka
 f(P3) * f(P4) < 0

you can also check if P3 or P4 is on the line : f(P3) * f(P4) == 0
)

2. repeat previous check by swapping the pairs.

3. if both previous checks are successful, you have asserted that each segment cut the
line of the other pair.
The demonstration that with such situation the two segments do intersect each other,
is not too complex (some would state obvious,
but obvious in math might need a few pages).

Whatever, you have your above check.

Hardest part: from 2 distinct points, compute the 3 coefficients of the equation of
their line.


Post a reply to this message

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