Skip to content

Commit

Permalink
little doc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
juliapaci committed Sep 27, 2024
1 parent a92112d commit 3d331fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ impl Point {
pub fn is_nan(self) -> bool {
self.x.is_nan() || self.y.is_nan()
}

}

impl From<(f32, f32)> for Point {
Expand Down
18 changes: 11 additions & 7 deletions src/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Triangle {
/// The empty [`Triangle`] at the origin
pub const ZERO: Self = Self::from_coords((0., 0.), (0., 0.), (0., 0.));

/// equilateral [`Triangle`]
/// Equilateral [`Triangle`] with the x-axis unit vector as its base.
pub const EQUILATERAL: Self = Self::from_coords(
(
1.0 / 2.0,
Expand Down Expand Up @@ -118,7 +118,9 @@ impl Triangle {
self.area() == 0.0
}

/// The inscribed circle of [`Triangle`] (the greatest [`Circle`] that lies within the [`Triangle`])
/// The inscribed circle of [`Triangle`]
///
/// This is defined as the greatest [`Circle`] that lies within the [`Triangle`]
#[doc(alias = "incircle")]
#[inline]
pub fn inscribed_circle(&self) -> Circle {
Expand All @@ -129,7 +131,9 @@ impl Triangle {
Circle::new(self.circumcenter(), 2.0 * self.area() / (ab + bc + ac))
}

/// The circumscribed circle of [`Triangle`] (the smallest [`Circle`] which intercepts each vertex of the [`Triangle`])
/// The circumscribed circle of [`Triangle`]
///
/// This is defined as the smallest [`Circle`] which intercepts each vertex of the [`Triangle`]
#[doc(alias = "circumcircle")]
#[inline]
pub fn circumscribed_circle(&self) -> Circle {
Expand Down Expand Up @@ -316,17 +320,17 @@ mod tests {

#[test]
fn inradius() {
let test = Triangle::EQUILATERAL.inscribed_circle();
let test = Triangle::EQUILATERAL.inscribed_circle().radius;
let expected = 0.28867513459481287;

assert_approx_eq(test.radius, expected);
assert_approx_eq(test, expected);
}

#[test]
fn circumradius() {
let test = Triangle::EQUILATERAL.circumscribed_circle();
let test = Triangle::EQUILATERAL.circumscribed_circle().radius;
let expected = 0.5773502691896258;

assert_approx_eq(test.radius, expected);
assert_approx_eq(test, expected);
}
}

0 comments on commit 3d331fb

Please sign in to comment.