POV-Ray : Newsgroups : povray.advanced-users : modulo / math funktions Server Time
11 Oct 2026 11:10:07 EDT (-0400)
  modulo / math funktions (Message 1 to 19 of 19)  
From: marabou
Subject: modulo / math funktions
Date: 29 Oct 2001 11:03:45
Message: <3bdd7de1@news.povray.org>
hello, 

in the manual i did not find any hind about this:
what is the function-call for modulo?
is it all similar to c(++)?

thanks


Post a reply to this message

From: marabou
Subject: Re: modulo / math funktions
Date: 29 Oct 2001 11:06:02
Message: <3bdd7e6a@news.povray.org>
marabou wrote:

> 
> hello,
> 
> in the manual i did not find any hind about this:
> what is the function-call for modulo?
> is it all similar to c(++)?
> 
> thanks

sorry for my pronounciation. i ment <hint>.

i want to make a construct like this:

        #if (mod((cm*100)/1) = 0)
        [...]
        #else
        [...]
        #end


Post a reply to this message

From:
Subject: Re: modulo / math funktions
Date: 29 Oct 2001 11:17:12
Message: <d20rtt86q3gfsa1h8jb8fm54u682lfaii9@4ax.com>
On Mon, 29 Oct 2001 17:06:50 +0100, marabou <not### [at] availableyet> wrote:

> i want to make a construct like this:
>
>        #if (mod((cm*100)/1) = 0)
>        [...]
>        #else
>        [...]
>        #end

I think you have POV-Ray installed with documentation but if not (POV
3.5 allow to not instal doc) please look at
http://www.povray.org/working-docs/id000135.html#6_1_3_6 - there is
list of float functions (also mod) for current beta version of POV 3.5
but most of them (i.e. mod) works fine with erlier versions.

ABX
--
#declare _=function(a,b,x){((a^2)+(b^2))^.5-x}#default {pigment{color rgb 1}}
union{plane{y,-3}plane{-x,-3}finish{reflection 1 ambient 0}}isosurface{ //ABX
function{_(x-2,y,1)|_((x+y)*.7,z,.1)|_((x+y+2)*.7,z,.1)|_(x/2+y*.8+1.5,z,.1)}
contained_by{box{<0,-3,-.1>,<3,0,.1>}}translate z*15finish{ambient 1}}//POV35


Post a reply to this message

From: marabou
Subject: Re: modulo / math funktions
Date: 29 Oct 2001 11:22:17
Message: <3bdd8238@news.povray.org>
that was it. thank you very well.

W³odzimierz ABX Skiba wrote:

> On Mon, 29 Oct 2001 17:06:50 +0100, marabou <not### [at] availableyet> wrote:
> 
>> i want to make a construct like this:
>>
>>        #if (mod((cm*100)/1) = 0)
>>        [...]
>>        #else
>>        [...]
>>        #end
> 
> I think you have POV-Ray installed with documentation but if not (POV
> 3.5 allow to not instal doc) please look at
> http://www.povray.org/working-docs/id000135.html#6_1_3_6 - there is
> list of float functions (also mod) for current beta version of POV 3.5
> but most of them (i.e. mod) works fine with erlier versions.
> 
> ABX
> --
> #declare _=function(a,b,x){((a^2)+(b^2))^.5-x}#default {pigment{color rgb
> #1}}
> union{plane{y,-3}plane{-x,-3}finish{reflection 1 ambient 0}}isosurface{
> //ABX
> 
function{_(x-2,y,1)|_((x+y)*.7,z,.1)|_((x+y+2)*.7,z,.1)|_(x/2+y*.8+1.5,z,.1)}
> contained_by{box{<0,-3,-.1>,<3,0,.1>}}translate z*15finish{ambient
> 1}}//POV35


Post a reply to this message

From:
Subject: Re: modulo / math funktions
Date: 29 Oct 2001 11:25:02
Message: <bj0rttsen87jqdpfen56p8450jmkva6q8o@4ax.com>
On Mon, 29 Oct 2001 17:23:04 +0100, marabou <not### [at] availableyet> wrote:

> that was it. thank you very well.

BTW: there are much more advanced questions within
povray.newusers group :-)

