// // Created by jholder on 21.10.21. // #include #include #include "Data/Rod2d.hpp" #include "tools/vec_trafos.h" TEST_CASE("Rods") { Rod2d sphere(1); Rod2d rod(2); SECTION("Checking translation") { rod.setPos({0,0}); rod.setPos(rod.getPos() + Eigen::Vector2d(1, -1)); auto newPos = rod.getPos(); REQUIRE(newPos[0] == 1); REQUIRE(newPos[1] == -1); REQUIRE(sphere.getDiff_Sqrt()(0, 0) == 1.0); REQUIRE(sphere.getDiff_Sqrt()(0, 1) == 0.0); REQUIRE(sphere.getDiff_Sqrt()(1, 0) == 0.0); REQUIRE(sphere.getDiff_Sqrt()(1, 1) == 1.0); } SECTION("Checking rotation") { double f1 = GENERATE(take(10, random(-100, 100))); double f2 = GENERATE(take(10, random(-100, 100))); rod.setE(Eigen::Vector2d({f1, f2}).normalized()); auto test = Eigen::Vector2d({1, 0}); auto e = rod.getE(); auto erg = (rotation_Matrix(e) * test).normalized(); REQUIRE(erg.isApprox(e)); } }