Added more tests (inline transformation of region etc. with matrix transformations)

This commit is contained in:
Matthias Koefferlein 2021-03-05 15:39:02 +01:00
parent 44e59bc2ff
commit af5435f869
1 changed files with 18 additions and 0 deletions

View File

@ -254,8 +254,17 @@ class DBMatrix_TestClass < TestBase
assert_equal((m * RBA::SimplePolygon::new(RBA::Box::new(-5, -10, 10, 20))).to_s, "(5,-25;-10,-18;5,43;20,35)")
assert_equal((m * RBA::Edge::new(RBA::Point::new(-5, -10), RBA::Point::new(10, 20))).to_s, "(-10,-18;20,35)")
assert_equal(RBA::Region::new(RBA::Box::new(-5, -10, 10, 20)).transformed(m).to_s, "(5,-25;-10,-18;5,43;20,35)")
r = RBA::Region::new(RBA::Box::new(-5, -10, 10, 20))
r.transform(m)
assert_equal(r.to_s, "(5,-25;-10,-18;5,43;20,35)")
assert_equal(RBA::Edges::new(RBA::Edge::new(RBA::Point::new(-5, -10), RBA::Point::new(10, 20))).transformed(m).to_s, "(-10,-18;20,35)")
r = RBA::Edges::new(RBA::Edge::new(RBA::Point::new(-5, -10), RBA::Point::new(10, 20)))
r.transform(m)
assert_equal(r.to_s, "(-10,-18;20,35)")
assert_equal(RBA::EdgePairs::new(RBA::EdgePair::new(RBA::Edge::new(RBA::Point::new(-5, -10), RBA::Point::new(10, 20)), RBA::Edge::new(RBA::Point::new(-6, -10), RBA::Point::new(11, 20)))).transformed(m).to_s, "(-10,-18;20,35)/(-11,-17;21,35)")
r = RBA::EdgePairs::new(RBA::EdgePair::new(RBA::Edge::new(RBA::Point::new(-5, -10), RBA::Point::new(10, 20)), RBA::Edge::new(RBA::Point::new(-6, -10), RBA::Point::new(11, 20))))
r.transform(m)
assert_equal(r.to_s, "(-10,-18;20,35)/(-11,-17;21,35)")
m = RBA::Matrix2d::new(1.0, 0.5, -0.5, 2.0)
assert_equal((m * RBA::DPoint::new(10, 20)).to_s, "20,35")
@ -273,8 +282,17 @@ class DBMatrix_TestClass < TestBase
assert_equal((m * RBA::SimplePolygon::new(RBA::Box::new(-5, -10, 10, 20))).to_s, "(6,-25;-9,-18;6,43;21,35)")
assert_equal((m * RBA::Edge::new(RBA::Point::new(-5, -10), RBA::Point::new(10, 20))).to_s, "(-9,-18;21,35)")
assert_equal(RBA::Region::new(RBA::Box::new(-5, -10, 10, 20)).transformed(m).to_s, "(6,-25;-9,-18;6,43;21,35)")
r = RBA::Region::new(RBA::Box::new(-5, -10, 10, 20))
r.transform(m)
assert_equal(r.to_s, "(6,-25;-9,-18;6,43;21,35)")
assert_equal(RBA::Edges::new(RBA::Edge::new(RBA::Point::new(-5, -10), RBA::Point::new(10, 20))).transformed(m).to_s, "(-9,-18;21,35)")
r = RBA::Edges::new(RBA::Edge::new(RBA::Point::new(-5, -10), RBA::Point::new(10, 20)))
r.transform(m)
assert_equal(r.to_s, "(-9,-18;21,35)")
assert_equal(RBA::EdgePairs::new(RBA::EdgePair::new(RBA::Edge::new(RBA::Point::new(-5, -10), RBA::Point::new(10, 20)), RBA::Edge::new(RBA::Point::new(-6, -10), RBA::Point::new(11, 20)))).transformed(m).to_s, "(-9,-18;21,35)/(-10,-17;22,35)")
r = RBA::EdgePairs::new(RBA::EdgePair::new(RBA::Edge::new(RBA::Point::new(-5, -10), RBA::Point::new(10, 20)), RBA::Edge::new(RBA::Point::new(-6, -10), RBA::Point::new(11, 20))))
r.transform(m)
assert_equal(r.to_s, "(-9,-18;21,35)/(-10,-17;22,35)")
m = RBA::Matrix3d::new(1.0, 0.5, 1.0, -0.5, 2.0, 0.0, 0.0, 0.0, 1.0)
assert_equal((m * RBA::DPoint::new(10, 20)).to_s, "21,35")