#curve #3d #graphics #game #path

fastcurve_3d

Library for 3D and 2D fast curve generation

2 releases

0.1.1 May 24, 2020
0.1.0 May 14, 2020

#118 in Robotics

Download history 177/week @ 2024-01-02 78/week @ 2024-01-09 106/week @ 2024-01-16 109/week @ 2024-01-23 175/week @ 2024-01-30 186/week @ 2024-02-06 284/week @ 2024-02-13 219/week @ 2024-02-20 197/week @ 2024-02-27 225/week @ 2024-03-05 215/week @ 2024-03-12 289/week @ 2024-03-19 216/week @ 2024-03-26 430/week @ 2024-04-02 460/week @ 2024-04-09 283/week @ 2024-04-16

1,460 downloads per month

Custom license

33KB
114 lines

Rust Fast Curve 3d

crates.io Rust License codecov

This algorithm is generates a curve from a list of control points.

References:

Original paper: G. M. Chaikin, “An algorithm for high-speed curve generation, Computer Graphics and Image Processing,” vol. 3, 1974, pp. 346-349 On Chaikin's algorithm R.F.Riesenfeld

The library contains the following functions:

  • fast_curve_2d for generating curves in 2D.
  • fast_curve_3d for generating curves in 3D.

Examples:

For the examples the rust gnuplot library is used.

3d curve generation

    let x = vec![1.0,1.0,4.0,5.0,2.0];
    let y = vec![1.0,2.0,0.5,1.0,2.0];
    let z = vec![1.0,2.0,0.8,1.0,1.5];
    let n: u8 = 4;

    let (xn,yn,zn) = fast_curve_3d(&x, &y, &z, n);

    // gnu plot Figure
    let mut fg = Figure::new();
    fg.axes3d()
    .lines(&x, &y, &z,&[Caption("Original"), Color("blue")])
    .lines(&xn, &yn, &zn, &[Caption("Smoothed"), Color("red")]);
    fg.set_scale(1.0, 1.0);
    fg.show().unwrap();

alt text

2d curve generation

    let x = vec![1.0,1.0,4.0,5.0,2.0];
    let y = vec![1.0,2.0,0.5,1.0,2.0];
    let n: u8 = 4;

     let (xn,yn) = fast_curve_2d(&x, &y, n);


    let mut fg = Figure::new();
    fg.axes2d()
    .lines(&x, &y,&[Caption("Original"), Color("blue")])
    .lines(&xn, &yn, &[Caption("Smoothed"), Color("red")]);
    
    fg.set_scale(1.0, 1.0);
    fg.show().unwrap();

alt text

No runtime deps