1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// src/ops/length.rs
//! Arc length and perimeter.
//!
//! Each edge length is `f64::hypot`, which avoids the overflow and underflow
//! that `sqrt(dx*dx + dy*dy)` has for very large or very small differences,
//! and the edge lengths are added with a compensated sum. Neither step has a
//! proven error bound in this crate: the result is an approximation, and its
//! accuracy is measured in the test suite.
use crateAccum;
use crate;
/// Length of the edge `a → b`: `hypot` of the two coordinate differences.
///
/// **Approximate, with no certified property.** Two roundings stand between
/// the inputs and the result. Each difference `b.x − a.x` and `b.y − a.y` is
/// rounded once (exact only when the operands are within a factor of two of
/// each other, by Sterbenz's lemma). Then `f64::hypot` is applied, and its
/// accuracy is the platform math library's: Rust does not specify it, so no
/// ulp bound is claimed here. `hypot` is used because, in practice, it has
/// none of the spurious overflow or underflow of `sqrt(dx² + dy²)` for very large or very small
/// differences.
///
/// A non-finite input gives a non-finite result; the result is never
/// negative. [`length`], [`ring_perimeter`] and [`perimeter`] are compensated
/// sums of this function.
/// Total arc length of a `LineString`: the sum of the Euclidean distances
/// between consecutive vertices.
/// Perimeter of a `LinearRing`, including the closing edge.
/// Perimeter of a `Polygon`'s exterior ring. Hole rings are not included;
/// add `ring_perimeter(hole)` for each of `polygon.holes()` for the total.