Parametric Equations


← The 4th Dimension  ·  Contents  ·  Geodesic Flow & Non-Euclidean Geometries →


Parametric equations are translated into GLSL and evaluated directly on the GPU via Qt RHI. Before compilation, the expression parser (based on ExprTk) validates the syntax and resolves constants and constraints. Because the software generates 2-dimensional surfaces embedded in 3D or 4D space, the mathematical definitions must always ultimately reduce to exactly two independent parameters.

 

The 2-Parameter Rule (Four Methods)

You can achieve this reduction to two dimensions using one of the following four methods:

  1. Direct 2D Parametrization: Write the main spatial equations (X, Y, Z, P) directly as functions of exactly two lowercase parameters (u, v).
  2. Constraint Mode: Write the main equations using three lowercase parameters (u, v, w), but bind one of them to the other two by providing an explicit equation in the Constraints tab (e.g., w = f(u, v)).
  3. Composition Mode: Write the main equations using uppercase composite variables (U, V, W). Then, in the Composition tab, define how these uppercase variables are calculated from the base parameters u and v (e.g., U = cos(u)*sin(v)).
    Note: You cannot mix lowercase (u, v, w) and uppercase (U, V, W) spatial variables in the main coordinate equations.
  4. Geodesic Flow: Described in detail in the Geodesic Flow & Non-Euclidean Geometries section.

 

Syntax

Variable Description
u, v, w Main lowercase parametric coordinates.
U, V, W Uppercase composite variables, used in Composition Mode (defined in the Composition tab) and in Geodesic Flow.
A, B, C... F Constants dynamically adjustable via sliders in the Equations panel.
s A dynamic variable controlled by its own slider for structural changes.
pi Constant π (3.14159...).
e Euler's number (2.71828...).
tau Constant τ = 2π (6.28318...).

 

Resolution (Steps)

Within the Equations dock, you will find the Steps slider (and matching input field). This parameter controls the geometric resolution of the generated 3D mesh — the actual number of samples taken along each parameter:

Steps is what actually changes the wireframe density. Because the wireframe simply draws the edges of the polygonal grid, raising or lowering Steps directly makes the wireframe finer or coarser. Moving the slider takes effect live, on parametric surfaces, scripted surfaces, and geodesic flows alike — you do not need to press Run. (In Ray Marching mode the surface is computed per-pixel rather than as a polygon grid, so there Steps drives the ray-marching accuracy instead; see the Ray Marching section.)

Do not confuse Steps with the Density u / Density v controls in the Renderer dock. Those do not change the mesh resolution: they only rebalance the appearance of the two families of coordinate lines. On shapes whose form stretches one parameter much more than the other — long tubes, thin ribbons — the U-lines and V-lines can look visually mismatched (too crowded one way, too sparse the other); Density u/v let you thin out or thicken each family independently to restore a balanced look, without altering the underlying geometry. See Rendering & Textures for details.

 

Cutout (Hiding Parts of a Surface)

A scripted surface can carry an optional cutout section, written in the Script dock between //CUTOUT_BEGIN and //CUTOUT_END. It is a rule, evaluated at every point of the surface, that answers one question: should this point be drawn? Everything the rule rejects simply disappears from view.

The main use is self-intersecting shapes — tubes and ribbons that pass through themselves. Where two branches cross, the walls that end up buried inside the solid are still being drawn even though nothing can be seen of them, and they betray themselves as stray highlights and hard seams along the crossing. A cutout removes precisely those hidden strips and leaves the visible skin untouched.

The test runs on the GPU while the image is drawn, not while the mesh is built, and this is what makes it pleasant to use:

The cutout is part of the surface script and is saved with the preset. Surfaces that do not define one are completely unaffected — the test is not even included in the shader, so it costs nothing. The full syntax, with the variables available to the rule, is in the Script Guide.


← The 4th Dimension  ·  Contents  ·  Geodesic Flow & Non-Euclidean Geometries →