POV-Ray : Newsgroups : povray.advanced-users : Negative division : Re: Negative division Server Time
29 Jul 2024 08:15:19 EDT (-0400)
  Re: Negative division  
From: Anders K 
Date: 11 Mar 2003 14:53:11
Message: <3e6e3ea7$1@news.povray.org>
Will W wrote:
> In CSG operations or modifying material maps and so forth, yes, I would
> prefer that the arithmetic be symmetrical around the origin. That lets me
> get away with a lot of shortcuts since I can then often ignore the
direction
> of opposing vectors and just work with their magnitudes.

Sounds like you're just being lazy, typing mod(x, m) when you should
type -mod(-x, m) -- it's only two extra characters. If that's not what it
is, can you give a more concrete example, like Rune did?

> Uh, no, I was talking about integers, with integer arithmetic like mod( )
> and div( ). I don't know any number system that uses a mod( ) or div( )
with
> rationals or reals...

Actually, mod and div are perfectly well defined on reals: div counts the
greatest integer multiple of b that's at most a, and it is perfectly
possible to consider integer multiples of fractions. You can use exactly the
same formulas:
  div(a, b) = floor(a / b)
  mod(a, b) = a - div(a, b)
Although I just checked in POV-Ray, and it does seem to convert everything
to an integer right now. That's too bad, since mod and div would be useful
with non-integer values (such as angles mod 2*pi), and it also has the
unfortunate side effect that div(10000000000000000000000, 3) = -2147483648.

Anders


Post a reply to this message

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