ABX
--
#declare _=function(a,b,x){((a^2)+(b^2))^.5-x}#default {pigment{color rgb 1}}
union{plane{y,-3}plane{-x,-3}finish{reflection 1 ambient 0}}isosurface{ //ABX
function{_(x-2,y,1)|_((x+y)*.7,z,.1)|_((x+y+2)*.7,z,.1)|_(x/2+y*.8+1.5,z,.1)}
contained_by{box{<0,-3,-.1>,<3,0,.1>}}translate z*15finish{ambient 1}}//POV35


Post a reply to this message

From: Warp
Subject: Re: modulo / math funktions
Date: 29 Oct 2001 13:07:06
Message: <3bdd9aca@news.povray.org>
Włodzimierz ABX Skiba <abx### [at] babilonorg> wrote:
: BTW: there are much more advanced questions within
: povray.newusers group :-)

  Which raises a question: Why do people post trivial questions in this
group? They should know that asking the syntax for a trivial function is
far from advanced.

-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

From: Ron Parker
Subject: Re: modulo / math funktions
Date: 29 Oct 2001 13:20:32
Message: <slrn9tr7fi.av0.ron.parker@fwi.com>
On 29 Oct 2001 13:07:06 -0500, Warp wrote:
> Włodzimierz ABX Skiba <abx### [at] babilonorg> wrote:
>: BTW: there are much more advanced questions within
>: povray.newusers group :-)
> 
>   Which raises a question: Why do people post trivial questions in this
> group? They should know that asking the syntax for a trivial function is
> far from advanced.

The usual thinking seems to go "well, this is where the advanced users
hang out, so someone here is sure to know the answer to my question."

Either that or the definition of advanced is "anyone more advanced than
me."


-- 
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbf 1}hollow interior{media{emission 3-T}}}#end 
Z(-x-x.2x)camera{location z*-10rotate x*90normal{bumps.02scale.05}}


Post a reply to this message

From: Slime
Subject: Re: modulo / math funktions
Date: 29 Oct 2001 14:46:11
Message: <3bddb203$1@news.povray.org>
Of course, then you've got the other extreme, where people think "My
question isn't advanced enough for this group," and it may or may not be
true, but I think it results in this group being very infrequently posted
to. What *would* qualify as an advanced question or discussion topic?

- Slime
[ http://www.slimeland.com/ ]
[ http://www.slimeland.com/images/ ]

"Ron Parker" <ron### [at] povrayorg> wrote in message
news:slr### [at] fwicom...
> On 29 Oct 2001 13:07:06 -0500, Warp wrote:
> > W³odzimierz ABX Skiba <abx### [at] babilonorg> wrote:
> >: BTW: there are much more advanced questions within
> >: povray.newusers group :-)
> >
> >   Which raises a question: Why do people post trivial questions in this
> > group? They should know that asking the syntax for a trivial function is
> > far from advanced.
>
> The usual thinking seems to go "well, this is where the advanced users
> hang out, so someone here is sure to know the answer to my question."
>
> Either that or the definition of advanced is "anyone more advanced than
> me."
>
>
> --
> #macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z
a-z)R(a
> -z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F
T)merge{
> P(z+a)P(z-a)R(-z-z-x a)pigment{rgbf 1}hollow interior{media{emission
3-T}}}#end
> Z(-x-x.2x)camera{location z*-10rotate x*90normal{bumps.02scale.05}}


Post a reply to this message

From: marabou
Subject: Re: modulo / math funktions
Date: 29 Oct 2001 15:11:42
Message: <3bddb7fc@news.povray.org>
Warp wrote:

> W³odzimierz ABX Skiba <abx### [at] babilonorg> wrote:
> : BTW: there are much more advanced questions within
> : povray.newusers group :-)
> 
>   Which raises a question: Why do people post trivial questions in this
> group? They should know that asking the syntax for a trivial function is
> far from advanced.
> 
BTW: until i do not have installed ht:dig it is a hard job to "fight 
through the fucking manual". rtfm turns to ftfm ;-)
an interesting interesting thing is: where is the border to an advanced 
question. (but no discussion about it please, i will post to newusers 
futurely.)


Post a reply to this message

From: Warp
Subject: Re: modulo / math funktions
Date: 30 Oct 2001 03:56:23
Message: <3bde6b36@news.povray.org>
Slime <noo### [at] hotmailcom> wrote:
: What *would* qualify as an advanced question or discussion topic?

  "How do I calculate the normal vector of an isosurface function at a
certain point <x,y,z>?", for example.

-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

From: Warp
Subject: Re: modulo / math funktions
Date: 30 Oct 2001 03:59:07
Message: <3bde6bdb@news.povray.org>
marabou <not### [at] availableyet> wrote:
: where is the border to an advanced question.

  I don't think there's a clear border. However, there are questions which
