This commit is contained in:
2026-01-20 17:30:34 +01:00
commit 650e5cc6b8
14 changed files with 968 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
#include <gtest/gtest.h>
#include "autoopt/quadric.hpp"
#include <iostream>
using namespace autoopt;
TEST(QuadricTest, ParabolaRotation) {
quadric<double> q(1.0, 0.0, 0.0, 0.0, -1.0, 0.0); // y = x^2
EXPECT_DOUBLE_EQ(q.at(-1.0), 1.0); // At x=1, y=1
EXPECT_DOUBLE_EQ(q.at(0.0), 0.0); // At x=0, y=0
EXPECT_DOUBLE_EQ(q.at(1.0), 1.0); // At x=1, y=1
double angle = M_PI / 4; // 45 degrees
quadric<double> q_rotated = q.rotated_by(angle);
EXPECT_NEAR(q_rotated.at(-1.0), -0.11729096183611623, 1e-9);
EXPECT_NEAR(q_rotated.at(0.0), 0.0, 1e-9);
EXPECT_TRUE(std::isnan(q_rotated.at(1.0))); // Expect NaN due to no real solution
}