Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chris00/rust-curve-sampling
Adaptive sampling of parametric curves (including graph of functions)
https://github.com/chris00/rust-curve-sampling
curve-tracing plotting plotting-functions sampling
Last synced: 15 days ago
JSON representation
Adaptive sampling of parametric curves (including graph of functions)
- Host: GitHub
- URL: https://github.com/chris00/rust-curve-sampling
- Owner: Chris00
- License: gpl-3.0
- Created: 2022-05-10T11:18:14.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-03T17:23:07.000Z (7 months ago)
- Last Synced: 2024-10-07T08:09:55.923Z (about 1 month ago)
- Topics: curve-tracing, plotting, plotting-functions, sampling
- Language: Rust
- Homepage:
- Size: 260 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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](https://docs.rs/curve-sampling/).
Example
-------To sample the function x ↦ x sin(1/x) on the interval [-0.4, 0.4] with
227 function evaluations, simply do```rust
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
```rust
s.latex().write(&mut File::create("graph.tex")?)?;
```or to a data file (whose format is compatible with [Gnuplot][]) with
```rust
s.write(&mut File::create("graph.dat")?)?;
```Asking [Gnuplot][] to draw the resulting curve (with `plot 'graph.dat'`)
yields:![x sin(1/x)](https://user-images.githubusercontent.com/1255665/186882845-81dcbe02-808b-40d7-9fad-a838e326ce78.png)
P.S. The number of evaluations (227) was chosen to match a depth 5
recursion for
[Mathematica](https://github.com/Chris00/rust-curve-sampling/wiki).[TikZ]: https://tikz.dev/
[Gnuplot]: http://www.gnuplot.info/