From 23f40d9e37e58141849db610a707695221f94812 Mon Sep 17 00:00:00 2001 From: George Steel Date: Wed, 30 Aug 2023 19:32:14 -0400 Subject: [PATCH] fix typos identified in review --- src/bezpath.rs | 2 +- src/circle.rs | 18 +++++++++--------- src/param_curve.rs | 8 ++++---- src/shape.rs | 26 +++++++++++++------------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/bezpath.rs b/src/bezpath.rs index 1843f0a4..8c5ee9be 100644 --- a/src/bezpath.rs +++ b/src/bezpath.rs @@ -1359,7 +1359,7 @@ impl Shape for PathSeg { PathSegIter { seg: *self, ix: 0 } } - /// The area under the curve. + /// The area between the curve and the origin. /// /// We could just return `0`, but this seems more useful. fn area(&self, _tolerance: f64) -> f64 { diff --git a/src/circle.rs b/src/circle.rs index 993e85b1..35ba0532 100644 --- a/src/circle.rs +++ b/src/circle.rs @@ -370,24 +370,24 @@ mod tests { fn area_sign() { let center = Point::new(5.0, 5.0); let c = Circle::new(center, 5.0); - assert_approx_eq(c.area(1.0), 25.0 * PI); + assert_approx_eq(c.area(1e-9), 25.0 * PI); - assert_eq!(c.winding(center, 1.0), 1); + assert_eq!(c.winding(center, 1e-9), 1); let p = c.to_path(1e-9); - assert_approx_eq(c.area(1.0), p.area(1.0)); - assert_eq!(c.winding(center, 1.0), p.winding(center, 1.0)); + assert_approx_eq(c.area(1e-9), p.area(1e-9)); + assert_eq!(c.winding(center, 1e-9), p.winding(center, 1e-9)); let c_neg_radius = Circle::new(center, -5.0); - assert_approx_eq(c_neg_radius.area(1.0), 25.0 * PI); + assert_approx_eq(c_neg_radius.area(1e-9), 25.0 * PI); - assert_eq!(c_neg_radius.winding(center, 1.0), 1); + assert_eq!(c_neg_radius.winding(center, 1e-9), 1); let p_neg_radius = c_neg_radius.to_path(1e-9); - assert_approx_eq(c_neg_radius.area(1.0), p_neg_radius.area(1.0)); + assert_approx_eq(c_neg_radius.area(1e-9), p_neg_radius.area(1e-9)); assert_eq!( - c_neg_radius.winding(center, 1.0), - p_neg_radius.winding(center, 1.0) + c_neg_radius.winding(center, 1e-9), + p_neg_radius.winding(center, 1e-9) ); } } diff --git a/src/param_curve.rs b/src/param_curve.rs index f8688388..5a0ea0a3 100644 --- a/src/param_curve.rs +++ b/src/param_curve.rs @@ -125,18 +125,18 @@ pub trait ParamCurveArclen: ParamCurve { /// A parametrized curve (or a section of one) that can have its signed area measured. pub trait ParamCurveArea { - /// Compute the signed (counterclockwise) area between the curve and the origin. + /// Compute the signed (counterclockwise from +x to +y) area between the curve and the origin. /// Equivalently (using Green's theorem), /// this is integral of the form `(x*dy - y*dx)/2` along the curve. - /// + /// /// For closed curves, this is the curve's area. /// For open curves, this is the the area of the resulting shape that would be created if /// the curve was closed with two line segments between the endpoints and the origin. /// This allows the area of a piecewise curve to be computed by adding the areas of its segments, /// generalizing the "shoelace formula." - /// + /// /// For an open curve with endpoints `(x0, y0)` and `(x1, y1)`, this value - /// is also equivalent to `-intgral(y*dx) - (x0*y0 + x1*y1)/2`. + /// is also equivalent to `-integral(y*dx) - (x0*y0 + x1*y1)/2`. /// /// See: /// and diff --git a/src/shape.rs b/src/shape.rs index 8bac8171..da2de696 100644 --- a/src/shape.rs +++ b/src/shape.rs @@ -112,25 +112,25 @@ pub trait Shape: Sized { /// usual convention for graphics), and anticlockwise when /// up is increasing y (the usual convention for math). /// - /// The tolerance parameter behaves the same as in [`path_elements()`], - /// allowing the default implmentation that first converts to a bezier path. + /// The `tolerance` parameter behaves the same as in [`path_elements()`], + /// allowing the default implmentation that first converts to a Beziér path. /// Note this allows the returned area to be off by a most the tolerance times the perimiter. /// /// Tolerance should be ignored (by implementing this method directly) - /// if there is an easy way to return a precice result. + /// if there is an easy way to return an accurate result. fn area(&self, tolerance: f64) -> f64 { segments(self.path_elements(tolerance)).area() } /// Total length of perimeter. /// - /// The tolerance parameter behaves the same as in [`path_elements()`], - /// allowing the default implmentation that first converts to a bezier path. + /// The `tolerance` parameter behaves the same as in [`path_elements()`], + /// allowing the default implmentation that first converts to a Beziér path. /// In addition, it may also be used to control the accuracy of integration of the arc length - /// (note that varying a sufficiently smooth curve will vary the perimiter by a simillar amount as the deflection). + /// (note that varying a sufficiently smooth curve will vary the perimeter by a similar amount as the deflection). /// /// Tolerance should be ignored (by implementing this method directly) - /// if there is an easy way to return a precice result. + /// if there is an easy way to return an accurate result. fn perimeter(&self, tolerance: f64) -> f64 { segments(self.path_elements(tolerance)).perimeter(tolerance) } @@ -144,13 +144,13 @@ pub trait Shape: Sized { /// and -1 when it is inside a negative area shape. Of course, greater /// magnitude values are also possible when the shape is more complex. /// - /// The tolerance parameter behaves the same as in [`path_elements()`], - /// allowing the default implmentation that first converts to a bezier path. - /// As a result, the returned value is allowed to be the tinging number of + /// The `tolerance` parameter behaves the same as in [`path_elements()`], + /// allowing the default implmentation that first converts to a Beziér path. + /// As a result, the returned value is allowed to be the winding number of /// a point at most tolerance away from p. /// /// Tolerance should be ignored (by implementing this method directly) - /// if there is an easy way to return a precice result. + /// if there is an easy way to return an accurate result. /// /// [`area`]: Shape::area /// [winding number]: https://mathworld.wolfram.com/ContourWindingNumber.html @@ -167,8 +167,8 @@ pub trait Shape: Sized { /// The smallest rectangle that encloses the shape. /// - /// The tolerance parameter behaves the same as in [`path_elements()`], - /// allowing the default implmentation that first converts to a bezier path. + /// The `tolerance` parameter behaves the same as in [`path_elements()`], + /// allowing the default implmentation that first converts to a Beziér path. /// It should be ignored (by implementing this method directly) /// if there is an easy way to return a precice result. fn bounding_box(&self, tolerance: f64) -> Rect;