POV-Ray : Newsgroups : povray.newusers : How to use self defined functions as patterns? : Re: How to use self defined functions as patterns? Server Time29 Feb 2024 10:28:02 EST (-0500)
 Re: How to use self defined functions as patterns?
 From: Thorsten Froehlich Date: 4 Apr 2018 08:05:01 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#web.5ac4bed81863261df773ca290%40news.povray.org",
"headline": "Re: How to use self defined functions as patterns?",
"dateCreated": "2018-04-04T12:05:01+00:00",
"datePublished": "2018-04-04T12:05:01+00:00",
"author": {
"@type": "Person",
"name": "Thorsten Froehlich"
}
}
"Kenneth" <kdw### [at] gmailcom> wrote:
> "rastertastic" <nomail@nomail> wrote:
>
> >
> > So basically I'm asking clarification on how to use such self-defined functions
> > like  x + y + z  as patterns with, say, color maps.
>
> Here's a simple example...
>
> #declare Foo = function(x,y){2*x + 2*y}
>
> box{<0,0,0>, <1,1,.01>
> pigment {
>   function {Foo(x,y)}
>        sine_wave // otherwise, a default 'ramp' wave is used
>        color_map{
>               [0 rgb 0]
>               [1 rgb 1]
>               }
>        }
>        }

This just discards the z position of the function.

> BTW, somewhere in the POV-Ray documentation, it states that when using a
> function as a pigment or pigment pattern, the 'image' of the function is
> actually just an infinitely thin slice, taken in the x/y plane (x from 0.0 to
> 1.0, y from 0.0 to 1.0). You can change the location of that slice, though:
>                  #declare Foo = function(x,y){2*(x + 1.7) + 2*y}

It does not say that, the pattern function is three dimensional, not two
dimensional. You are free to not use all three dimensions though.
```