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

Function TestRotSplines2

SplinesTest.cpp:195–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195void TestRotSplines2()
196{
197 printf("+ RotSpline2\n");
198
199#if 1
200 const Vec2f dirs[] =
201 {
202 { 1, 0 },
203 { 0, 1 },
204 { -1, 0 },
205 { 0, -1 },
206 { 1, 0 },
207 { 0, -1 },
208 };
209 const int numDirs = sizeof(dirs) / sizeof(dirs[0]);
210
211 RotSpline2 splines[numDirs + 1];
212
213 int numSplines = RotSplinesFromDirs(numDirs, dirs, splines);
214#else
215 const float angles[] =
216 {
217 0,
218 vlf_pi * 4 + vlf_halfPi,
219 vlf_pi,
220 -vlf_halfPi,
221 vlf_twoPi,
222 vlf_twoPi - vlf_halfPi,
223 };
224 const int numAngles = sizeof(angles) / sizeof(angles[0]);
225
226 RotSpline2 splines[numAngles + 1];
227
228 int numSplines = RotSplinesFromAngles(numAngles, angles, splines);
229#endif
230
231 printf("\ninterpolation:\n");
232 for (int is = 0; is < numSplines; is++)
233 for (float ts = 0.1f; ts <= 1.0f; ts += 0.2f)
234 {
235 float w = Rotation (splines[is], ts);
236 float wv = RotVelocity(splines[is], ts);
237
238 Vec2f v(sinf(w), cosf(w));
239
240 printf(" i %d, t %0.2f: direction [%6.3f, %6.3f], rot speed %.2f rad/s\n", is, ts, v.x, v.y, 2.0f * wv);
241 }
242
243 printf("\n");
244}
245
246void TestRotSplines3()
247{

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected