Function cavalier_contours::polyline::seg_length
source · pub fn seg_length<T>(v1: PlineVertex<T>, v2: PlineVertex<T>) -> Twhere
T: Real,
Expand description
Calculate the path length of the polyline segment defined by v1
to v2
.
§Examples
// counter clockwise half circle arc going from (2, 2) to (2, 4)
// arc radius = 1 so length should be PI
let v1 = PlineVertex::new(2.0, 2.0, 1.0);
let v2 = PlineVertex::new(4.0, 2.0, 0.0);
assert!(seg_length(v1, v2).fuzzy_eq(std::f64::consts::PI));
Also works with line segments.
// line segment going from (2, 2) to (4, 4)
let v1 = PlineVertex::new(2.0, 2.0, 0.0);
let v2 = PlineVertex::new(4.0, 4.0, 0.0);
assert!(seg_length(v1, v2).fuzzy_eq(2.0 * 2.0f64.sqrt()));