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

Function TestSplines3

SplinesTest.cpp:103–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void TestSplines3()
104{
105 printf("+ Spline3\n");
106
107 Vec3f points[] =
108 {
109 { 1.14978f , -137.651f, 11.1f },
110 { -174.87f , -78.9264f, 22.2f },
111 { 51.2561f , 90.6417f , 66.6f },
112 { -183.824f, -39.0125f, 88.8f },
113 { 22.3669f , 21.0507f , 66.6f },
114 { -63.4809f, 145.797f , 44.4f },
115 { 16.1387f , -137.128f, -22.2f },
116 { -49.4056f, 159.712f , 11.1f },
117 { 7.183f , -90.0083f, 11.1f },
118 { -164.355f, -189.983f, 33.3f },
119 { -180.224f, 42.4843f , 11.1f },
120 { 102.902f , 118.445f , 44.4f },
121 { 8.07961f , 188.87f , 66.6f },
122 { 160.243f , -126.232f, 88.8f },
123 { -125.71f , -123.763f, 55.5f },
124 { -102.967f, 18.3226f , 11.1f },
125 };
126 const int numPoints = sizeof(points) / sizeof(points[0]);
127
128 Spline3 splines[numPoints + 1];
129
130 int numSplines = SplinesFromPoints(numPoints, points, splines);
131 float sumLen = 0.0f;
132
133 printf("\ninfo:\n");
134 for (int i = 0; i < numSplines; i++)
135 {
136 float len = Length(splines[i], 0.01f);
137 Bounds3 bb = ExactBounds(splines[i]);
138
139 printf(" %2d: length %5.1f, bounds [%6.1f, %6.1f, %6.1f], [%6.1f, %6.1f, %6.1f]\n", i, len, bb.mMin.x, bb.mMin.y, bb.mMin.z, bb.mMax.x, bb.mMax.y, bb.mMax.z);
140
141 sumLen += len;
142 }
143 printf("\ntotal length: %6.1f\n", sumLen);
144
145 printf("\ninterpolation:\n");
146 for (int is = 4; is < 6; is++)
147 for (float ts = 0.1f; ts <= 1.0f; ts += 0.2f)
148 {
149 Vec3f ps = Position (splines[is], ts);
150 Vec3f vs = Velocity (splines[is], ts);
151 float cs = Curvature(splines[is], ts);
152 float rs = Torsion (splines[is], ts);
153 printf(" i %d, t %.1f: position [%6.1f, %6.1f, %6.1f], velocity [%6.1f, %6.1f, %6.1f], curvature %6.3f, torsion %6.3f\n", is, ts, ps.x, ps.y, ps.z, vs.x, vs.y, vs.z, cs, rs);
154 }
155
156 const Vec3f queryPoints[] =
157 {
158 { 83.7624f , -122.161f, 22.2f },
159 { 126.166f , -40.4692f, 11.1f },
160 { -36.1414f, -9.16203f, 88.8f },

Callers 1

mainFunction · 0.85

Calls 1

FindSplineIntersectionsFunction · 0.85

Tested by

no test coverage detected