Skip to content

Commit

Permalink
add test + passes
Browse files Browse the repository at this point in the history
  • Loading branch information
banin committed Mar 15, 2023
1 parent e8e98f8 commit a1cf38a
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2240,7 +2240,7 @@ fn abs(x: f64) -> f64 {

#[cfg(test)]
mod test {
use super::{incircle, orient2d, orient3d, Coord, Coord3D};
use super::{incircle, insphere, orient2d, orient3d, Coord, Coord3D};

#[test]
fn test_orient2d() {
Expand Down Expand Up @@ -2331,6 +2331,53 @@ mod test {
assert!(incircle(from, to, p_right, p_query) > 0.0);
}

#[test]
fn test_insphere() {
let pa = Coord3D {
x: 1.0,
y: 0.0,
z: 0.0,
};
let pb = Coord3D {
x: 0.0,
y: 1.0,
z: 0.0,
};
let pc = Coord3D {
x: 0.0,
y: 0.0,
z: 1.0,
};
let pd = Coord3D {
x: 0.0,
y: -1.0,
z: 0.0,
};

// point outside sphere
let pe1 = Coord3D {
x: -1.01,
y: 0.,
z: 0.,
};
// point inside sphere
let pe2 = Coord3D {
x: 0.,
y: 0.,
z: 0.99,
};
// cospherical point
let pe3 = Coord3D {
x: 0.,
y: 0.,
z: -1.,
};

assert!(insphere(pa, pb, pc, pd, pe1) < 0.0);
assert!(insphere(pa, pb, pc, pd, pe2) > 0.0);
assert!(insphere(pa, pb, pc, pd, pe3) == 0.0);
}

#[test]
fn test_issue48_a() {
let pa = Coord {
Expand Down

0 comments on commit a1cf38a

Please sign in to comment.