Added EdgePair#distance

This commit is contained in:
Matthias Koefferlein 2023-12-05 22:09:57 +01:00
parent ce77909c3f
commit d5f484bf92
2 changed files with 18 additions and 0 deletions

View File

@ -169,6 +169,14 @@ struct edge_pair_defs
method ("bbox", &C::bbox,
"@brief Gets the bounding box of the edge pair\n"
) +
method ("distance", &C::distance,
"@brief Gets the distance of the edges in the edge pair\n"
"\n"
"The distance between the two edges is defined as the minimum distance between any "
"two points on the two edges.\n"
"\n"
"This attribute has been introduced in version 0.28.14."
) +
method ("perimeter", &C::perimeter,
"@brief Gets the perimeter of the edge pair\n"
"\n"

View File

@ -61,6 +61,7 @@ class DBEdgePair_TestClass < TestBase
ep = RBA::EdgePair::new(RBA::Edge::new(0, 0, 10, 0), RBA::Edge::new(0, 20, 0, 0))
assert_equal(ep.distance, 0)
assert_equal(ep.perimeter, 30)
assert_equal(ep.area, 100)
assert_equal(ep.simple_polygon(0).area, 100)
@ -71,6 +72,10 @@ class DBEdgePair_TestClass < TestBase
assert_equal(ep.area, 0)
assert_equal(ep.simple_polygon(0).area, 0)
ep = RBA::EdgePair::new(RBA::Edge::new(0, 0, 10, 0), RBA::Edge::new(-10, 10, 20, 10))
assert_equal(ep.distance, 10)
end
# Basics
@ -108,6 +113,7 @@ class DBEdgePair_TestClass < TestBase
ep = RBA::DEdgePair::new(RBA::DEdge::new(0, 0, 10, 0), RBA::DEdge::new(0, 20, 0, 0))
assert_equal(ep.distance, 0)
assert_equal(ep.perimeter, 30)
assert_equal(ep.area, 100)
assert_equal(ep.simple_polygon(0).area, 100)
@ -118,6 +124,10 @@ class DBEdgePair_TestClass < TestBase
assert_equal(ep.area, 0)
assert_equal(ep.simple_polygon(0).area, 0)
ep = RBA::DEdgePair::new(RBA::DEdge::new(0, 0, 10, 0), RBA::DEdge::new(-10, 10, 20, 10))
assert_equal(ep.distance, 10)
end
# Fuzzy compare