POV-Ray : Newsgroups : povray.advanced-users : Negative division Server Time
29 Jul 2024 06:22:05 EDT (-0400)
  Negative division (Message 11 to 20 of 22)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 2 Messages >>>
From: Thorsten Froehlich
Subject: Re: Negative division
Date: 10 Mar 2003 13:29:35
Message: <3e6cd98f@news.povray.org>
In article <3e6cc573@news.povray.org> , gimi <gim### [at] psicoch>  wrote:

> - then consider this:
> (source: http://www.cs.uu.nl/~daan/papers/divmodnote.html)

Because someone on some webpage says this makes my statement incorrect?

I am not going to get into an argument over nonsense like this.  Any such
argument would be pointless because I don't have do defend correct behavior.
You have to produce credible sources that show the current behavior does not
follow any logical rules.  And that task, fortunately, is impossible because
the results in POV-Ray are generated by a well-defined program.

    Thorsten

____________________________________________________
Thorsten Froehlich
e-mail: mac### [at] povrayorg

I am a member of the POV-Ray Team.
Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Negative division
Date: 10 Mar 2003 13:55:39
Message: <3e6cdfab$1@news.povray.org>
In article <3e6cc573@news.povray.org> , gimi <gim### [at] psicoch>  wrote:

> this is what both the programmers of povray, and the engineers
> at hp did, and why the results are different, but neither are
> *wrong*!

Yes, because you only look at div and mod as one system.  You have to
consider the use of div without mod.  And then the rounding rules get
arbitrary as a special case just to fit mod, which in nonsense to do.  And
just because engineers at HP didn't know how to produce a logical
implementation doesn't make their implementation right.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: gimi
Subject: Re: Negative division
Date: 10 Mar 2003 15:11:58
Message: <3e6cf18e$1@news.povray.org>
Thorsten Froehlich wrote:
> In article <3e6cc573@news.povray.org> , gimi <gim### [at] psicoch>  wrote:
>>(source: http://www.cs.uu.nl/~daan/papers/divmodnote.html)
>
> Because someone on some webpage says this makes my statement incorrect?

no, it's that it is *plain wrong* that makes it incorrect.

your statement was that Anders was wrong, and i showed
that this is is not true. - get it?

i quoted this page because it was the first hit
on google.  i looked this up because i wasn't sure
about the details, so i refreshed my memory, kind of.

what pages i quote is completely irrelevant, as long as
the content is correct.  i just couldn't find it in one
of my books right away.

> I am not going to get into an argument over nonsense like this.  Any such
> argument would be pointless because I don't have do defend correct behavior.
> You have to produce credible sources that show the current behavior does not
> follow any logical rules.  And that task, fortunately, is impossible because
> the results in POV-Ray are generated by a well-defined program.

again, you missed by far! - nowhere and in no way did i
suggest that povray (nor any other program or system) did
not behave correctly - i quote again:

Thorsten Froehlich wrote:
> In article <3e6bcf10@news.povray.org> , "Anders K."
> <and### [at] kaseorgcom> wrote:
>> mod(7, 3) = 1
>> mod(-7, 3) = 2
>> mod(7, -3) = 1
>> mod(-7, -3) = 2
> Again, only if you apply random rules you could arrive at this result.
> I could understand you argue for 1,2,2,1 as results for this, but not 
> 1,2,1,2 because that is definitely wrong.

see, you accused Anders of stating something wrong.
i said that no, it is not wrong.  it is a matter of
how you actually define that functions, and if you
do it Anders' way, you will get his results, which
are as correct as povray's or hp's results are, because
they fulfill the relation in the definition that i
have quoted.

Thorsten Froehlich wrote:
> In article <3e6cc573@news.povray.org> , gimi <gim### [at] psicoch>  wrote:
>> this is what both the programmers of povray, and the engineers
>> at hp did, and why the results are different, but neither are
>> *wrong*!
>
> Yes, because you only look at div and mod as one system.  You have to
> consider the use of div without mod.  And then the rounding rules get
> arbitrary as a special case just to fit mod, which in nonsense to do. 
 > And just because engineers at HP didn't know how to produce a logical
> implementation doesn't make their implementation right.

honestly, i don't see where you are trying to get here.

of course the two functions have to be defined on the basis
of the same system, or they would not work (as they have to
sort of "complement" each other). - you cannot use two
different rulesets for creating "div" and "mod" functions;
as they will not generally fulfull the equation in the
definition this way (like using "hp-div" together with
"povray-mod", or whatever).

it is not a question of right or wrong, logical or illogical
implementation.  the question is whether they are consistently
defined, and if they are, they will actually work!


well, i'm going to drink some beer now. cheers!

-- 
the quote has left the building


Post a reply to this message

From: Andrew Coppin
Subject: Re: Negative division
Date: 10 Mar 2003 16:43:48
Message: <3e6d0714@news.povray.org>
Oh my God, what have I created...

Well, of course, div and mod could give me any pair of numbers such that you
can reconstruct the originals! Of course, letting mod be larger than the
denominator would seem a little silly from a practical point of view, but
yes, I am aware that there are two equally valid ways PR could handle this -
which is why I asked!

I too would have liked to find that it does it the other way round - because
I wanted to use mod() to reduce all integer values into the range 0 - (n-1).
Never mind!

Andrew.



Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Negative division
Date: 10 Mar 2003 18:45:55
Message: <3e6d23b3$1@news.povray.org>
In article <3e6cf18e$1@news.povray.org> , gimi <gim### [at] psicoch>  wrote:

> honestly, i don't see where you are trying to get here.
>
> of course the two functions have to be defined on the basis
> of the same system, or they would not work (as they have to
> sort of "complement" each other). - you cannot use two
> different rulesets for creating "div" and "mod" functions;
> as they will not generally fulfull the equation in the
> definition this way (like using "hp-div" together with
> "povray-mod", or whatever).

The point is that the non-POV-Ray results are plain useless for anything but
combining mod and div results back together.  However, it might be
surprising, but the mod and div functions exist for more than just
mathematical completeness.

Apart from this, I really have no time for this.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Anders K 
Subject: Re: Negative division
Date: 10 Mar 2003 21:58:44
Message: <3e6d50e4@news.povray.org>
I wrote:
> > div(7, 3) = 2
> > div(-7, 3) = -3
> > div(7, -3) = -2
> > div(-7, -3) = 3

Thorsten Froehlich wrote:
> How can the result possibly be +-3 for any of these?  No matter how you
> round, this makes only sense if you apply *different* rounding rules
> depending on the signs.  And doing so is nonsensical.

No, the formulas I'm using are very simple and consistent:
  div(a, b) = floor(a / b)
  mod(a, b) = a - div(a, b)
Where floor always rounds down to the nearest integer.

Instead of floor, POV-Ray is using trunc (which POV-Ray calls int, but
shouldn't), and trunc rounds up if a number's less than zero, and down if a
number's greater than zero. So it's POV-Ray's current behavior that uses
different rounding rules, and in your own words, is nonsensical.

Anders


Post a reply to this message

From: Anders K 
Subject: Re: Negative division
Date: 10 Mar 2003 22:05:55
Message: <3e6d5293$1@news.povray.org>
Thorsten Froehlich wrote:
> The point is that the non-POV-Ray results are plain useless for anything
but
> combining mod and div results back together.

I (and many others) would say that about the current POV-Ray results! Rune
has already given an example where the POV-Ray behavior is useless -- taking
a hue value mod 360, attempting to get it in the range [0, 360). Now I'd
like to see an example where the current POV-Ray behavior is needed. Anyone?

Anders


Post a reply to this message

From: Will W
Subject: Re: Negative division
Date: 11 Mar 2003 00:45:02
Message: <3e6d77de@news.povray.org>
"Anders K." <and### [at] kaseorgcom> wrote in message
news:3e6d50e4@news.povray.org...

<snip>

> Instead of floor, POV-Ray is using trunc (which POV-Ray calls int, but
> shouldn't), and trunc rounds up if a number's less than zero, and down if
a
> number's greater than zero. So it's POV-Ray's current behavior that uses
> different rounding rules, and in your own words, is nonsensical.

POV's method is consistent within its intended framework. The behavior is
that truncation is always to the lower magnitude, which often is what you
want when working in a cartesian coordinate system (where the negation of a
value should be a symmetrical with the first value around the origin).
Because POV is essentially a cartesian graphing system, it makes a lot of
sense to go with this model.

Another aspect of the problem that is going unrecognized here is that while
mathemeticians deal with a true integer number line, there is no way to
represent that number line in any computer I know of. The best that can be
done is to set up a large "number circle"-- but there will be some maximum
number which when incremented will yield a negative number, and some minimum
number which when decremented will yield a positive number. Working with
magnitudes-- the distance the number is away from zero-- allows for more
consistency in the system's behavior.

I'm not sure that I'd care to see POV adopt the pure mathematics model.
While it is true that the current method makes conversion of negative hue
values more difficult, it also makes operations in POV's vector space more
dwim. I'm sort of confused about negative hue values anyway-- the concept
strikes me as unnatural. But whatever floats your boat.


--
Will Woodhull
Thornhenge, SW Oregon, USA
willl.at.thornhenge.net


Post a reply to this message

From: gimi
Subject: Re: Negative division
Date: 11 Mar 2003 02:38:07
Message: <3e6d925f$1@news.povray.org>
Thorsten Froehlich wrote:
> The point is that the non-POV-Ray results are plain useless for anything but
> combining mod and div results back together.

that is bullshit.  i won't look for a page to quote
from this time :) , but i bet there are plenty.

or maybe you should look up "modulo calculus" for
yourself.

> However, it might be
> surprising, but the mod and div functions exist for more than just
> mathematical completeness.

yes, i understand this now (Will's explanation was
very helpful for my understanding of povray's use
for div and mod, and why it is a little, um,
"different". ;)

however, i agree with Andrew that it is a bit strange
from a mathematician's perspective.

the only solution would be to use macros for other
implementations, if one needs them, as hardly anybody
would agree if someone asked the pov team to rename,
say, "div" to "symdiv" and add another function..

> Apart from this, I really have no time for this.

i disagree!  ;)


g.

-- 
Shick's Law: There is no problem a good miracle can't solve.
++ mailto:gim### [at] psicoch ++ http://www.psico.ch/ ++


Post a reply to this message

From: Anders K 
Subject: Re: Negative division
Date: 11 Mar 2003 09:00:43
Message: <3e6dec0b@news.povray.org>
Will W wrote:
> POV's method is consistent within its intended framework. The behavior is
> that truncation is always to the lower magnitude, which often is what you
> want when working in a cartesian coordinate system (where the negation of
a
> value should be a symmetrical with the first value around the origin).

I don't see why anyone would want mod(-x, m) to be symmetrical with mod(x,
m).

> Another aspect of the problem that is going unrecognized here is that
while
> mathemeticians deal with a true integer number line, there is no way to
> represent that number line in any computer I know of. The best that can be
> done is to set up a large "number circle"-- but there will be some maximum
> number which when incremented will yield a negative number, and some
minimum
> number which when decremented will yield a positive number.

That's not true with floating-point numbers, which is what we're talking
about here. Besides, even if they were integers, the result of mod(-1, 3) is
much more important than the result of mod(-2147483648, 3).

> While it is true that the current method makes conversion of negative hue
> values more difficult, it also makes operations in POV's vector space more
> dwim.

How so?

> I'm sort of confused about negative hue values anyway-- the concept
> strikes me as unnatural.

Of course you wouldn't directly enter a negative hue, but suppose you want
to shift all the hues in some picture down by 10 -- then you get negative
hues pretty quickly. If you prefer, think of shifting an angle by 10
degrees. This is exactly the kind of thing that mod is for, but POV-Ray's
mod is nearly useless in this case.

Anders


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 2 Messages >>>

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