 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Kenneth" <kdw### [at] gmail com> wrote:
> Unfortunately, I'm still a bit puzzled by the docs' written description.
Well don't feel bad - because at one time I was too.
https://news.povray.org/povray.newusers/thread/%3Cweb.51fb3b6e744b4afe73fc9ebb0%40news.povray.org%3E/?mtop=386122
> But
> another interpretation in the 'modulo' topic...if I understand it
> correctly...puts no restriction on the values re: floats vs. integers--
> "depending on the programming language used."
Yes, well, when you get around to playing with / using these things enough, you
find that things like this can be ... flexible.
What is N/0? It it "undefined"? "unbounded"? Infinity?
what about pow(0, 0)?
Sometimes the definitions of things change - or, rather - grow - to encompass
new discoveries and new ways of understanding, and therefore defining what that
thing is.
Like acids. There have been a number of progressive expansions of the
definition of what an acid is. All the way from Bronstead to Lewis.
zero
Negative numbers
or the square root of -1.
Look at the fundamentals of calculus. We needed LIMITS to make that leap, and
land on putatively solid ground.
So:
Can you take the modulo of a COMPLEX number?
.. . .might depend on which computer language you use.
> In any case, POV-ray's 'mod' can obviously work with float values too...and
> fractions...at least when running in Windows.
Well of course. If I have a 40-foot, 9-inch long log, and I want to cut it up
into sections that are 18 inches long, or 1.5 feet, then I will get a certain
integer number of logs, plus some remainder.
Just conceptually replace "integer" with "unit value".
(The universe is silently begging you to then expand your inquiries and
understanding to Basis Vectors ;) )
> So IMO the docs are either
> outdated or too 'strict', and at least somewhat unclear.
The docs in that case are just "poorly written" - because probably at the time,
they just wanted to casually provide the kindergarten-level explanation of the
function, and get on with the rest of it, rather than expanding it into a
mathematically accurate treatise on Modular Arithmetic.
Likely the documentation needs to be written in a large number of places, if
only to clear up little details like this.
I voluntell Kenneth. :D
- BE
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Kenneth" <kdw### [at] gmail com> wrote:
> ... it also suggested a particular
> video...which I now can't find. The mathematician host quickly discussed some
> typical (i.e. pure-integer) examples of using mod...but then began a rather
> abstract discourse on how modulo should be thought of in other NON-math
> contexts.
Video length?
Background?
Visual aids?
Presenter?
You're at the part where things get interesting - and remarkably useful - if you
stick with it and follow through far enough.
I can attest that there are an amazing number of things that can be done with
the simplest of "tricks" - just using vcross, vdot, matrix determinants,
eigenvalues, and vector swizzling.
And while that may all sound complicated and "out of reach" - the point is that
you don't have to understand a damned thing about how any of it is "done" - you
just need to understand the significance of the result. What it means.
And then you can go on to code some pretty amazing stuff, that's easy to write
(as a result of knowing the "tricks"), and is FAST - compared to the usual "I'm
going to write my code in the exact same way as I went about figuring this out
the long way" that we all do so often.
- BW
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Just got a chance to do a quick AI-interrogation
Practical Computer Graphics Uses of Modulo
Tiling and Repeating Patterns
Use case: Seamless textures, checkerboards, brick walls.
How: mod(x, tile_width) wraps coordinates to repeat a pattern.
Example: Creating a grid of alternating colors:
Text.#declare Color = select(mod(X + Y, 2), rgb <1,1,1>, rgb <0,0,0>);Show more
lines
UV Mapping and Texture Wrapping
Use case: Preventing texture coordinates from exceeding [0,1].
How: mod(U, 1) ensures UVs stay within bounds.
Animation Loops
Use case: Looping motion or color changes.
How: mod(Time, Duration) resets animation after a cycle.
Striping and Banding Effects
Use case: Zebra stripes, barcodes, scanlines.
How: mod(Y, StripeHeight) < Threshold to alternate colors.
Grid Indexing
Use case: Mapping 1D index to 2D grid.
How: Row = Index / Width, Col = mod(Index, Width).
Symmetry and Mirroring
Use case: Reflecting patterns across axes.
How: mod(abs(X), MirrorWidth) to repeat mirrored segments.
Procedural Noise and Randomization
Use case: Repeating pseudo-random patterns.
How: Seeded PRNGs often use mod to wrap values.
Non-Math Logic and Programming Tasks Using Modulo
Alternating Behavior
Use case: Toggle between two states (e.g., even/odd rows).
How: if (mod(i, 2) = 0) → even; else → odd.
Scheduling and Timing
Use case: Trigger events every N frames or seconds.
How: if (mod(Frame, N) = 0) → trigger.
Circular Buffers
Use case: Wrap-around indexing in fixed-size arrays.
How: Index = mod(CurrentIndex, BufferSize).
Color Cycling
Use case: Cycle through a palette.
How: Color = Palette[mod(i, PaletteSize)].
Hashing and Bucketing
Use case: Assign items to groups or bins.
How: Bucket = mod(ID, NumBuckets).
File Naming or Resource Allocation
Use case: Distribute tasks or files evenly.
How: mod(TaskID, NumWorkers).
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 10.11.2025 12:13, Kenneth wrote:
> When I was first querying Google about this topic and read the AI summary--
> which changes by the minute, apparently-- it also suggested a particular
> video...which I now can't find. The mathematician host quickly discussed some
> typical (i.e. pure-integer) examples of using mod...but then began a rather
> abstract discourse on how modulo should be thought of in other NON-math
> contexts. I had real trouble following it, but my own takeaway would be
> *something* like this (not his own original example, which I didn't understand):
Well, have you considered that "AI" in the sense of large language
models is the equivalent of a parrot? ;-)
Maybe a real source of information edited by humans might help? Apart
from a good math book, try https://en.wikipedia.org/wiki/Modulo , which
is reasonably complete and free human-made information.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Thorsten <tho### [at] trf de> wrote:
>
> Well, have you considered that "AI" in the sense of large language
> models is the equivalent of a parrot? ;-)
>
> Maybe a real source of information edited by humans might help? Apart
> from a good math book, try https://en.wikipedia.org/wiki/Modulo , which
> is reasonably complete and free human-made information.
Currently, I have a very skeptical response to AI-generated answers -- when I
even pay attention to them; I wish Google would place those summaries at the
*bottom* of the search page, instead of at the top where they are the first
things we see. But of course, that would negate the entire purpose of why they
are there: using all of us as guinea pigs to help the AI engine 'learn', if only
by clicking on the 'Like' or 'Don't like' buttons that are so conveniently
placed-- which I never respond to, as MY silent protest.
Here's one AI answer/example that I saw while searching for 'modulo'-- it
quickly came and went, but I swear that I'm not making it up, honest!
"72 mod 10: The result is 2, because 10 goes into 70 three times, with a
remainder of 2."
So 10 X 3 = 70? I didn't know that!
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Kenneth" <kdw### [at] gmail com> wrote:
> Unfortunately, I'm still a bit puzzled by the docs' written description.
Check out the "divmod" function!
https://docs.python.org/3/library/functions.html#divmod
divmod(a, b, /)
Take two (non-complex) numbers as arguments and return a pair of numbers
consisting of their quotient and remainder when using integer division. With
mixed operand types, the rules for binary arithmetic operators apply. For
integers, the result is the same as (a // b, a % b). For floating-point numbers
the result is (q, a % b), where q is usually math.floor(a / b) but may be 1 less
than that. In any case q * b + a % b is very close to a, if a % b is non-zero it
has the same sign as b, and 0 <= abs(a % b) < abs(b).
HuhSayWhat?
"Your next assignment, should you choose to accept it....."
:D
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Bald Eagle" <cre### [at] netscape net> wrote:
>
> I can attest that there are an amazing number of things that can be done with
> the simplest of "tricks" - just using vcross, vdot, matrix determinants,
> eigenvalues, and vector swizzling.
About the only thing I truly grasp from that bunch is vector swizzling. :-( I
have lots more learnin' to do...
>
> And while that may all sound complicated and "out of reach" - the point
> is that you don't have to understand a damned thing about how any of it
> is "done" - you just need to understand the significance of the result.
> What it means.
>
> And then you can go on to code some pretty amazing stuff, that's easy to
> write (as a result of knowing the "tricks"), and is FAST - compared to
> the usual "I'm going to write my code in the exact same way as I went about
> figuring this out the long way" that we all do so often.
>
Well-said. Fortunately or unfortunately, I always think in terms of 'visual
images' regarding math stuff-- I have to construct a step-by-step mental picture
of the particular process that I'm dealing with...as well as for the particular
math 'tool' that I'm trying to use, before putting it to work. Only then do I
have a clear understanding of what the result will be. It's a plodding and
cautious process, admittedly. But at some point I'll (hopefully) have a
'Eureka!' moment, when all is clear. :-)
But then there are times that I'll just *experiment*-- using renders, one after
another-- with no clear idea of what's happening or what to expect, until I see
some kind of result that helps me learn. That's usually a lot of fun, because
unexpected things arise! I should do more of that, instead of trying to do so
much 'pre-thinking'.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
hi,
"Kenneth" <kdw### [at] gmail com> wrote:
> Thorsten <tho### [at] trf de> wrote:
> >
> > Well, have you considered that "AI" in the sense of large language
> > models is the equivalent of a parrot? ;-)
> > ...
> ...
> Here's one AI answer/example that I saw while searching for 'modulo'-- it
> quickly came and went, but I swear that I'm not making it up, honest!
>
> "72 mod 10: The result is 2, because 10 goes into 70 three times, with a
> remainder of 2."
>
> So 10 X 3 = 70? I didn't know that!
it probably works for people who have six fingers on each hand. ;-)
regards, jr.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Kenneth" <kdw### [at] gmail com> wrote:
> "Bald Eagle" <cre### [at] netscape net> wrote:
> >
> > I can attest that there are an amazing number of things that can be done with
> > the simplest of "tricks" - just using vcross, vdot, matrix determinants,
> > eigenvalues, and vector swizzling.
>
> About the only thing I truly grasp from that bunch is vector swizzling. :-( I
> have lots more learnin' to do...
I did some tutorial stuff on vcross and vdot. Hopefully that's clear enough for
you. There's also the stuff in the distro.
Matrix determinants are ... not my strong point, but I believe relate to area or
volume, and IIRC can signify other things as well (maybe?) - probably depending
on what the input data is.
Eigenvalues are the scalar values in a transformation matrix that tell you how
much the associated vector gets stretched or compressed. 3Blue1Brown does an
EXCELLENT series on linear algebra, which you absolutely should watch - it's
VERY visual and intuitive. He will tell you EXACTLY what all these things are
and mean, and WHY.
> > And while that may all sound complicated and "out of reach" - the point
> > is that you don't have to understand a damned thing about how any of it
> > is "done" - you just need to understand the significance of the result.
> > What it means.
> >
> > And then you can go on to code some pretty amazing stuff, that's easy to
> > write (as a result of knowing the "tricks"), and is FAST - compared to
> > the usual "I'm going to write my code in the exact same way as I went about
> > figuring this out the long way" that we all do so often.
Yeah, but what I mean here, is that if you did something like rename mod (A,B)
to "remainder" - using a macro or function, then you really wouldn't need to be
able to regurgitate the exact steps of the process - you'd intuitively know what
the calculated result meant.
I just coded a "Cash Register" macro, since it was one of the fun examples that
I found while searching for examples for you. Hopefully I'll get a little time
to test it out tonight to see if I did it right without the code-parse
error-edit cycle. ;)
-BW
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Interesting application:
https://math.stackexchange.com/questions/101324/how-to-use-modulo-to-find-the-last-character-of-an-exponentiation
https://math.stackexchange.com/questions/23918/how-to-find-the-last-digit-of-31000/23920#23920
REALLY interesting reference therein (!):
https://math.stackexchange.com/questions/2033639/mod-of-numbers-with-large-exponents-modular-order-reduction/2033681#20
33681
- BW
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |