#include <cmath>
#include "gtest/gtest.h"
namespace cad_helpers {
TEST(DomainEngines, B_splineEvaluate) {
int p = 2;
Range<double> knots({0, 0, 0, 1, 2, 3, 3, 4, 4, 4});
EXPECT_LT((pt -
Vec2d(3.98, 2.52)).norm(), 1e-15);
EXPECT_LT((pt -
Vec2d(2.38, 3)).norm(), 1e-15);
EXPECT_LT((pt -
Vec2d(0.8, 1.24)).norm(), 1e-15);
EXPECT_LT((pt -
Vec2d(6.8, 3.18)).norm(), 1e-15);
EXPECT_LT((pt -
Vec2d(0, 1)).norm(), 1e-15);
EXPECT_LT((pt -
Vec2d(7, 3)).norm(), 1e-15);
}
TEST(DomainEngines, B_splineDerivative) {
int p = 2;
Range<double> knots({0, 0, 0, 1, 2, 3, 3, 4, 4, 4});
Range<double> d_knots;
Range<Vec2d> d_cp;
EXPECT_LT((pt -
Vec2d(2, 0)).norm(), 1e-15);
EXPECT_LT((pt -
Vec2d(2, 0)).norm(), 1e-15);
EXPECT_LT((pt -
Vec2d(1.5, 0.5)).norm(), 1e-15);
EXPECT_LT((pt -
Vec2d(2, -2)).norm(), 1e-15);
EXPECT_LT((pt -
Vec2d(1.5, 0)).norm(), 1e-15);
}
}
}