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. A slider unlocks when its constant appears in the equations, the limits, the camera paths, the texture or the background; a constant can also be defined from the ones before it (e.g. B = A/10).
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)

The Steps slider sets the resolution of the mesh: the number of samples taken along each parameter. The slider stops at 1000: for more, type the value in the field next to it (up to about 2000 on desktop and 1500 on mobile devices, fewer on multi-mesh surfaces). In Ray Marching it sets the ray-marching accuracy instead (see the Ray Marching section).

 

The Solid Curve Sub-tab

The Parametric tab holds two sub-tabs: Surface, with the equations described above, and Solid Curve, which draws a tube around a curve.

A solid curve is built around its curve: the curve is truly 4D, but the cross-sections stay round, with no 4D deformation, so that the curve is easy to follow. A tube in the full sense is a true surface seen in 4D, deformed by the 4D view like any other: it is written in the Surface sub-tab, with equations in u and v.

Clicking the sub-tab you are already on reloads its default surface.

 

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:

The full syntax, with the variables available to the rule, is in the Script Guide.


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