|
 |
On 2/25/25 06:34, Bald Eagle wrote:
> Super. Maybe you can help me understand why I always have to go through a NEW
> form of calisthenics when I cross zero.
> (and as you can see, the pattern function is dirt simple)
If you are working with an equation you wish to use as a pattern, and
the value of y, say, crossing through 0.0 flips or changes the
function's behavior, one must deal with it in some way.
In your particular function there is a flip in behavior due internal
value changes away from zero and another due y changing sign.
Below a yuqk fork scene showing some typical ways for dealing with value
transitions causing unwanted change with your function based pattern.
Some work with official POV-Ray releases too. To reproduce your result,
however, we might need to do something pretty close to what you did! I
didn't try to exactly match your posted result.
// Sample scene. 'yuqk y_cross_0.pov +w1024 +h768 +p +mv3.8'
global_settings { assumed_gamma 1.0 }
#declare VarOrthoMult =
20.0/max(image_width/image_height,image_height/image_width);
#declare Camera01z = camera {
orthographic
location <0,0,-2>
direction z
right VarOrthoMult*x*max(1,image_width/image_height)
up VarOrthoMult*y*max(1,image_height/image_width)
}
// 'odd()' is one of the fake keywords shipped with official
// POV-Ray which the yuqk fork removed.
#include "functions.inc"
#include "munctions.inc"
#local Dummy = M_odd(0.5); // compiling F_odd()
#local EvenOdd = M_odd(0); // Later calls run F_odd internally
#local EvenOdd = F_odd(2); // = 0
#local EvenOdd = F_odd(3); // = 1
#declare Formula1 = function { (y-sin(x))*(y-cos(x)) }
// When y moving through zero flips results, it's typical to use
// pattern value modifiers or similar inbuilt functions.
#if (1) // Call as FnY(0,y/2,0)
#declare FnY = function {
pattern { gradient y triangle_wave }
}
#elseif (0) // Call as FnY(0,y/4,0)
#declare FnY = function {
pattern { gradient y function_interval triangle_wave }
}
#elseif (0) // Call as FnY(0,y/2,0)
#declare FnY = function {
f_triangle_wave(y,0)
}
#elseif (0) // Call as FnY(0,y/4,0)
#declare FnY = function {
f_triangle_wave(y,1)
}
#else
#error "Must pick a definition of function Fny()\n"
#end
#declare Formula2 = function {
pattern {
function { Formula1(x,y,z) }
triangle_wave
frequency 4
}
}
#declare Formula3 = function { // Push y positive
Formula1(x,
select(
F_odd(f_round(y+100+0.5)),
0,
mod(y+100,1),
1-mod(y+100,1)),0)
}
#declare FnLine = function {
select(((Formula2(x,y,z)>-0.1) & (Formula2(x,y,z)<0.1)),
0, 0, 1)
}
plane { -z 0
pigment {
//function { Formula1(x,y,z) }
//function { Formula1(x,FnY(0,y/2,0),z) }
//function { Formula2(x,FnY(0,y/2,0),z) }
function { FnLine( x,FnY(0,y/2,0),z) }
//function { Formula3(x, y,z) }
//raw_wave
color_map {
[-2 rgb <1,0,0>]
[-0.01 rgb 0]
[+0.01 rgb 0]
[+2 rgb <0,1,0>]
}
}
finish { emission 1 }
}
camera { Camera01z }
#if (0)
union {
sphere {<0, 0,0> , 0.1 }
sphere {<0,+1,0> , 0.1 }
sphere {<0,+2,0> , 0.1 }
sphere {<0,-1,0> , 0.1 }
sphere {<0,-2,0> , 0.1 }
pigment { rgb <1,0,0>} finish { emission 1 }
}
#end
Image attached.
Bill P.
Post a reply to this message
Attachments:
Download 'y_cross0.png' (415 KB)
Preview of image 'y_cross0.png'

|
 |