Skip to main content

Module function_plane

Module function_plane 

Expand description

FunctionPlane — the world ↔ screen mapping and grid of a pannable, zoomable function plot (a grapher’s y = f(x) canvas).

Unlike crate::widget::CartesianPlot, whose domain is fitted to its data, a function plane is an unbounded world the user pans and zooms: the axes run through the world origin wherever it lands, and the grid steps follow a 1-2-5 progression so a label never reads 0.30000000000000004. The host samples its own curves through FunctionPlane::to_screen and paints them over FunctionPlane::paint_grid.

Structs§

FunctionPlane
A function plot’s viewport: center is the world point under the canvas centre and scale the pixels per world unit (y up in world space).

Functions§

format_tick
A tick value at the precision its step implies, without trailing zeros: 0.5, 2, -0.25, and exactly 0 at the origin.
nice_step
The 1-2-5 “nice” step nearest above raw world units. Non-finite or non-positive input falls back to 1.0.
nice_ticks
Axis ticks on a 1-2-5 step inside [min, max]: at most max_count, at least two, every one a round number at its step’s precision, so an axis reads 0, 10, 20, 30 instead of 0, 11.5, 23, 34.5. A range too narrow or too odd for two round ticks gets its two ends.