are clearly newbie and questions which are clearly advanced.
  When it's not clear, just post where it better fits. :)

-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

From: Slime
Subject: Re: modulo / math funktions
Date: 30 Oct 2001 08:52:05
Message: <3bdeb085$1@news.povray.org>
>   "How do I calculate the normal vector of an isosurface function at a
> certain point <x,y,z>?", for example.

Now *there's* a question that's been plaguing me for a while. I'll ask it
later. =)

- Slime
[ http://www.slimeland.com/ ]
[ http://www.slimeland.com/images/ ]


Post a reply to this message

From: Dave Dunn
Subject: Re: modulo / math funktions
Date: 30 Oct 2001 09:44:13
Message: <3BDEBCBB.6F77D350@aol.com>
Slime wrote:

> >   "How do I calculate the normal vector of an isosurface function at a
> > certain point <x,y,z>?", for example.
>
> Now *there's* a question that's been plaguing me for a while. I'll ask it
> later. =)

I'll be watching for the answer to that one myself, as it is holding up
isosurface support for POVGUI. I suspect it involves using trace...


Post a reply to this message

From: Slime
Subject: Re: modulo / math funktions
Date: 30 Oct 2001 09:58:37
Message: <3bdec01d$1@news.povray.org>
My guess would be evaluating various points near a point on the surface to
determine various derivatives... but I'm not really sure...

- Slime
[ http://www.slimeland.com/ ]
[ http://www.slimeland.com/images/ ]

"Dave Dunn" <poi### [at] aolcom> wrote in message
news:3BDEBCBB.6F77D350@aol.com...
>
>
> Slime wrote:
>
> > >   "How do I calculate the normal vector of an isosurface function at a
> > > certain point <x,y,z>?", for example.
> >
> > Now *there's* a question that's been plaguing me for a while. I'll ask
it
> > later. =)
>
> I'll be watching for the answer to that one myself, as it is holding up
> isosurface support for POVGUI. I suspect it involves using trace...
>


Post a reply to this message

From: Ken
Subject: Re: modulo / math funktions
Date: 30 Oct 2001 10:00:10
Message: <3BDEC07D.F8B538D9@pacbell.net>
Slime wrote:
> 
> My guess would be evaluating various points near a point on the surface to
> determine various derivatives... but I'm not really sure...

The easiest way is to just let an advanced user figure it out for you :)

-- 
Ken Tyler


Post a reply to this message

From: Ron Parker
Subject: Re: modulo / math funktions
Date: 30 Oct 2001 10:16:46
Message: <slrn9tth2v.n0q.ron.parker@fwi.com>
On Tue, 30 Oct 2001 09:44:11 -0500, Dave Dunn wrote:
> 
> 
> Slime wrote:
> 
>> >   "How do I calculate the normal vector of an isosurface function at a
>> > certain point <x,y,z>?", for example.
>>
>> Now *there's* a question that's been plaguing me for a while. I'll ask it
>> later. =)
> 
> I'll be watching for the answer to that one myself, as it is holding up
> isosurface support for POVGUI. I suspect it involves using trace...

Well, if you know how to take the derivative of the function, you just use
the gradient vector, which is < df/dx, df/dy, df/dz > where "d" is really 
the lowercase delta we use to indicate partial derivatives.

Since we're talking about arbitrary functions here, you can approximate the
gradient by using this:

#declare d = 1e-5; //(some small number; POV uses the accuracy value)
#declare Gradient=vnormalize(<F(X+d,Y,Z),F(X,Y+d,Z),F(X,Y,Z+d)>-F(X,Y,Z));

This is what POV does.  As the comment says, we use the value you specified
for the accuracy of the isosurface to do the computation.  Notice that this
does not work properly for functions with zero gradients; you should detect
that and deal with it appropriately.

--
#macro R(L P)sphere{L __}cylinder{L P __}#end#macro P(_1)union{R(z+_ z)R(-z _-z)
R(_-z*3_+z)torus{1__ clipped_by{plane{_ 0}}}translate z+_1}#end#macro S(_)9-(_1-
_)*(_1-_)#end#macro Z(_1 _ __)union{P(_)P(-_)R(y-z-1_)translate.1*_1-y*8pigment{
rgb<S(7)S(5)S(3)>}}#if(_1)Z(_1-__,_,__)#end#end Z(10x*-2,.2)camera{rotate x*90}


