1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#include "Test.h"
#include "Bezier.h"
#include <glm/geometric.hpp>
TEST_CASE("Bezier Spline", "[Bezier]")
{
pymol::BezierSpline spline;
REQUIRE(true);
REQUIRE(spline.getBezierPoints().size() == 0);
REQUIRE(spline.getLastBezierPoint() == nullptr);
REQUIRE(spline.curveCount() == 0);
}
TEST_CASE("Add Bezier Point", "[Bezier]")
{
pymol::BezierSpline spline;
spline.addBezierPoint();
REQUIRE(spline.getBezierPoints().size() == 2);
REQUIRE(spline.getLastBezierPoint() != nullptr);
REQUIRE(spline.curveCount() == 1);
}
TEST_CASE("Get Bezier Point", "[Bezier]")
{
pymol::BezierSpline spline;
spline.addBezierPoint();
auto quarterPoint = spline.getBezierPoint(0.25f);
auto halfPoint = spline.getBezierPoint(0.5f);
REQUIRE(quarterPoint == glm::vec3(1.5625f, 0.0f, -5.625f));
REQUIRE(halfPoint == glm::vec3(5.0f, 0.0f, -7.5f));
}
TEST_CASE("Get First Derivative", "[Bezier]")
{
pymol::BezierSpline spline;
spline.addBezierPoint();
auto quarterTangent = spline.getFirstDerivative(0.25f);
auto quarterDir = glm::normalize(quarterTangent);
auto halfTangent = spline.getFirstDerivative(0.5f);
auto halfDir = glm::normalize(halfTangent);
REQUIRE(quarterTangent == glm::vec3(11.25f, 0.0f, -15.0f));
REQUIRE(quarterDir == glm::vec3(0.6f, 0.0f, -0.8f));
REQUIRE(halfTangent == glm::vec3(15.0f, 0.0f, 0.0f));
REQUIRE(halfDir == glm::vec3(1.0f, 0.0f, 0.0f));
}
|