POV-Ray : Newsgroups : povray.advanced-users : Divide by zero : Divide by zero Server Time
29 Jun 2024 02:09:15 EDT (-0400)
  Divide by zero  
From: stbenge
Date: 19 Jul 2010 13:44:35
Message: <4c448f03@news.povray.org>
Hello,

In one of my macros, I'm finding the slope of a 2D line, and sometimes I 
get that warning about dividing by zero. Since it seems that diving any 
number by zero results in an infinite number, would something like this 
be a good fix?

#if(A.x-B.x != 0)
  #local m1 = (A.y-B.y)/(A.x-B.x);
#else
  #local m1 = 1e10;
#end

It seems to get rid of the warnings, but I wonder if there's a better way.

This poor hack was (understandably) giving me artifacts:

(A.x-B.x+0.000001)

I guess the other option is to jitter my points slightly, but that would 
introduce problems into the whole setup, and total infallibility would 
still not be ensured.

Sam


Post a reply to this message

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