POV-Ray : Newsgroups : povray.general : Fuctions, My two cents : Re: Fuctions, My two cents Server Time
25 Apr 2024 09:14:09 EDT (-0400)
  Re: Fuctions, My two cents  
From: William F Pokorny
Date: 25 Feb 2023 08:29:16
Message: <63fa0d2c$1@news.povray.org>
On 2/25/23 07:39, William F Pokorny wrote:



> Functions return double float values. The values are clipped/confined to 
> a 0-1 range as a ramp wave. This always so in POV-Ray releases. It's 
> true by default in povr, but other ranges are allowed as options.

On grabbing my first coffee it hit me the above statement is a mess. 
Plus I flipped the red and green significance of the .hf kind of grey 
conversion while writing...

---

Functions return one float value or float vectors. The components of the 
float vectors are doubles too - except for (5d) color vectors, which end 
up as single floats. Functions can return any valid double, but 
downstream consumers may not be able to make use of values outside the 
0-1 range.

I believe the vector component values are clamped to a 0-1 range. 
However, as I write this I'm not 100% sure... Can we get a vector 
component value of say 100.0 function to vector and visa versa?

As used in a height_field or image_map the values would end up with the 
ramp_wave (mod) kind of wrapping, but is that happening in the function 
vector return mechanism or elsewhere...?

The wrapping is happening elsewhere!

If I code up:

#declare Fn00 = function { pigment { rgb <222,333,444> } }
#declare Fn01 = function { Fn00(0,0,0).gray }
#declare Fn02 = function { Fn00(0,0,0).hf }

#debug concat("_pt=<", vstr(3, Fn00(0,0,0), ",", 0, 3), ">\n")
#debug concat("_pt=<", vstr(3,
<Fn00(0,0,0).x,Fn00(0,0,0).y,Fn00(0,0,0).z>, ",", 0, 3), ">\n")

#debug concat("Fn00(0,0,0).grey : ",str(Fn01(0,0,0),0,-1)," \n")
#debug concat("Fn00(0,0,0).hf : ",str(Fn02(0,0,0),0,-1)," \n")

and run it in v3.8 beta 2 I get:

Fn00 : 222.000,333.000,444.000>
Fn00 .x .y .z : 222.000,333.000,444.000>
Fn00(0,0,0).grey : 312.687000
Fn00(0,0,0).hf : 222.433426

Interesting. I learned something new.

Bill P.


Post a reply to this message

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