BD_Integratoren/C++/test/test_Rod2d.cpp
2021-10-27 22:00:24 +02:00

33 lines
1.0 KiB
C++

//
// Created by jholder on 21.10.21.
//
#include <Eigen/Dense>
#include <catch2/catch.hpp>
#include "Rod2d.hpp"
#include "vec_trafos.h"
TEST_CASE("Rods") {
Rod2d sphere(1);
Rod2d rod(2);
SECTION("Checking translation") {
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));
}
}