POV-Ray : Newsgroups : povray.advanced-users : Negative division : Re: Negative division Server Time
29 Jul 2024 02:25:43 EDT (-0400)
  Re: Negative division  
From: Rune
Date: 9 Mar 2003 19:37:14
Message: <3e6bde3a@news.povray.org>
Christopher James Huff wrote:
> Anders K. wrote:
>> This has annoyed me a lot. If they fixed the
>> broken gradient pattern, why can't they fix
>> the equally broken div() and mod() functions?
>
> Because they didn't know about it?

The way the mod() function works for negative numbers has annoyed me a
lot too, but having originally learned about the mod() function through
POV-Ray, I thought it was just the way it was supposed to work, pleasant
or not.

Actually, if you look in colors.inc in the CH2RGB macro, you will see
that I explicitly worked around the problem by having this line

#local H = mod(H, 360);

be followed by this one:

#local H = (H < 0 ? H+360 : H);


Internally, isn't it just some int() call that should be replaced with
floor()? From the docs:

   mod(A,B) Value of A modulo B. Returns the remainder
   after the integer division of A/B.
   Formula is mod=((A/B)-int(A/B))*B.


Rune
--
3D images and anims, include files, tutorials and more:
rune|vision:  http://runevision.com (updated Oct 19)
POV-Ray Ring: http://webring.povray.co.uk


Post a reply to this message

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