mirror of https://codeberg.org/topola/topola.git
feat(math/polygon_tangents): Add unit tests for triangle case
This commit is contained in:
parent
eff197d410
commit
d1bcf22e96
|
|
@ -160,10 +160,10 @@ mod tests {
|
|||
#[test]
|
||||
fn petp00() {
|
||||
let poly_ext = &[
|
||||
(point! { x: 0.0, y: 0.0 }, FixedDotIndex::new(0.into())),
|
||||
(point! { x: 1.0, y: 0.0 }, FixedDotIndex::new(1.into())),
|
||||
(point! { x: 1.0, y: 1.0 }, FixedDotIndex::new(2.into())),
|
||||
(point! { x: 0.0, y: 1.0 }, FixedDotIndex::new(3.into())),
|
||||
(point! { x: 0., y: 0. }, FixedDotIndex::new(0.into())),
|
||||
(point! { x: 1., y: 0. }, FixedDotIndex::new(1.into())),
|
||||
(point! { x: 1., y: 1. }, FixedDotIndex::new(2.into())),
|
||||
(point! { x: 0., y: 1. }, FixedDotIndex::new(3.into())),
|
||||
];
|
||||
let origin = point! { x: 0.5, y: -1.0 };
|
||||
assert_eq!(
|
||||
|
|
@ -175,10 +175,10 @@ mod tests {
|
|||
#[test]
|
||||
fn petp00cw() {
|
||||
let poly_ext = &[
|
||||
(point! { x: 0.0, y: 0.0 }, FixedDotIndex::new(0.into())),
|
||||
(point! { x: 0.0, y: 1.0 }, FixedDotIndex::new(3.into())),
|
||||
(point! { x: 1.0, y: 1.0 }, FixedDotIndex::new(2.into())),
|
||||
(point! { x: 1.0, y: 0.0 }, FixedDotIndex::new(1.into())),
|
||||
(point! { x: 0., y: 0. }, FixedDotIndex::new(0.into())),
|
||||
(point! { x: 0., y: 1. }, FixedDotIndex::new(3.into())),
|
||||
(point! { x: 1., y: 1. }, FixedDotIndex::new(2.into())),
|
||||
(point! { x: 1., y: 0. }, FixedDotIndex::new(1.into())),
|
||||
];
|
||||
let origin = point! { x: 0.5, y: -1.0 };
|
||||
assert_eq!(
|
||||
|
|
@ -186,4 +186,34 @@ mod tests {
|
|||
Ok((FixedDotIndex::new(1.into()), FixedDotIndex::new(0.into())))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "https://codeberg.org/topola/topola/issues/238"]
|
||||
fn triangle() {
|
||||
let poly_ext = &[
|
||||
(point! { x: 0., y: 0. }, FixedDotIndex::new(0.into())),
|
||||
(point! { x: 1., y: 1. }, FixedDotIndex::new(1.into())),
|
||||
(point! { x: 0., y: 2. }, FixedDotIndex::new(2.into())),
|
||||
];
|
||||
let origin = point! { x: 2., y: 1. };
|
||||
assert_eq!(
|
||||
petp(poly_ext, false, origin),
|
||||
Ok((FixedDotIndex::new(2.into()), FixedDotIndex::new(0.into())))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "https://codeberg.org/topola/topola/issues/238"]
|
||||
fn triangle_cw() {
|
||||
let poly_ext = &[
|
||||
(point! { x: 0., y: 0. }, FixedDotIndex::new(0.into())),
|
||||
(point! { x: 0., y: 2. }, FixedDotIndex::new(2.into())),
|
||||
(point! { x: 1., y: 1. }, FixedDotIndex::new(1.into())),
|
||||
];
|
||||
let origin = point! { x: 2., y: 1. };
|
||||
assert_eq!(
|
||||
petp(poly_ext, true, origin),
|
||||
Ok((FixedDotIndex::new(2.into()), FixedDotIndex::new(0.into())))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue