Skip to content

Adaptive sampling of parametric curves (including graph of functions)

License

Notifications You must be signed in to change notification settings

Chris00/rust-curve-sampling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Curve Sampling

This module provide a collection of routines to perform adaptive sampling of curves as well as manipulating those samplings.

Usage

Add this to your Cargo.toml:

[dependencies]
curve-sampling = "0.5"

See the documentation.

Example

To sample the function x ↦ x sin(1/x) on the interval [-0.4, 0.4] with 227 function evaluations, simply do

use curve_sampling::Sampling;
let s = Sampling::fun(|x| x * (1. / x).sin(), -0.4, 0.4).n(227).build();

You can save the resulting sampling to TikZ with

s.latex().write(&mut File::create("graph.tex")?)?;

or to a data file (whose format is compatible with Gnuplot) with

s.write(&mut File::create("graph.dat")?)?;

Asking Gnuplot to draw the resulting curve (with plot 'graph.dat') yields:

x sin(1/x)

P.S. The number of evaluations (227) was chosen to match a depth 5 recursion for Mathematica.

About

Adaptive sampling of parametric curves (including graph of functions)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published