poincare-lib
A GPU-accelerated 3D graphing library for embedding interactive mathematical plots in any wgpu / egui application. Built on viewport-lib.
Plot types
- Surfaces: Cartesian
z = f(x, y), parametric, spherical, cylindrical, implicit - Curves: 3D parametric curves and piecewise polylines
- Scatter / point clouds: per-point colour and size
- Vector fields: arrow glyphs and LIC (line integral convolution)
- Streamlines: seeded integration through a vector field
- Volumes and isosurfaces: scalar field rendering
- Contours and density plots
Styles include solid colour, colourmap, matcap shading, opacity, two-sided lighting, and parameter-space visualisation. Expressions are parsed at runtime with no recompilation needed.
Usage
Add to Cargo.toml:
[]
= "0.5"
= "0.15" # for ViewportRenderer and Camera
Minimal example
use ;
use ;
// 1. Declare the scene. No GPU work happens here.
let spec = GraphSpec ;
// 2. Tessellate expressions into CPU-side triangle meshes.
let mut scene = spec.build_scene.expect;
// 3. Upload meshes to the GPU once at startup (needs wgpu device + ViewportRenderer).
// GraphScene caches the returned MeshIds for use in build_frame().
scene.upload_meshes.unwrap;
// 4. Each frame, build FrameData and hand it to the renderer.
let mut frame = scene.build_frame;
frame.camera.viewport_size = ;
frame.camera.pixels_per_point = pixels_per_point;
frame.viewport.background_colour = Some;
// ... submit frame to ViewportRenderer via your egui_wgpu callback
See poincare-dvd for a minimal self-contained application that uses this API to render a bouncing 3D graph window, showing that poincare-lib works independently of the main Poincaré application.
Relationship to other crates
| Crate | Role |
|---|---|
poincare-lib |
Math, tessellation, scene construction (this crate) |
viewport-lib |
GPU renderer, wgpu pipeline, Camera |
poincare-app |
Full desktop application built on top of this crate |