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

Function TEST

tests/T_Circles.cpp:10–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8using namespace LNLib;
9
10TEST(Test_Circles, All)
11{
12 {
13 XYZ sp1 = XYZ(5.0, 181.34, 0);
14 XYZ ep1 = XYZ(13.659999999999997, 176.34, 0);
15
16 XYZ sp2 = XYZ(19.999779996773235, 189.9998729810778, 0);
17 XYZ ep2 = XYZ(19.999652977851035, 180.00009298430456, 0);
18
19 double param1, param2 = 0.0;
20 XYZ interP;
21 CurveCurveIntersectionType type = Intersection::ComputeRays(sp1, ep1 - sp1, sp2, ep2 - sp2, param1, param2, interP);
22 EXPECT_TRUE(type != CurveCurveIntersectionType::Skew);
23 }
24
25 {
26 XYZ center = XYZ(0, 0, 0);
27 XYZ xAxis = XYZ(1, 0, 0);
28 XYZ yAxis = XYZ(0, 1, 0);
29
30 LN_NurbsCurve curve;
31
32 bool result = NurbsCurve::CreateArc(center, xAxis, yAxis, 0, 2 * Constants::Pi, 10, 10, curve);
33 EXPECT_TRUE(result);
34
35 XYZ C0 = NurbsCurve::GetPointOnCurve(curve, 0);
36 EXPECT_TRUE(C0.IsAlmostEqualTo(XYZ(10, 0, 0)));
37 XYZ C1 = NurbsCurve::GetPointOnCurve(curve,0.25);
38 EXPECT_TRUE(C1.IsAlmostEqualTo(XYZ(0, 10, 0)));
39 XYZ C2 = NurbsCurve::GetPointOnCurve(curve, 0.5);
40 EXPECT_TRUE(C2.IsAlmostEqualTo(XYZ(-10, 0, 0)));
41 XYZ C3 = NurbsCurve::GetPointOnCurve(curve, 0.75);
42 EXPECT_TRUE(C3.IsAlmostEqualTo(XYZ(0, -10, 0)));
43 XYZ C4 = NurbsCurve::GetPointOnCurve(curve, 1.0);
44 EXPECT_TRUE(C4.IsAlmostEqualTo(XYZ(10, 0, 0)));
45
46 // Test arcs of 1/2/3/4 portions.
47 double endAngle[] = {Constants::Pi/4, 3*Constants::Pi/4, 5*Constants::Pi/4, 7*Constants::Pi/4};
48 for(int i=0;i<4;++i)
49 {
50 // Create arc.
51 const double radius = 10;
52 const double startAngle = 0;
53 bool result = NurbsCurve::CreateArc(center, xAxis, yAxis,
54 startAngle, endAngle[i], radius, radius, curve);
55
56 LN_ArcInfo arcInfo;
57 bool isArc = NurbsCurve::IsArc(curve, arcInfo);
58 EXPECT_TRUE(isArc);
59 EXPECT_TRUE(MathUtils::IsAlmostEqualTo(radius, arcInfo.Radius));
60 EXPECT_TRUE(result);
61
62 // Verify length.
63 double length = NurbsCurve::ApproximateLength(curve, LNLib::IntegratorType::Chebyshev);
64 double expectedLen = (endAngle[i] - startAngle) * radius;
65 EXPECT_NEAR(length, expectedLen, Constants::DistanceEpsilon);
66 }
67 }

Callers

nothing calls this directly

Calls 3

GetPointOnCurveFunction · 0.85
XYZClass · 0.50
IsAlmostEqualToMethod · 0.45

Tested by

no test coverage detected