|
![](/i/fill.gif) |
Wasn't it Alain who wrote:
>I don't understand how radial works with non integer frequencies.
>
>Let's take a simple one :
>#declare MyP = pigment{ radial
> frequency F
> phase P
> pigment_map {
> [0.5 Black]
> [0.5 White]}}
>
>I want F to grow from .1 to 10, and I want the Black color to start at the
>fixed position (+x, -z, I don' t care). What is the value of P which achieve
>this ?
>
>It looked simple to me at first, but I must say that I going to give up. Any
>one can help ?
I couldn't get radial itself to behave predictably for non-integer
frequencies, but I've managed to write a pigment function that behaves
in a predictable manner and gives the same results as "radial" for
integer frequencies.
#include "functions.inc"
#declare MyP = pigment{
function {F * (0.5+f_th(z,0,-x)/2/pi)}
pigment_map {
[0.5 Black]
[0.5 White]}}
The "/2/pi" bit compensates for the fact that f_th() returns radians.
The "0.5" compensates for the fact that the implied atan operation
returns negative values in the second hemisphere. We want values between
0.0 and 1.0 rather than between -0.5 and +0.5.
Using "(z,0,-x)" instead of "(x,0,z)" flips the axes, so that the
pattern starts at +x and goes clockwise, like "radial" does, rather than
starting at -z and going anticlockwise.
Note that you won't always see a black/white transition at +x, because
for some values of F the pattern ends on black, and you can't see where
the end black ends and the start black starts. (Similarly, for negative
values of F you can get two whites next to each other).
If you animate with "#declare F=clock*10;" you can see how the starting
point behaves.
Don't try using "phase" to change the starting point because it
interferes with the "0.5" compensation factor.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
![](/i/fill.gif) |