POV-Ray : Newsgroups : povray.text.scene-files : Intersection Of Two Lines Server Time
31 Oct 2024 12:16:12 EDT (-0400)
  Intersection Of Two Lines (Message 1 to 3 of 3)  
From: Dave Blandston
Subject: Intersection Of Two Lines
Date: 28 Jul 2009 03:30:00
Message: <web.4a6ea7e685700808ed14c4120@news.povray.org>
Helpful macro to compute the intersection of two lines, given their starting
coordinates and angles.

Regards,
Dave Blandston


Post a reply to this message


Attachments:
Download 'intersection.pov.txt' (4 KB)

From: Warp
Subject: Re: Intersection Of Two Lines
Date: 28 Jul 2009 04:20:15
Message: <4a6eb4be@news.povray.org>
Dave Blandston <nomail@nomail> wrote:
>    #local Theta = degrees (atan (Point2_Macro.y / Point2_Macro.x));
>    #local R1 = R2 * sin (radians (Angle2_Macro)) / sin (radians (Angle3_Macro));

  You have potential divisions by zero in these two lines, even for completely
valid parameters passed to the macro.

  The intersection point of two 2D lines is a basic geometrical problem which
can be solved without having to resort to trigonometry, and this solution
avoids divisions by zero. Try googling for "intersection of two lines".

-- 
                                                          - Warp


Post a reply to this message

From: Dave Blandston
Subject: Re: Intersection Of Two Lines
Date: 30 Jul 2009 02:45:01
Message: <web.4a7141087fed82f4ed14c4120@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
>   You have potential divisions by zero in these two lines, even for completely
> valid parameters passed to the macro.

Oops, you're right - how embarrassing. This macro was just right for the project
I was working on at the time because I knew points and angles already. But
there's no excuse for not checking for division by zero. Thanks for pointing
that out.

Regards,
Dave Blandston


Post a reply to this message

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