Struct visioncortex::Spline
source · pub struct Spline {
pub points: Vec<PointF64>,
}
Expand description
Series of connecting 2D Bezier Curves
Fields§
§points: Vec<PointF64>
1+3*(num_curves) points, where the first curve is represented by the first 4 points and each subsequent curve is represented by the last point in the previous curve plus 3 points Points are of PointF64 type.
Implementations§
source§impl Spline
impl Spline
sourcepub fn add(&mut self, point2: PointF64, point3: PointF64, point4: PointF64)
pub fn add(&mut self, point2: PointF64, point3: PointF64, point4: PointF64)
Adds a curve to the end of the spline. Takes 3 points that are the second to fourth control points of the bezier curve. Note that the first control point is taken from the last point of the previous curve.
sourcepub fn iter(&self) -> Iter<'_, PointF64>
pub fn iter(&self) -> Iter<'_, PointF64>
Returns an iterator on the vector of points on the spline
pub fn get_control_points(&self) -> Vec<&[PointF64]>
sourcepub fn num_curves(&self) -> usize
pub fn num_curves(&self) -> usize
Returns the number of curves on the spline
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the spline contains no curve, false otherwise A curve is defined by 4 points, so a non-empty spline should contain at least 4 points.
sourcepub fn from_image(
image: &BinaryImage,
clockwise: bool,
corner_threshold: f64,
outset_ratio: f64,
segment_length: f64,
max_iterations: usize,
splice_threshold: f64
) -> Self
pub fn from_image( image: &BinaryImage, clockwise: bool, corner_threshold: f64, outset_ratio: f64, segment_length: f64, max_iterations: usize, splice_threshold: f64 ) -> Self
Returns a spline created from image. The following steps are performed:
- Convert pixels into path
- Simplify the path into polygon
- Smoothen the polygon and approximate it with a curve-fitter
Corner/Splice thresholds are specified in radians. Length threshold is specified in pixels (length unit in path coordinate system).
sourcepub fn from_path_f64(path: &PathF64, splice_threshold: f64) -> Self
pub fn from_path_f64(path: &PathF64, splice_threshold: f64) -> Self
Returns a spline by curve-fitting a path.
Splice threshold is specified in radians.