POV-Ray : Newsgroups : povray.newusers : What does the 'mod' operator do? Server Time
10 Nov 2025 22:39:09 EST (-0500)
  What does the 'mod' operator do? (Message 11 to 14 of 14)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Kenneth
Subject: Re: What does the 'mod' operator do?
Date: 10 Nov 2025 16:00:00
Message: <web.6912521e1bdd4431e83955656e066e29@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> 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

From: jr
Subject: Re: What does the 'mod' operator do?
Date: 10 Nov 2025 16:05:00
Message: <web.691253341bdd4431475fba6a6cde94f1@news.povray.org>
hi,

"Kenneth" <kdw### [at] gmailcom> wrote:
> Thorsten <tho### [at] trfde> 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

From: Bald Eagle
Subject: Re: What does the 'mod' operator do?
Date: 10 Nov 2025 16:15:00
Message: <web.691255891bdd44317f81dbac25979125@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> "Bald Eagle" <cre### [at] netscapenet> 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

From: Bald Eagle
Subject: Re: What does the 'mod' operator do?
Date: 10 Nov 2025 16:20:00
Message: <web.691256871bdd44317f81dbac25979125@news.povray.org>
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

<<< Previous 10 Messages Goto Initial 10 Messages

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