47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
//
|
|
// Created by jholder on 21.10.21.
|
|
//
|
|
|
|
#include "Rod2d.hpp"
|
|
#include <catch2/catch.hpp>
|
|
#include <Eigen/Dense>
|
|
|
|
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") {
|
|
SECTION("Forwards == e 90"){
|
|
//
|
|
// =====
|
|
//
|
|
rod.setE({0, 1}); // Lab system is 90 degree rotated
|
|
auto test = Eigen::Vector2d ({1,0});
|
|
auto erg = (rod.getE_Base_matrix()*test).normalized();
|
|
auto e = rod.getE();
|
|
REQUIRE(erg.isApprox(e));
|
|
|
|
}
|
|
SECTION("Forwards == e 45"){
|
|
// o
|
|
// o
|
|
// o
|
|
rod.setE(Eigen::Vector2d ({1,1}).normalized()); // Lab system is 90 degree rotated
|
|
auto test = Eigen::Vector2d ({1,0});
|
|
auto erg = (rod.getE_Base_matrix()*test).normalized();
|
|
auto e = rod.getE();
|
|
REQUIRE(erg.isApprox(e));
|
|
}
|
|
|
|
|
|
}
|
|
|
|
} |