Skip to content

Documentation / @ripl/3d / parametricNormal

Function: parametricNormal() ​

parametricNormal(surface, u, v): Vector3

Defined in: 3d/src/elements/parametric.ts:181

Approximates a parametric surface's normal at (u, v) from its numeric partial derivatives.

The step is clamped to stay inside the domain at the edges, so a surface defined only on [0, 1] is never sampled outside it.

A surface of revolution collapses to a point at each pole, where the tangents are parallel and the cross product vanishes. Rather than hand back a zero normal — which shades the pole black — this retreats a little way into the domain and takes the normal there, which for a smooth surface is the limit the pole is approaching.

Parameters ​

ParameterTypeDescription
surfaceParametricSurfaceThe surface to differentiate.
unumberThe first parameter.
vnumberThe second parameter.

Returns ​

Vector3

The unit normal, or the up vector for a surface degenerate in both directions.