MCPcopy Create free account
hub / github.com/andrewwillmott/splines-lib / TestSplines2

Function TestSplines2

SplinesTest.cpp:19–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17using namespace SL;
18
19void TestSplines2()
20{
21 printf("+ Spline2\n");
22
23 const Vec2f points[] =
24 {
25 { 1.14978f, -137.651f },
26 { -174.87f, -78.9264f },
27 { 51.2561f, 90.6417f },
28 { -183.824f, -39.0125f },
29 { 22.3669f, 21.0507f },
30 { -63.4809f, 145.797f },
31 { 16.1387f, -137.128f },
32 { -49.4056f, 159.712f },
33 { 7.183f, -90.0083f },
34 { -164.355f, -189.983f },
35 { -180.224f, 42.4843f },
36 { 102.902f, 118.445f },
37 { 8.07961f, 188.87f },
38 { 160.243f, -126.232f },
39 { -125.71f, -123.763f },
40 { -102.967f, 18.3226f },
41 };
42 const int numPoints = sizeof(points) / sizeof(points[0]);
43
44 Spline2 splines[numPoints + 1];
45
46 int numSplines = SplinesFromPoints(numPoints, points, splines);
47 float sumLen = 0.0f;
48
49 printf("\ninfo:\n");
50 for (int i = 0; i < numSplines; i++)
51 {
52 float len = Length(splines[i], 0.01f);
53 Bounds2 bb = ExactBounds(splines[i]);
54
55 printf(" %2d: length: %5.1f, bounds [%6.1f, %6.1f], [%6.1f, %6.1f]\n", i, len, bb.mMin.x, bb.mMin.y, bb.mMax.x, bb.mMax.y);
56
57 sumLen += len;
58 }
59 printf("\ntotal length: %6.1f\n", sumLen);
60
61 printf("\ninterpolation:\n");
62 for (int is = 4; is < 6; is++)
63 for (float ts = 0.1f; ts <= 1.0f; ts += 0.2f)
64 {
65 Vec2f ps = Position (splines[is], ts);
66 Vec2f vs = Velocity (splines[is], ts);
67 float cs = Curvature(splines[is], ts);
68
69 printf(" i %d, t %.1f: position [%6.1f, %6.1f], velocity [%6.1f, %6.1f], curvature %6.3f\n", is, ts, ps.x, ps.y, vs.x, vs.y, cs);
70 }
71
72 const Vec2f queryPoints[] =
73 {
74 { 83.7624f, -122.161f },
75 { 126.166f, -40.4692f },
76 { -36.1414f, -9.16203f },

Callers 1

mainFunction · 0.85

Calls 1

FindSplineIntersectionsFunction · 0.85

Tested by

no test coverage detected