The language has three kinds of functions. The built-in functions are reserved words that the parser evaluates at once while it reads the scene (sin, vlength, concat). A user-defined function is an identifier declared with function; it is compiled to small programs that the renderer also runs for each point, which is why isosurfaces and function patterns use them. The standard include files add more functions and many macros. This page lists all three, with the constants and variables that the language provides. How an expression is built from them is on Expressions, vectors and identifiers; the words are listed with a short meaning on Reserved words.
Float functions
Each of these returns one float. Arguments are written in parentheses and separated by commas. x and y are float expressions, s a string expression, v a vector. A function that takes one float argument reads it as a full expression (so abs(a < b) is valid); the other functions read each argument at the sum layer and need parentheses around a comparison.
| Function | Result | Notes |
|---|---|---|
abs(x) | absolute value | |
acos(x) | arc cosine in radians | a value outside -1 to 1 gives the warning Domain error in acos. and is clamped to that range |
acosh(x) | inverse hyperbolic cosine | |
asc(s) | the code of the first character | 0 for the empty string |
asin(x) | arc sine in radians | clamped like acos (Domain error in asin.) |
asinh(x) | inverse hyperbolic sine | |
atan(x) | arc tangent in radians, -pi/2 to pi/2 | |
atan2(y, x) | the angle of the point (x, y) in radians, -pi to pi | both zero is the error Domain error in atan2! |
atanh(x) | inverse hyperbolic tangent | |
bitwise_and(a, b) | bitwise AND | the arguments are cut to integers |
bitwise_or(a, b) | bitwise OR | |
bitwise_xor(a, b) | bitwise exclusive OR | |
ceil(x) | the smallest integer not below x | |
cos(x) | cosine of an angle in radians | |
cosh(x) | hyperbolic cosine | |
defined(Name) | 1 if the name is declared, else 0 | an array element or dictionary entry can be tested; no error for an unknown name |
degrees(x) | radians to degrees | |
dimension_size(A, d) | the number of elements in dimension d of array A | d counts from 1; a dimension that does not exist gives 0 and a warning |
dimensions(A) | the number of dimensions of array A | |
div(x, y) | the quotient with the fraction cut off (towards zero) | |
exp(x) | e to the power x | |
file_exists(s) | 1 if a file of that name can be found, else 0 | the search is the one of #fopen ... read (current directory, library paths) |
floor(x) | the largest integer not above x | |
inside(Object, v) | 1 if the point v is inside the solid object, else 0 | the first argument must be an object identifier (Object identifier expected.) and a solid one (Solid object identifier expected. for a patch) |
int(x) | the integer part, cut towards zero | |
ln(x) | natural logarithm | x of 0 or less is the error ln of negative number |
log(x) | logarithm to base 10 | x of 0 or less is an error |
max(x, y) | the larger value | one or two arguments in the language (with one, the result is that argument); inside a function body two or more are needed |
min(x, y) | the smaller value | as max |
mod(x, y) | the remainder of x / y, with the sign of x | C fmod: mod(-7, 3) is -1 |
pow(x, y) | x to the power y | pow(0, 0) is the error Domain error. |
radians(x) | degrees to radians | |
rand(stream) | the next random number of a stream, between 0 and 1 | stream is a value of seed; another number is the error Illegal random number generator. |
seed(n) | starts a new random stream with the start value n and returns its number | two streams with the same n give the same numbers |
select(v, a, b [, c]) | with three arguments: a when v is below 0, else b. With four: a below 0, b at exactly 0, c above 0 | no tolerance is used in the comparison with 0 |
sin(x) | sine of an angle in radians | |
sinh(x) | hyperbolic sine | |
sqrt(x) | square root | a negative x is the error sqrt of negative number |
strcmp(s1, s2) | 0 if the strings are equal, else the difference of the first two characters that differ | negative if s1 sorts first |
strlen(s) | the number of characters | |
tan(x) | tangent of an angle in radians | |
tanh(x) | hyperbolic tangent | |
val(s) | the number at the start of a string | C atof: val("12.5abc") is 12.5, val("abc") is 0 |
vdot(v1, v2) | the dot product | |
vlength(v) | the length of a vector | |
sum, prod | sum and product over a range | only inside a function body (see below). Outside a body the parser reads the word but no arguments, so sum(1, 2) stops at the parenthesis |
sqr is a reserved word, but it is not a function: a call such as sqr(2) stops the parse, both in expressions and in function bodies. sqr only has a meaning as a function type of julia_fractal. For a square, write x*x or pow(x, 2) (the include file math.inc has f_sqr and VSqr).
#debug concat(str(abs(-2.5),0,1), " ", str(ceil(1.2),0,0), " ", str(floor(-1.2),0,0), " ", str(int(-1.7),0,0), " ", str(div(7,2),0,0), " ", str(mod(7,3),0,0), " ", str(mod(-7,3),0,0), " ", str(pow(2,10),0,0), " ", str(sqrt(16),0,0), "\n")
#debug concat(str(exp(1),0,4), " ", str(ln(10),0,4), " ", str(log(1000),0,1), " ", str(min(3,1),0,0), " ", str(max(3,1),0,0), " ", str(max(3),0,0), "\n")
#debug concat(str(select(-1, 10, 20, 30),0,0), str(select(0, 10, 20, 30),0,0), str(select(1, 10, 20, 30),0,0), " ", str(select(-1, 10, 20),0,0), str(select(0, 10, 20),0,0), str(select(1, 10, 20),0,0), "\n")
#debug concat(str(bitwise_and(12, 10),0,0), " ", str(bitwise_or(12, 10),0,0), " ", str(bitwise_xor(12, 10),0,0), "\n")
#debug concat(str(sin(radians(30)),0,3), " ", str(cos(pi),0,3), " ", str(tan(radians(45)),0,3), " ", str(degrees(asin(1)),0,1), " ", str(degrees(acos(0)),0,1), " ", str(degrees(atan(1)),0,1), " ", str(degrees(atan2(1, 1)),0,1), " ", str(degrees(atan2(1, -1)),0,1), "\n")
#debug concat(str(sinh(1),0,4), " ", str(cosh(1),0,4), " ", str(tanh(1),0,4), " ", str(asinh(1),0,4), " ", str(acosh(2),0,4), " ", str(atanh(0.5),0,4), "\n")
#declare Rs = seed(42);
#declare Rt = seed(42);
#declare R1 = rand(Rs);
#declare R2 = rand(Rt);
#debug concat(str((R1 = R2), 0, 0), " ", str(((R1 >= 0) & (R1 < 1)), 0, 0), " ", str((rand(Rs) != R1), 0, 0), "\n")
2.5 2 -2 -1 3 1 -1 1024 4, 2.7183 2.3026 3.0 1 3 3, 102030 102020, 8 14 6, 0.500 -1.000 1.000 90.0 90.0 45.0 45.0 135.0, 1.1752 1.5431 0.7616 0.8814 1.3170 0.5493 and 1 1 1. The two streams that start from 42 give the same first number, which is in [0, 1), and the second number of a stream differs from the first. max(3) with one argument returns the argument.Vector functions
These return a vector with three components. Arguments that are vectors accept anything that Parse_Vector reads: a float is repeated, and a 2-vector is padded.
| Function | Result | Notes |
|---|---|---|
vaxis_rotate(v, axis, angle) | v rotated about the axis vector by angle degrees | |
vcross(v1, v2) | the cross product | |
vnormalize(v) | v scaled to length 1 | the zero vector gives the zero vector and, from language version 3.5, the warning Normalizing zero-length vector. |
vrotate(v, angles) | v rotated by the angles in degrees about x, y and z (the same order as rotate) | |
vturbulence(lambda, omega, octaves, v) | the turbulence displacement of the point v, as used by the turbulence modifier | octaves is limited to 1 to 10 |
trace(Object, origin, direction [, N]) | the point where a ray from origin along direction first hits the object, or <0, 0, 0> when it misses | the object must be an object identifier. If a fourth argument is given it must be an existing vector identifier; it receives the surface normal at the hit point (the zero vector on a miss) |
min_extent(Object) | the lower corner of the bounding box of an object | an argument that is not an object identifier gives <0, 0, 0> |
max_extent(Object) | the upper corner of the bounding box of an object | for a pigment, normal or density that is based on an image or a DF3 file, the pixel width and height of the image, or the three sizes of the file |
#declare Ball = sphere { 0, 1 }
#declare Box1 = box { <-1,-2,-3>, <4,5,6> }
#debug concat(str(vlength(<3,4,0>),0,1), " ", str(vdot(<1,2,3>,<4,5,6>),0,0), " ", vstr(3, vcross(<1,0,0>,<0,1,0>), ",", 0, 0), " ", vstr(3, vnormalize(<0,3,4>), ",", 0, 2), "\n")
#debug concat(vstr(3, vrotate(<1,0,0>,<0,0,90>), ",", 0, 2), " ", vstr(3, vaxis_rotate(<1,0,0>,<0,1,0>,90), ",", 0, 2), "\n")
#declare Normal = <0, 0, 0>;
#declare Hit = trace(Ball, <0,0,-5>, <0,0,1>, Normal);
#debug concat(vstr(3, Hit, ",", 0, 2), " ", vstr(3, Normal, ",", 0, 2), "\n")
#declare Miss = trace(Ball, <0,5,-5>, <0,0,1>);
#debug concat(vstr(3, Miss, ",", 0, 1), "\n")
#debug concat(vstr(3, min_extent(Box1), ",", 0, 0), " ", vstr(3, max_extent(Box1), ",", 0, 0), "\n")
#debug concat(str(inside(Ball, <0.5,0,0>),0,0), str(inside(Ball, <2,0,0>),0,0), "\n")
5.0 32 0,0,1 0.00,0.60,0.80, 0.00,1.00,0.00 0.00,0.00,-1.00, 0.00,0.00,-1.00 0.00,0.00,-1.00, 0.0,0.0,0.0, -1,-2,-3 4,5,6 and 10. The ray along +z from z = -5 hits the unit sphere at <0, 0, -1>, where the normal points back at the viewer.String functions
These return a string. They are described in full, with a checked example, on Expressions, vectors and identifiers.
| Function | Result |
|---|---|
chr(n) | the character with code n (0 to 65535) |
concat(s1, s2, ...) | the strings joined |
datetime(days [, format]) | a date and time, from a number of days since 2000-01-01 (UTC) |
str(x, width, decimals) | a number as text |
strlwr(s), strupr(s) | lower and upper case |
substr(s, start, length) | a part of a string, from character start (counting from 1) |
vstr(n, v, sep, width, decimals) | a vector as text |
Constants and built-in variables
The words below are reserved: they cannot be redeclared. They need no parentheses.
| Name | Value |
|---|---|
pi | 3.14159265358979 |
tau | 2 pi, 6.28318530717959 |
true, yes, on | 1 |
false, no, off | 0 |
version | the language version as a float (3.8 for a 3.8 scene; after #version 3.7; it is 3.7). Inside a #version directive it is the version value that was set last, which at the start is the version of the program, so #version version; at the top of a scene gives 3.8 (checked) |
clock | the animation clock; 0 in a still image |
clock_on | 1 in an animation, 0 in a still image |
now | the current date and time as a number of days (with fractions) since 2000-01-01 00:00 UTC; datetime(now) prints it. It changes at each use |
x, y, z | the unit vectors <1,0,0>, <0,1,0>, <0,0,1> |
t | <0, 0, 0, 1> |
u, v | <1, 0> and <0, 1> |
The front end declares these float identifiers before it hands the scene to the parser. They are ordinary identifiers (they can be hidden or redeclared), so a scene can use them without any declaration. The animation values are set for each frame; for a still image they are 0, except for the image size.
| Name | Value |
|---|---|
clock_delta | the step of the clock from one frame to the next: (final clock - initial clock) / (final frame - initial frame) |
final_clock | the clock of the last frame (+KF, Final_Clock) |
final_frame | the number of the last frame (+KFF) |
frame_number | the number of the frame being rendered |
initial_clock | the clock of the first frame (+KI) |
initial_frame | the number of the first frame (+KFI) |
image_width | the image width in pixels (+W) |
image_height | the image height in pixels (+H) |
Checked with the program. For a still image rendered with +W8 +H8 they gave clock=0.000 clock_on=0 clock_delta=0.000, frame_number=0 initial_frame=0 final_frame=0, initial_clock=0.000 final_clock=0.000 and image_width=8 image_height=8. With the options +KFI1 +KFF4 +KI0 +KF1 +SF2 +EF2 (frames 1 to 4, clock 0 to 1, only frame 2 rendered) the same scene printed clock=0.333 clock_on=1 clock_delta=0.333, frame_number=2 initial_frame=1 final_frame=4, initial_clock=0.000 final_clock=1.000 and the image size.
User-defined functions
A function is declared with #declare Name = function ... (or #local). The type of the result decides the kind of identifier: a function with one float result is a float function; the forms that return several numbers give a vector function. A function is called by its name with arguments in parentheses. A function can be used in an expression like any built-in function, and also wherever the renderer needs a function of position: in an isosurface, a parametric surface, a function pattern and so on. A function cannot be redeclared with #declare (use #undef first), and a function cannot call itself.
| Form | Parameters | Result |
|---|---|---|
function { expr } | three: x, y, z | a float |
function (p1, p2, ...) { expr } | the listed names (at least one, at most 56); a name is an identifier or x, y, z, u, v | a float |
function { internal(n) } | three, then the extra parameters of the internal function number n (see below) | a float |
function { pattern { ... } } | three: x, y, z | a float: the value of the pattern at the point. Only patterns that need no surface information work (not slope, aoi, uv_mapping) |
function { pigment { ... } } | three | a vector function; the five components of the colour at the point |
function { spline { ... } } | one: the parameter of the spline | a vector function with 2 to 5 components, as many as the spline has |
function { transform { ... } } | three | a vector function with three components: the point moved by the transform |
The arguments of a call are float expressions. A call must give exactly as many arguments as the function has parameters; a call with fewer or more is a parse error (Expected 'numeric expression', ) found instead or No matching ), ...). pattern, pigment, spline and transform functions cannot have a parameter list (Function parameters for pattern functions are not allowed.). A vector function is used where a vector is expected, or with .x, .red and so on after the call.
The body of a function
The body is not an ordinary expression: it is compiled by its own parser (parser_functions.cpp, fncode.cpp). It reads a smaller language:
| In the body | Meaning |
|---|---|
numbers, pi, tau, clock | constants (clock has the value of the frame being parsed) |
the parameter names, and x, y, z, u, v | the arguments of the call |
| a float identifier | its value at the time the function is declared (later changes do not matter) |
operators + - * /, unary + and -, < <= = != >= >, & |, parentheses | the same precedence as in the language (see Expressions), but without parentheses around comparisons and logical operators: x > 1 & x < 3 is valid. There is no ! and no ? :; use select |
sin cos tan asin acos atan sinh cosh tanh asinh acosh atanh abs radians degrees div int floor ceil sqrt exp ln log atan2 pow mod | as the built-in functions |
min, max | two or more arguments |
select | three or four arguments, as the built-in function |
sum(i, from, to, expr), prod(i, from, to, expr) | the sum or the product of expr for i = from, from + 1, ... up to and including to. Exactly four arguments |
| a call of another user function | a float function declared earlier, as in F1(x) + y |
The other built-in functions (vlength, strlen, bitwise_and, rand, file_exists, trace and so on) are not available in a body, and neither is sqr. The body is read once, at the declaration; it is not run then.
#declare F1 = function(x) { x * x + 1 }
#declare F2 = function(x, y) { F1(x) + y }
#declare F3 = function { x + y*z }
#declare F5 = function(x) { sum(i, 1, 4, i * x) }
#declare F6 = function(x) { prod(i, 1, 4, x + i) }
#declare F8 = function(x) { x > 1 & x < 3 }
#declare F9 = function(x) { min(x, 2, 10) + max(x, 2) + abs(0 - x) + select(x - 1, -1, 0, 1) }
#debug concat(str(F1(3),0,0), " ", str(F2(3,1),0,0), " ", str(F3(1,2,3),0,0), " ", str(F5(2),0,0), " ", str(F6(1),0,0), " ", str(F8(2),0,0), str(F8(5),0,0), " ", str(F9(3),0,0), "\n")
#declare FP = function { pattern { checker } }
#declare FC = function { pigment { rgb <0.1, 0.2, 0.3> } }
#declare FS = function { spline { linear_spline 0, <0,0,0>, 1, <1,2,3> } }
#declare FT = function { transform { translate <1, 2, 3> } }
#debug concat(str(FP(0.5,0.5,0.5),0,1), str(FP(1.5,0.5,0.5),0,1), " ", vstr(5, FC(0,0,0), ",", 0, 1), " ", vstr(3, FS(0.5), ",", 0, 1), " ", vstr(3, FT(1,1,1), ",", 0, 1), "\n")
10 11 7 20 120 10 9 and 0.01.0 0.1,0.2,0.3,0.0,0.0 0.5,1.0,1.5 2.0,3.0,4.0. F5(2) is 2+4+6+8, F6(1) is 2*3*4*5, and F8 is true between 1 and 3. The checker pattern is 0 in one cell and 1 in the next.Internal functions and functions.inc
function { internal(n) } binds one of the surfaces and noise functions that are built into the renderer (a table in source/vm/fnintern.cpp). The include file functions.inc declares each of them under a readable name. All of them take x, y, z first, then the extra parameters of the table. A surface function is meant for an isosurface: the surface lies where the value is 0, or at the threshold. For most of them the first extra parameter is the field strength, a factor on the value. The meaning of each extra parameter is in the comments of functions.inc.
| Name | internal number | Extra parameters |
|---|---|---|
f_algbr_cyl1 | 0 | 5 |
f_algbr_cyl2 | 1 | 5 |
f_algbr_cyl3 | 2 | 5 |
f_algbr_cyl4 | 3 | 5 |
f_bicorn | 4 | 2 |
f_bifolia | 5 | 2 |
f_blob | 6 | 5 |
f_blob2 | 7 | 4 |
f_boy_surface | 8 | 2 |
f_comma | 9 | 1 |
f_cross_ellipsoids | 10 | 4 |
f_crossed_trough | 11 | 1 |
f_cubic_saddle | 12 | 1 |
f_cushion | 13 | 1 |
f_devils_curve | 14 | 1 |
f_devils_curve_2d | 15 | 6 |
f_dupin_cyclid | 16 | 6 |
f_ellipsoid | 17 | 3 |
f_enneper | 18 | 1 (declared deprecated when the scene runs at a version below 3.8: it was broken before) |
f_flange_cover | 19 | 4 |
f_folium_surface | 20 | 3 |
f_folium_surface_2d | 21 | 6 |
f_glob | 22 | 1 |
f_heart | 23 | 1 |
f_helical_torus | 24 | 10 |
f_helix1 | 25 | 7 |
f_helix2 | 26 | 7 |
f_hex_x | 27 | 1 |
f_hex_y | 28 | 1 |
f_hetero_mf | 29 | 6 |
f_hunt_surface | 30 | 1 |
f_hyperbolic_torus | 31 | 3 |
f_isect_ellipsoids | 32 | 4 |
f_kampyle_of_eudoxus | 33 | 3 |
f_kampyle_of_eudoxus_2d | 34 | 6 |
f_klein_bottle | 35 | 1 |
f_kummer_surface_v1 | 36 | 1 |
f_kummer_surface_v2 | 37 | 4 |
f_lemniscate_of_gerono | 38 | 1 |
f_lemniscate_of_gerono_2d | 39 | 6 |
f_mesh1 | 40 | 5 |
f_mitre | 41 | 1 |
f_nodal_cubic | 42 | 1 |
f_odd | 43 | 1 |
f_ovals_of_cassini | 44 | 4 |
f_paraboloid | 45 | 1 |
f_parabolic_torus | 46 | 3 |
f_ph | 47 | 0: the polar angle (from the y axis) |
f_pillow | 48 | 1 |
f_piriform | 49 | 1 |
f_piriform_2d | 50 | 7 |
f_poly4 | 51 | 5 |
f_polytubes | 52 | 6 |
f_quantum | 53 | 1 |
f_quartic_paraboloid | 54 | 1 |
f_quartic_saddle | 55 | 1 |
f_quartic_cylinder | 56 | 3 |
f_r | 57 | 0: the distance from the origin |
f_ridge | 58 | 6 |
f_ridged_mf | 59 | 6 |
f_rounded_box | 60 | 4 |
f_sphere | 61 | 1: the radius; the value is the distance to the surface along the radius |
f_spikes | 62 | 5 |
f_spikes_2d | 63 | 4 |
f_spiral | 64 | 6 |
f_steiners_roman | 65 | 1 |
f_strophoid | 66 | 4 |
f_strophoid_2d | 67 | 7 |
f_superellipsoid | 68 | 2 |
f_th | 69 | 0: the azimuth angle |
f_torus | 70 | 2: the major and the minor radius |
f_torus2 | 71 | 3 |
f_torus_gumdrop | 72 | 1 |
f_umbrella | 73 | 1 |
f_witch_of_agnesi | 74 | 2 |
f_witch_of_agnesi_2d | 75 | 6 |
f_noise3d | 76 | 0: the noise value in the range 0 to 1 |
f_noise_generator | 78 | 1: the number of the noise generator |
Number 77 is the pattern function (function { pattern { ... } } uses it). The same file also declares these functions, written in the language:
| Name | Definition |
|---|---|
f_snoise3d | 2*f_noise3d(x, y, z) - 1: noise in the range -1 to 1 |
f_agate, f_boxed, f_brick, f_checker, f_crackle, f_cylindrical, f_granite, f_leopard, f_marble, f_onion, f_planar, f_radial, f_ripples, f_spherical, f_waves, f_wood, f_wrinkles | function { pattern { name } } for the pattern of the same name |
f_gradientX, f_gradientY, f_gradientZ | function { pattern { gradient x } } and the same for y and z |
f_mandel, f_spiral1, f_spiral2 | pattern { mandel 25 }, pattern { spiral1 2 }, pattern { spiral2 2 } |
f_hexagon | function { pigment { hexagon color rgb 0, color rgb 0.5, color rgb 1 } }, a vector function |
f_bozo, f_bumps, f_spotted | f_noise3d(x, y, z) |
f_dents | pow(f_noise3d(x, y, z), 3) |
f_sine_wave(val, amplitude, frequency) | sin(x*z*pi)*y |
f_scallop_wave(val, amplitude, frequency) | abs(sin(x*z*pi)*y) |
eval_pigment(pigment, vector) (macro) | the colour of a pigment at a point, as a five-component vector |
The patterns that the file notes as not implemented (average, density_file, image_pattern, object, pigment_pattern, quilted and the fractal variants) need parameters that a fixed definition cannot hold; declare your own function with pattern { ... } for them. A function of this file can be used as the function of an isosurface, parametric or function pattern, or called in an expression.
#include "functions.inc"
#debug concat(str(f_sphere(3,0,0,2),0,3), " ", str(f_torus(3,0,0,2,0.5),0,3), " ", str(f_r(3,4,0),0,3), " ", str(f_checker(0.5,0.5,0.5),0,1), str(f_checker(1.5,0.5,0.5),0,1), " ", str(f_sine_wave(0.25, 2, 1),0,3), "\n")
isosurface { function { f_sphere(x, y, z, 1) } contained_by { sphere { 0, 1.5 } } threshold 0 }
1.000 0.500 5.000 0.01.0 1.414 and adds an isosurface that is the unit sphere. f_sphere(3,0,0,2) is the distance 1 from the point to a sphere of radius 2.math.inc
#include "math.inc" declares these functions (written with function, so they also work in function bodies) and macros. A macro that ends with an expression can be used inside an expression, because the macro text is read at the place of the call; the statistics and gradient macros also run directives first.
| Name | Kind | Meaning |
|---|---|---|
sind(x), cosd(x), tand(x) | function | sine, cosine and tangent of an angle in degrees |
asind(x), acosd(x), atand(x), atan2d(y, x) | function | the inverse functions, giving degrees |
max3(x, y, z), min3(x, y, z) | function | the largest and the smallest of three values |
even(x), odd(x) | function | 1 or 0 for an even or an odd integer |
f_sqr(x) | function | x squared |
sgn(x) | function | -1, 0 or 1 for the sign of x |
clip(x, min, max) | function | x limited to the range |
clamp(x, min, max) | function | x wrapped into the range |
adj_range(x, min, max) | function | a value from 0 to 1 mapped to the range |
adj_range2(x, min, max, newmin, newmax) | function | a value in one range mapped to another |
Interpolate(GC, GS, GE, TS, TE, Method) | macro | the value in the target range TS to TE that matches GC in the range GS to GE; method 0 is a cosine curve, a positive method is the exponent of a power curve (1 is linear) |
Mean(A), Std_Dev(A, M) | macro | mean and standard deviation of the values of an array |
GetStats(A) | macro | prints N, mean, minimum, maximum and standard deviation with #debug, and declares the global array StatisticsArray of those five values |
Histogram(A, Intervals) | macro | declares the global array HistogramArray: for each interval, its centre and the number of values in it |
VSqr(V), VPow(V, P), VPow5D(V, P) | macro | the components squared, or raised to a power |
VEq(V1, V2), VEq5D(V1, V2) | macro | 1 if the vectors are equal |
VZero(V), VZero5D(V) | macro | 1 if the vector is all zeros |
VLength5D(V), VNormalize5D(V), VDot5D(V1, V2) | macro | length, normalised copy and dot product over five components |
VCos_Angle(V1, V2), VAngle(V1, V2), VAngleD(V1, V2) | macro | cosine, and the angle in radians or in degrees, between two vectors |
VRotation(V1, V2, Axis), VRotationD(...) | macro | the signed angle from V1 to V2 about an axis, in radians or in degrees |
VDist(V1, V2) | macro | the distance between two points |
VPerp_To_Vector(V), VPerp_To_Plane(V1, V2), VPerp_Adjust(V, Axis) | macro | vectors perpendicular to a vector, to two vectors, or to an axis in the plane of the vector and the axis |
VProject_Plane(V, Axis), VProject_Axis(V, Axis) | macro | the projection of a vector on a plane or on an axis |
VMin(V), VMax(V) | macro | the smallest and the largest component |
VWith_Len(V, Len) | macro | a vector in the direction of V with the given length |
SetGradientAccuracy(Value) | macro | sets the step of the numeric derivatives of the next macros (default 0.001) |
fn_Gradient(fn), fn_Gradient_Directional(fn, Dir), fn_Divergence(fx, fy, fz) | macro | give a function: the length of the gradient, the gradient in a direction, and the divergence of a vector field made of three functions |
vGradient(fn, p), vCurl(fx, fy, fz, p) | macro | the gradient and the curl at a point, as vectors |
Divergence(fx, fy, fz, p), Gradient_Length(fn, p), Gradient_Directional(fn, p, Dir) | macro | the divergence, the length of the gradient and the gradient in a direction at a point, as floats |
transforms.inc
#include "transforms.inc" (it includes math.inc) declares macros that build transform blocks. Write them where a transform is wanted: object { Obj Axis_Rotate_Trans(y, 30) }.
| Macro | Meaning |
|---|---|
Shear_Trans(A, B, C) | moves the x axis to A, the y axis to B and the z axis to C, which may deform the object |
Matrix_Trans(A, B, C, D) | the same, with D as the translation: a matrix from four vectors |
Axial_Scale_Trans(Axis, Amt) | stretches by Amt along an axis |
Axis_Rotate_Trans(Axis, Angle) | rotates by an angle in degrees about an axis |
Rotate_Around_Trans(Rotation, Point) | rotates (angles in degrees about x, y and z) about a point |
Reorient_Trans(Axis1, Axis2) | turns the direction Axis1 to the direction Axis2 |
Point_At_Trans(YAxis) | turns the y axis to point along YAxis |
Center_Trans(Object, Axis) | centres the bounding box of the object along the given axes (x, or x+y for two) |
Align_Trans(Object, Axis, Pt) | moves the object so that the side of its bounding box named by the sign of Axis lies at the point Pt |
Spline_Trans(Spline, Time, Sky, Foresight, Banking) | places an object on a spline at a time value so that its z axis points along the spline, with banking in turns |
vtransform(vec, trans) | (macro, returns a value) the vector moved by a transform |
vinv_transform(vec, trans) | the vector moved by the inverse of a transform |
#include "math.inc"
#include "transforms.inc"
#debug concat(str(sind(30),0,3), " ", str(sgn(-5),0,0), str(sgn(0),0,0), str(sgn(7),0,0), " ", str(clip(15,0,10),0,0), " ", str(clamp(12,0,10),0,0), " ", str(VDist(<0,0,0>,<3,4,0>),0,1), " ", str(VAngleD(x,y),0,1), "\n")
#debug concat(vstr(3, vtransform(<1,0,0>, transform { rotate y*90 translate <1,0,0> }), ",", 0, 2), "\n")
0.500 -101 10 2 5.0 90.0 and 1.00,0.00,-1.00. The macros VDist and VAngleD are used inside the expressions of str.Not described
Known, not yet covered
- Reference: the formula and the extra parameters of each internal surface function are only counted here; they are listed in the comments of
functions.incand in the manual (chapter 3.8 ofdoc/html/r3_8.html), and the code is insource/vm/fnintern.cpp. - Reference: which patterns work inside
function { pattern { ... } }was taken from the comments of the parser, not tested for every pattern.