Skip to content

geometry.complexSurface

Summary

geometry.complexSurface samples a complex function over a rectangle in the complex plane. It can draw a flat domain-color plot or use one property of the output as a height field. The geometry retains the real and imaginary samples for inspection.

Syntax

complexSurface(descriptor: ComplexSurfaceDescriptor): Geometry
const plot = wgpu.geometry.complexSurface({ f: (re, im) => [re, im] });

Parameters

Name Type Required Description
descriptor ComplexSurfaceDescriptor Yes Complex callback, input grid, height and coloring options.

Returns

Geometry - Indexed surface with normals, UVs, vertex colors and interleaved [re, im] sample values in vertex order. Manage its references as for other geometry. The same factory is available as Geometry.complexSurface.

Type Details

type ComplexSurfaceDescriptor = {
    f: (re: number, im: number) => [number, number];
    reMin?: number;
    reMax?: number;
    imMin?: number;
    imMax?: number;
    reSegments?: number;
    imSegments?: number;
    height?: "none" | "modulus" | "logModulus" | "real" | "imaginary";
    heightScale?: number;
    heightRange?: [number, number];
    coloring?: DomainColorMode;
    colormap?: BuiltinColormapName | Colormap;
    range?: [number, number];
    plane?: "xy" | "xz" | "yz";
    skipInvalid?: boolean;
    doubleSided?: boolean;
    color?: never;
};
  • Both input axes default to [-2, 2] with 256 subdivisions each. Counts are rounded down and clamped to at least one. The default "xz" plane maps input real and imaginary to X and Z and puts height on Y. The "xy" and "yz" options put height on Z and X, respectively.
  • height defaults to "none" for a flat surface. Use magnitude, natural log magnitude, real part or imaginary part for height. If present, heightRange clamps the chosen finite height to two ordered finite endpoints before multiplication by heightScale, which defaults to 1 and must be finite.
  • coloring defaults to "domain" and follows color.domain. Select a built-in or CPU-sampleable colormap. The defaults are "hsv" for domain and argument coloring and "viridis" for modulus. The modulus color range defaults to the finite sample extent. Use coloring, colormap and range for styling this plot.
  • skipInvalid defaults to true and omits cells touching a non-finite height. With false, non-finite heights use zero. A flat plot uses zero height even when the sampled value is non-finite, and its invalid colors are opaque white. doubleSided defaults to false.

Example

const wgpu = await WasmGPU.create(document.querySelector("canvas"));
const plot = wgpu.geometry.complexSurface({
    f: (re, im) => [re * re - im * im, 2 * re * im],
    reSegments: 32, imSegments: 32,
    height: "modulus", heightScale: 0.25
});
console.log(plot.valueComponents, plot.values.subarray(0, 2));
plot.destroy();

See Also