contour

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package contour traces iso-lines and fills iso-bands of a function sampled on a rectangular grid, by marching squares with linear interpolation along cell edges.

A grid is Z[i*nx+j] at (X[j], Y[i]); X and Y must be monotonic. Saddle cells (opposite corners on the same side of the level) are resolved by the value at the cell centre, taken as the mean of the four corners. NaN corners make a cell contribute nothing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Band

func Band(g Grid, lo, hi float64) [][]Pt

Band returns the region where lo <= z <= hi as polygons, one per grid cell that the band touches, all wound counter-clockwise in (x, y). Filled together under the nonzero rule they make the band without seams.

func Lines

func Lines(g Grid, level float64) [][]Pt

Lines returns the iso-lines at level as polylines. Lines that close on themselves repeat their first point at the end.

Types

type Grid

type Grid struct {
	X, Y []float64 // len nx and ny
	Z    []float64 // ny*nx, row-major: Z[i*nx+j] is at (X[j], Y[i])
}

Grid is a function sampled on a rectangular grid.

type Pt

type Pt struct{ X, Y float64 }

Pt is a point in grid (data) coordinates.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL