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

Function TEST

tests/T_NurbsCurve.cpp:7–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5using namespace LNLib;
6
7TEST(Test_NurbsCurve, All)
8{
9 int degree = 2;
10 std::vector<double> kv = { 0,0,0,1,2,3,3,3};
11 std::vector<XYZW> cps = { XYZW(XYZ(0,0,0),1), XYZW(XYZ(1,1,0),4), XYZW(XYZ(3,2,0),1), XYZW(XYZ(4,1,0),1), XYZW(XYZ(5,-1,0),1)};
12
13 LN_NurbsCurve curve;
14 curve.Degree = degree;
15 curve.KnotVector = kv;
16 curve.ControlPoints = cps;
17
18 bool canDer = NurbsCurve::CanComputeDerivative(curve, 1.0);
19 EXPECT_TRUE(canDer);
20
21 XYZ result = NurbsCurve::GetPointOnCurve(curve, 1.0);
22 EXPECT_TRUE(result.IsAlmostEqualTo(XYZ(7.0/5,6.0/5,0)));
23
24 std::vector<double> kv1 = { 0,0,0,1,1,1 };
25 std::vector<XYZW> cps1 = { XYZW(XYZ(1,0,0),1), XYZW(XYZ(1,1,0),1), XYZW(XYZ(0,1,0),2)};
26
27 curve.KnotVector = kv1;
28 curve.ControlPoints = cps1;
29
30 std::vector<XYZ> ders = NurbsCurve::ComputeRationalCurveDerivatives(curve, 2, 0.0);
31 EXPECT_TRUE(ders[1].IsAlmostEqualTo(XYZ(0, 2, 0)));
32 EXPECT_TRUE(ders[2].IsAlmostEqualTo(XYZ(-4, 0, 0)));
33}

Callers

nothing calls this directly

Calls 4

GetPointOnCurveFunction · 0.85
XYZWClass · 0.50
XYZClass · 0.50
IsAlmostEqualToMethod · 0.45

Tested by

no test coverage detected