Post a reply to this message

From: Slime
Subject: Re: modulo / math funktions
Date: 30 Oct 2001 10:36:52
Message: <3bdec914$1@news.povray.org>
Ah, it's much as I suspected. That's pretty cool.

Notice that this
> does not work properly for functions with zero gradients; you should
detect
> that and deal with it appropriately.


How would it be possible to have a point on the surface of the object with
zero gradient in any direction? Unless the function were something like
function (x,y,z) {0}... where every point of the function is part of the
surface, which would be sort of a strange case...

--
- Slime
[ http://www.slimeland.com/ ]
[ http://www.slimeland.com/images/ ]
"Ron Parker" <ron### [at] povrayorg> wrote in message
news:slr### [at] fwicom...
> On Tue, 30 Oct 2001 09:44:11 -0500, Dave Dunn wrote:
> >
> >
> > Slime wrote:
> >
> >> >   "How do I calculate the normal vector of an isosurface function at
a
> >> > certain point <x,y,z>?", for example.
> >>
> >> Now *there's* a question that's been plaguing me for a while. I'll ask
it
> >> later. =)
> >
> > I'll be watching for the answer to that one myself, as it is holding up
> > isosurface support for POVGUI. I suspect it involves using trace...
>
> Well, if you know how to take the derivative of the function, you just use
> the gradient vector, which is < df/dx, df/dy, df/dz > where "d" is really
> the lowercase delta we use to indicate partial derivatives.
>
> Since we're talking about arbitrary functions here, you can approximate
the
> gradient by using this:
>
> #declare d = 1e-5; //(some small number; POV uses the accuracy value)
> #declare Gradient=vnormalize(<F(X+d,Y,Z),F(X,Y+d,Z),F(X,Y,Z+d)>-F(X,Y,Z));
>
> This is what POV does.  As the comment says, we use the value you
specified
> for the accuracy of the isosurface to do the computation.  Notice that
this
> does not work properly for functions with zero gradients; you should
detect
> that and deal with it appropriately.
>
> --
> #macro R(L P)sphere{L __}cylinder{L P __}#end#macro P(_1)union{R(z+_
z)R(-z _-z)
> R(_-z*3_+z)torus{1__ clipped_by{plane{_ 0}}}translate z+_1}#end#macro
S(_)9-(_1-
> _)*(_1-_)#end#macro Z(_1 _
__)union{P(_)P(-_)R(y-z-1_)translate.1*_1-y*8pigment{
> rgb<S(7)S(5)S(3)>}}#if(_1)Z(_1-__,_,__)#end#end Z(10x*-2,.2)camera{rotate
x*90}


Post a reply to this message

From: Ron Parker
Subject: Re: modulo / math funktions
Date: 30 Oct 2001 10:45:52
Message: <slrn9ttiph.n34.ron.parker@fwi.com>
On Tue, 30 Oct 2001 10:35:04 -0500, Slime wrote:
> Ah, it's much as I suspected. That's pretty cool.
> 
> Notice that this
>> does not work properly for functions with zero gradients; you should
> detect
>> that and deal with it appropriately.
> 
> 
> How would it be possible to have a point on the surface of the object with
> zero gradient in any direction?

Nobody said it has to be a point on the surface, did they?  I suppose it's
implied by the word "normal" but I thought I'd put the warning out there 
anyway.

By the way, the gradient is a direction, so the phrase "zero gradient in
any direction" is meaningless.

-- 
#local R=<7084844682857967,0787982,826975826580>;#macro L(P)concat(#while(P)chr(
mod(P,100)),#local P=P/100;#end"")#end background{rgb 1}text{ttf L(R.x)L(R.y)0,0
translate<-.8,0,-1>}text{ttf L(R.x)L(R.z)0,0translate<-1.6,-.75,-1>}sphere{z/9e3
4/26/2001finish{reflection 1}}//ron.parker@povray.org My opinions, nobody else's


Post a reply to this message

From: Slime
Subject: Re: modulo / math funktions
Date: 30 Oct 2001 11:01:00
Message: <3bdecebc$1@news.povray.org>
> By the way, the gradient is a direction, so the phrase "zero gradient in
> any direction" is meaningless.

Oops, I meant "a derivative of zero in all directions."

- Slime
[ http://www.slimeland.com/ ]
[ http://www.slimeland.com/images/ ]


Post a reply to this message

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