![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
High!
I'm not really sure whether I'm on-topic here or not... but as this
group also deals with programming techniques, I just assumed...
My question: does PoV-Ray allow programming of "discontinuous" functions
(I only dabble in math, so please don't stone me if this is not the
correct terminus!)?
Is it possible to write a function which changes apruptly at certain
values, such as
from x=0 to x=1.5: pow(x, 2)
from x=1.5 to x=7: sqrt(14-x)+3
etc. etc. ?
See you in Khyberspace -
http://home.arcor.de/yadgar/khyberspace/index-e.html
Afghanistan Chronicle: http://home.arcor.de/yadgar/
Yadgar
Now playing: Deimos and Phobos go to Mars (Synergy)
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
hi,
> I'm not really sure whether I'm on-topic here or not... but as this
> group also deals with programming techniques, I just assumed...
I think p.general would be better
> My question: does PoV-Ray allow programming of "discontinuous" functions
> (I only dabble in math, so please don't stone me if this is not the
> correct terminus!)?
>
> Is it possible to write a function which changes apruptly at certain
> values, such as
>
> from x=0 to x=1.5: pow(x, 2)
> from x=1.5 to x=7: sqrt(14-x)+3
> etc. etc. ?
Where would you like to use it? If you want to use it to describe the
postion of an object (in an animation), you can try the following:
#declare f1=function(x){pow(x,2)};
#declare f2=function(x){sqrt(14-x)+3};
#if(x>0 && x<1.5)//correct way to describe interval??
//use f1 to get position
#end
#if(other interval)
//use f2 f1 to get position
#end
I assume it would have the same effect as an discontious function.
Hoping to be of help,
JWV
"Yadgar" <yaz### [at] gmx de> wrote in message
news:411df55b$1@news.povray.org...
> High!
>
> I'm not really sure whether I'm on-topic here or not... but as this
> group also deals with programming techniques, I just assumed...
>
> My question: does PoV-Ray allow programming of "discontinuous" functions
> (I only dabble in math, so please don't stone me if this is not the
> correct terminus!)?
>
> Is it possible to write a function which changes apruptly at certain
> values, such as
>
> from x=0 to x=1.5: pow(x, 2)
> from x=1.5 to x=7: sqrt(14-x)+3
> etc. etc. ?
>
> See you in Khyberspace -
> http://home.arcor.de/yadgar/khyberspace/index-e.html
> Afghanistan Chronicle: http://home.arcor.de/yadgar/
>
> Yadgar
>
> Now playing: Deimos and Phobos go to Mars (Synergy)
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Yadgar nous apporta ses lumieres ainsi en ce 14/08/2004 07:33... :
> High!
>
> I'm not really sure whether I'm on-topic here or not... but as this
> group also deals with programming techniques, I just assumed...
>
> My question: does PoV-Ray allow programming of "discontinuous"
> functions (I only dabble in math, so please don't stone me if this is
> not the correct terminus!)?
>
> Is it possible to write a function which changes apruptly at certain
> values, such as
>
> from x=0 to x=1.5: pow(x, 2)
> from x=1.5 to x=7: sqrt(14-x)+3
> etc. etc. ?
>
> See you in Khyberspace -
> http://home.arcor.de/yadgar/khyberspace/index-e.html
> Afghanistan Chronicle: http://home.arcor.de/yadgar/
>
> Yadgar
>
> Now playing: Deimos and Phobos go to Mars (Synergy)
It's possible but not alway a good solution. If used in an isosurface,
it will lead to infinite gradient. It may be preferable to use an union
of different objects, each modeled acording to a continuous function.
If used to define a path in an animation, it can lead to whatever is
folowing that path to jump around.
In your case use a #switch:
#switch(YourVar)
#range(0,1.5)#declare OutVar=pow(YourVar,1);#break
#range(1.5,7)#declare OutVar=sqrt(14-YourVar)+3;#break
#range(.....
#end
Alain
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
hm, I should be reading about #switch statements. Thanks for the tip!
JWV
"Alain" <aze### [at] qwerty gov> wrote in message
news:411f95d2@news.povray.org...
> Yadgar nous apporta ses lumieres ainsi en ce 14/08/2004 07:33... :
>
> > High!
> >
> > I'm not really sure whether I'm on-topic here or not... but as this
> > group also deals with programming techniques, I just assumed...
> >
> > My question: does PoV-Ray allow programming of "discontinuous"
> > functions (I only dabble in math, so please don't stone me if this is
> > not the correct terminus!)?
> >
> > Is it possible to write a function which changes apruptly at certain
> > values, such as
> >
> > from x=0 to x=1.5: pow(x, 2)
> > from x=1.5 to x=7: sqrt(14-x)+3
> > etc. etc. ?
> >
> > See you in Khyberspace -
> > http://home.arcor.de/yadgar/khyberspace/index-e.html
> > Afghanistan Chronicle: http://home.arcor.de/yadgar/
> >
> > Yadgar
> >
> > Now playing: Deimos and Phobos go to Mars (Synergy)
>
> It's possible but not alway a good solution. If used in an isosurface,
> it will lead to infinite gradient. It may be preferable to use an union
> of different objects, each modeled acording to a continuous function.
> If used to define a path in an animation, it can lead to whatever is
> folowing that path to jump around.
>
> In your case use a #switch:
> #switch(YourVar)
> #range(0,1.5)#declare OutVar=pow(YourVar,1);#break
> #range(1.5,7)#declare OutVar=sqrt(14-YourVar)+3;#break
> #range(.....
> #end
>
> Alain
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Yadgar wrote:
> High!
>
> I'm not really sure whether I'm on-topic here or not... but as this
> group also deals with programming techniques, I just assumed...
>
> My question: does PoV-Ray allow programming of "discontinuous" functions
> (I only dabble in math, so please don't stone me if this is not the
> correct terminus!)?
>
> Is it possible to write a function which changes apruptly at certain
> values, such as
>
> from x=0 to x=1.5: pow(x, 2)
> from x=1.5 to x=7: sqrt(14-x)+3
> etc. etc. ?
Try this:
#declare MinB = 0.0;
#declare MaxB = 1.5;
#declare FnB = function(x) { pow(x, 2) }
#declare MinC = 1.5;
#declare MaxC = 7.0;
#declare FnC = function(x) { sqrt(14 - x) + 3 }
#declare IntervalFn =
function(x) {
select(x - MinB, 0, select(x - MaxB, FnB(x), 0)) +
select(x - MinC, 0, select(x - MaxC, FnC(x), 0))
}
This function will return 0 when x is below 0 or above
(or equal to) 7.
To have it return (e.g.) -x when x is below 0 and (e.g.)
-1 when it is above or equal to 7, you can use this code:
#declare MaxA = 0.0;
#declare FnA = function(x) { -x }
#declare MinB = 0.0;
#declare MaxB = 1.5;
#declare FnB = function(x) { pow(x, 2) }
#declare MinC = 1.5;
#declare MaxC = 7.0;
#declare FnC = function(x) { sqrt(14 - x) + 3 }
#declare MinD = 7.0;
#declare FnD = function(x) { -1 }
#declare IntervalFn =
function(x) {
select(x - MaxA, FnA(x), 0) +
select(x - MinB, 0, select(x - MaxB, FnB(x), 0)) +
select(x - MinC, 0, select(x - MaxC, FnC(x), 0)) +
select(x - MinD, 0, FnD(x))
}
- And (despite what others have said in this thread,)
such functions can sometimes be useful in isosurfaces.
--
Tor Olav
http://subcube.net
http://subcube.com
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |