POV-Ray : Documentation : 2.7.9.1 Float functions and macros
 POV-Ray 3.6 Documentation Online View

2.7.9.1 Float functions and macros

`even(N)`. A function to test whether N is even, returns 1 when true, 0 when false.
Parameters

• `N` = Input value

`odd(N)`. A function to test whether N is odd, returns 1 when true, 0 when false.
Parameters

• `N` = Input value

`Interpolate(GC, GS, GE, TS, TE, Method)`. Interpolation macro, interpolates between the float values `TS` and `TE`. The method of interpolation is cosine, linear or exponential. The position where to evaluate the interpolation is determined by the position of `GC` in the range `GS` - `GE`. See example.
Parameters:

• `GC` = global current, float value within the range GS - GE
• `GS` = global start
• `GE` = global end
• `TS` = target start
• `TE` = target end
• `Method` = interpolation method, float value:
• `Method` < 0 : exponential, using the value of Method as exponent.
• `Method` = 0 : cosine interpolation.
• `Method` > 0 : exponential, using the value of Method as exponent.
• `Method` = 1 : linear interpolation,

Example:

```  #declare A = Interpolate(0.5, 0, 1, 0, 10, 1);
#debug str(A,0,2)
// result A = 5.00

#declare A = Interpolate(0.0,-2, 2, 0, 10, 1);
#debug str(A,0,2)
// result A = 5.00

#declare A = Interpolate(0.5, 0, 1, 0, 10, 2);
#debug str(A,0,2)
// result A = 2.50
```

`Mean(A)`. A macro to compute the average of an array of values.
Parameters:

• `A` = An array of float or vector values.

`Std_Dev(A, M)`. A macro to compute the standard deviation.
Parameters:

• `A` = An array of float values.
• `M` = Mean of the floats in the array.

`GetStats(ValArr)`. This macro declares a global array named "`StatisticsArray`" containing: N, Mean, Min, Max, and Standard Deviation
Parameters:

• `A` = An array of float values.

`Histogram(ValArr, Intervals)`. This macro declares a global, 2D array named "`HistogramArray`". The first value in the array is the center of the interval/bin, the second the number of values in that interval.
Parameters:

• `ValArr` = An array with values.
• `Intervals` = The desired number of intervals/bins.

`sind(v), cosd(v), tand(v), asind(v), acosd(v), atan2d(a, b)`. These functions are versions of the trigonometric functions using degrees, instead of radians, as the angle unit.
Parameters:
The same as for the analogous built-in trig function.

`max3(a, b, c)`. A function to find the largest of three numbers.
Parameters:

• `a, b, c` = Input values.

`min3(a, b, c)`. A function to find the smallest of three numbers.
Parameters:

• `a, b, c` = Input values.

`f_sqr(v)`. A function to square a number.
Parameters:

• `v` = Input value.

`sgn(v)`. A function to show the sign of the number. Returns -1 or 1 depending on the sign of v.
Parameters:

• `v` = Input value.

`clip(V, Min, Max)`. A function that limits a value to a specific range, if it goes outside that range it is "clipped". Input values larger than `Max` will return `Max`, those less than `Min` will return `Min`.
Parameters:

• `V` = Input value.
• `Min` = Minimum of output range.
• `Max` = Maximum of output range.

`clamp(V, Min, Max)`. A function that limits a value to a specific range, if it goes outside that range it is "clamped" to this range, wrapping around. As the input increases or decreases outside the given range, the output will repeatedly sweep through that range, making a "sawtooth" waveform.
Parameters:

• `V` = Input value.
• `Min` = Minimum of output range.
• `Max` = Maximum of output range.

`adj_range(V, Min, Max)`. A function that adjusts input values in the range [0, 1] to a given range. An input value of 0 will return `Min`, 1 will return `Max`, and values outside the [0, 1] range will be linearly extrapolated (the graph will continue in a straight line).
Parameters:

• `V` = Input value.
• `Min` = Minimum of output range.
• `Max` = Maximum of output range.

`adj_range2(V, InMin, InMax, OutMin, OutMax)`. Like `f_range()`, but adjusts input values in the range `[InMin, InMax]` to the range `[OutMin, OutMax]`.
Parameters:

• `V` = Input value.
• `InMin` = Minimum of input range.
• `InMax` = Maximum of input range.
• `OutMin` = Minimum of output range.
• `OutMax` = Maximum of output range.