MCPcopy Create free account
hub / github.com/BIMCoderLiang/LNLib / TEST

Function TEST

tests/T_BsplineCurve.cpp:10–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8using namespace LNLib;
9
10TEST(Test_BsplineCurve, All)
11{
12 int degree = 2;
13 std::vector<double> knotVector = { 0,0,0,1,2,3,4,4,5,5,5 };
14 double paramT = 5.0 / 2;
15 XYZ P2 = XYZ(5, 6, 7);
16 XYZ P3 = XYZ(6, 7, 8);
17 XYZ P4 = XYZ(8, 9, 10);
18 std::vector<XYZ> controlPoints = { XYZ(1,0,0), XYZ(2,3,4), P2, P3, P4,
19 XYZ(9,10,11), XYZ(10,11,12), XYZ(11,12,13)};
20
21 LN_BsplineCurve<XYZ> bsplineCurve;
22 bsplineCurve.Degree = degree;
23 bsplineCurve.KnotVector = knotVector;
24 bsplineCurve.ControlPoints = controlPoints;
25
26 XYZ result = BsplineCurve::GetPointOnCurve(bsplineCurve, paramT);
27 EXPECT_TRUE(result.IsAlmostEqualTo(1.0/8 * P2 + 6.0/8 * P3 + 1.0/8 * P4));
28 std::vector<XYZ> ders = BsplineCurve::ComputeDerivatives(bsplineCurve, 1, paramT);
29 EXPECT_TRUE(ders[1].IsAlmostEqualTo(-0.5 * P2 + 0.5 * P4));
30 ders = BsplineCurve::ComputeDerivativesByAllBasisFunctions(bsplineCurve, 1, paramT);
31 EXPECT_TRUE(ders[1].IsAlmostEqualTo(-0.5 * P2 + 0.5 * P4));
32}

Callers

nothing calls this directly

Calls 5

GetPointOnCurveFunction · 0.85
XYZClass · 0.50
ComputeDerivativesFunction · 0.50
IsAlmostEqualToMethod · 0.45

Tested by

no test coverage detected