Skip to content

Commit

Permalink
fix typos identified in review
Browse files Browse the repository at this point in the history
  • Loading branch information
george-steel committed Aug 30, 2023
1 parent d2f7f12 commit ea4b5fa
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/bezpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 9 additions & 9 deletions src/circle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/param_curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ 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.
///
Expand All @@ -136,7 +136,7 @@ pub trait ParamCurveArea {
/// 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:
/// <https://github.com/Pomax/bezierinfo/issues/44> and
Expand Down
26 changes: 13 additions & 13 deletions src/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit ea4b5fa

Please sign in to comment.