Files
autoopt-cpp/tests/quadric.cpp
T
2026-01-20 17:30:34 +01:00

21 lines
649 B
C++

#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
}