Code-Eli  0.3.6
piecewise_cubic_spline_creator_test_suite.hpp
Go to the documentation of this file.
1 /*********************************************************************************
2 * Copyright (c) 2013 David D. Marshall <ddmarsha@calpoly.edu>
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * David D. Marshall - initial code and implementation
11 ********************************************************************************/
12 
13 #ifndef piecewise_cubic_spline_creator_test_suite_hpp
14 #define piecewise_cubic_spline_creator_test_suite_hpp
15 
16 #include <cmath> // std::pow, std::exp
17 
18 #include <typeinfo> // typeid
19 #include <string> // std::string
20 #include <sstream> // std::stringstream
21 #include <iomanip> // std::setw
22 #include <limits> // std::numeric_limits
23 
24 #include "eli/constants/math.hpp"
27 
28 template<typename data__>
30 {
31  private:
39 
40  tolerance_type tol;
41 
42  protected:
43  void AddTests(const float &)
44  {
45  // add the tests
61  }
62  void AddTests(const double &)
63  {
64  // add the tests
80  }
81  void AddTests(const long double &)
82  {
83  // add the tests
99  }
100 
101  public:
103  {
104  AddTests(data__());
105  }
107  {
108  }
109 
110  private:
111  void octave_print(int figno, const piecewise_curve_type &pc) const
112  {
113  index_type i, pp, ns;
114  data_type tmin, tmax;
115 
116  ns=pc.number_segments();
117  pc.get_parameter_min(tmin);
118  pc.get_parameter_max(tmax);
119 
120  std::cout << "figure(" << figno << ");" << std::endl;
121 
122  // get control points and print
123  std::cout << "cp_x=[";
124  for (pp=0; pp<ns; ++pp)
125  {
126  curve_type bez;
127  pc.get(bez, pp);
128  for (i=0; i<=bez.degree(); ++i)
129  {
130  std::cout << bez.get_control_point(i).x();
131  if (i<bez.degree())
132  std::cout << ", ";
133  else if (pp<ns-1)
134  std::cout << "; ";
135  }
136  std::cout << std::endl;
137  }
138  std::cout << "];" << std::endl;
139 
140  std::cout << "cp_y=[";
141  for (pp=0; pp<ns; ++pp)
142  {
143  curve_type bez;
144  pc.get(bez, pp);
145  for (i=0; i<=bez.degree(); ++i)
146  {
147  std::cout << bez.get_control_point(i).y();
148  if (i<bez.degree())
149  std::cout << ", ";
150  else if (pp<ns-1)
151  std::cout << "; ";
152  }
153  std::cout << std::endl;
154  }
155  std::cout << "];" << std::endl;
156 
157  std::cout << "cp_z=[";
158  for (pp=0; pp<ns; ++pp)
159  {
160  curve_type bez;
161  pc.get(bez, pp);
162  for (i=0; i<=bez.degree(); ++i)
163  {
164  std::cout << bez.get_control_point(i).z();
165  if (i<bez.degree())
166  std::cout << ", ";
167  else if (pp<ns-1)
168  std::cout << "; ";
169  }
170  std::cout << std::endl;
171  }
172  std::cout << "];" << std::endl;
173 
174  // initialize the t parameters
175  std::vector<data__> t(129);
176  for (i=0; i<static_cast<index_type>(t.size()); ++i)
177  {
178  t[i]=tmin+(tmax-tmin)*static_cast<data__>(i)/(t.size()-1);
179  }
180 
181  // set the surface points
182  std::cout << "surf_x=[";
183  for (i=0; i<static_cast<index_type>(t.size()); ++i)
184  {
185  std::cout << pc.f(t[i]).x();
186  if (i<static_cast<index_type>(t.size()-1))
187  std::cout << ", ";
188  }
189  std::cout << "];" << std::endl;
190 
191  std::cout << "surf_y=[";
192  for (i=0; i<static_cast<index_type>(t.size()); ++i)
193  {
194  std::cout << pc.f(t[i]).y();
195  if (i<static_cast<index_type>(t.size()-1))
196  std::cout << ", ";
197  }
198  std::cout << "];" << std::endl;
199 
200  std::cout << "surf_z=[";
201  for (i=0; i<static_cast<index_type>(t.size()); ++i)
202  {
203  std::cout << pc.f(t[i]).z();
204  if (i<static_cast<index_type>(t.size()-1))
205  std::cout << ", ";
206  }
207  std::cout << "];" << std::endl;
208 
209  std::cout << "setenv('GNUTERM', 'x11');" << std::endl;
210  std::cout << "plot3(surf_x, surf_y, surf_z, '-k');" << std::endl;
211  std::cout << "hold on;" << std::endl;
212  std::cout << "plot3(cp_x', cp_y', cp_z', '-ok', 'MarkerFaceColor', [0 0 0]);" << std::endl;
213  std::cout << "hold off;" << std::endl;
214  }
215 
217  {
218  // create with specified times
219  {
220  piecewise_curve_type pc;
221  cubic_spline_creator_type spline_creator(4);
222  std::vector<point_type, Eigen::aligned_allocator<point_type> > pt(16);
223  point_type cp[4];
224  std::vector<data_type> t(5);
225  data_type dt;
226 
227  // set the points and times
228  data_type k=4*(eli::constants::math<data_type>::sqrt_two()-1)/3;
229  pt[0] << 2, 0, 0;
230  pt[1] << 2, k, 0;
231  pt[2] << 2*k, 1, 0;
232  pt[3] << 0, 1, 0;
233  pt[4] << 0, 1, 0;
234  pt[5] << -2*k, 1, 0;
235  pt[6] << -2, k, 0;
236  pt[7] << -2, 0, 0;
237  pt[8] << -2, 0, 0;
238  pt[9] << -2, -k, 0;
239  pt[10] << -2*k, -1, 0;
240  pt[11] << 0, -1, 0;
241  pt[12] << 0, -1, 0;
242  pt[13] << 2*k, -1, 0;
243  pt[14] << 2, -k, 0;
244  pt[15] << 2, 0, 0;
245  t[0]=1;
246  t[1]=3;
247  t[2]=4;
248  t[3]=7;
249  t[4]=9;
250 
251  // set the control points
252  spline_creator.set_segment_control_points(pt[0], pt[1], pt[2], pt[3], 0);
253  spline_creator.set_segment_control_points(pt[4], pt[5], pt[6], pt[7], 1);
254  spline_creator.set_segment_control_points(pt[8], pt[9], pt[10], pt[11], 2);
255  spline_creator.set_segment_control_points(pt[12], pt[13], pt[14], pt[15], 3);
256 
257  // set the times
258  spline_creator.set_t0(t[0]);
259  spline_creator.set_segment_dt(t[1]-t[0], 0);
260  spline_creator.set_segment_dt(t[2]-t[1], 1);
261  spline_creator.set_segment_dt(t[3]-t[2], 2);
262  spline_creator.set_segment_dt(t[4]-t[3], 3);
263 
264  // test control point settings
265  spline_creator.get_segment_control_points(cp[0], cp[1], cp[2], cp[3], 0);
266  TEST_ASSERT(cp[0]==pt[0]);
267  TEST_ASSERT(cp[1]==pt[1]);
268  TEST_ASSERT(cp[2]==pt[2]);
269  TEST_ASSERT(cp[3]==pt[3]);
270  spline_creator.get_segment_control_points(cp[0], cp[1], cp[2], cp[3], 1);
271  TEST_ASSERT(cp[0]==pt[4]);
272  TEST_ASSERT(cp[1]==pt[5]);
273  TEST_ASSERT(cp[2]==pt[6]);
274  TEST_ASSERT(cp[3]==pt[7]);
275  spline_creator.get_segment_control_points(cp[0], cp[1], cp[2], cp[3], 2);
276  TEST_ASSERT(cp[0]==pt[8]);
277  TEST_ASSERT(cp[1]==pt[9]);
278  TEST_ASSERT(cp[2]==pt[10]);
279  TEST_ASSERT(cp[3]==pt[11]);
280  spline_creator.get_segment_control_points(cp[0], cp[1], cp[2], cp[3], 3);
281  TEST_ASSERT(cp[0]==pt[12]);
282  TEST_ASSERT(cp[1]==pt[13]);
283  TEST_ASSERT(cp[2]==pt[14]);
284  TEST_ASSERT(cp[3]==pt[15]);
285 
286  // test time step settings
287  TEST_ASSERT(spline_creator.get_t0()==t[0]);
288  dt=spline_creator.get_segment_dt(0);
289  TEST_ASSERT(dt==t[1]-t[0]);
290  dt=spline_creator.get_segment_dt(1);
291  TEST_ASSERT(dt==t[2]-t[1]);
292  dt=spline_creator.get_segment_dt(2);
293  TEST_ASSERT(dt==t[3]-t[2]);
294  dt=spline_creator.get_segment_dt(3);
295  TEST_ASSERT(dt==t[4]-t[3]);
296 
297  // create the spline
298  TEST_ASSERT(spline_creator.create(pc));
299  }
300 
301  // create with default times
302  {
303  piecewise_curve_type pc;
304  cubic_spline_creator_type spline_creator(4);
305  std::vector<point_type, Eigen::aligned_allocator<point_type> > pt(16);
306  point_type cp[4];
307  data_type dt;
308 
309  // set the points and times
310  data_type k=4*(eli::constants::math<data_type>::sqrt_two()-1)/3;
311  pt[0] << 2, 0, 0;
312  pt[1] << 2, k, 0;
313  pt[2] << 2*k, 1, 0;
314  pt[3] << 0, 1, 0;
315  pt[4] << 0, 1, 0;
316  pt[5] << -2*k, 1, 0;
317  pt[6] << -2, k, 0;
318  pt[7] << -2, 0, 0;
319  pt[8] << -2, 0, 0;
320  pt[9] << -2, -k, 0;
321  pt[10] << -2*k, -1, 0;
322  pt[11] << 0, -1, 0;
323  pt[12] << 0, -1, 0;
324  pt[13] << 2*k, -1, 0;
325  pt[14] << 2, -k, 0;
326  pt[15] << 2, 0, 0;
327 
328  // set the control points
329  spline_creator.set_segment_control_points(pt[0], pt[1], pt[2], pt[3], 0);
330  spline_creator.set_segment_control_points(pt[4], pt[5], pt[6], pt[7], 1);
331  spline_creator.set_segment_control_points(pt[8], pt[9], pt[10], pt[11], 2);
332  spline_creator.set_segment_control_points(pt[12], pt[13], pt[14], pt[15], 3);
333 
334  // test control point settings
335  spline_creator.get_segment_control_points(cp[0], cp[1], cp[2], cp[3], 0);
336  TEST_ASSERT(cp[0]==pt[0]);
337  TEST_ASSERT(cp[1]==pt[1]);
338  TEST_ASSERT(cp[2]==pt[2]);
339  TEST_ASSERT(cp[3]==pt[3]);
340  spline_creator.get_segment_control_points(cp[0], cp[1], cp[2], cp[3], 1);
341  TEST_ASSERT(cp[0]==pt[4]);
342  TEST_ASSERT(cp[1]==pt[5]);
343  TEST_ASSERT(cp[2]==pt[6]);
344  TEST_ASSERT(cp[3]==pt[7]);
345  spline_creator.get_segment_control_points(cp[0], cp[1], cp[2], cp[3], 2);
346  TEST_ASSERT(cp[0]==pt[8]);
347  TEST_ASSERT(cp[1]==pt[9]);
348  TEST_ASSERT(cp[2]==pt[10]);
349  TEST_ASSERT(cp[3]==pt[11]);
350  spline_creator.get_segment_control_points(cp[0], cp[1], cp[2], cp[3], 3);
351  TEST_ASSERT(cp[0]==pt[12]);
352  TEST_ASSERT(cp[1]==pt[13]);
353  TEST_ASSERT(cp[2]==pt[14]);
354  TEST_ASSERT(cp[3]==pt[15]);
355 
356  // test time step settings
357  TEST_ASSERT(spline_creator.get_t0()==0);
358  dt=spline_creator.get_segment_dt(0);
359  TEST_ASSERT(dt==1);
360  dt=spline_creator.get_segment_dt(1);
361  TEST_ASSERT(dt==1);
362  dt=spline_creator.get_segment_dt(2);
363  TEST_ASSERT(dt==1);
364  dt=spline_creator.get_segment_dt(3);
365  TEST_ASSERT(dt==1);
366 
367  // create the spline
368  TEST_ASSERT(spline_creator.create(pc));
369  }
370  }
371 
373  {
374  // create with specified times
375  {
376  piecewise_curve_type pc;
377  cubic_spline_creator_type spline_creator(4);
378  point_type pt_b, pt_a;
379  std::vector<point_type, Eigen::aligned_allocator<point_type> > pt(5), m0(4), m1(4);
380  std::vector<data_type> t(5);
381  data_type dt;
382  index_type i, nseg;
383 
384  // set the points and times
385  pt[0] << 2, 0, 0;
386  pt[1] << 1, 1, 0;
387  pt[2] << 2, 1, 1;
388  pt[3] << 0, 2, 1;
389  pt[4] << 0, 1, 0;
390  m0[0] << 0, 1, 0;
391  m1[0] << 1, 1, 1;
392  m0[1] << 1, 1, 1;
393  m1[1] << 0, 1, 0;
394  m0[2] << 1, 0, 1;
395  m1[2] << 1, 1, 1;
396  m0[3] << 0, 1, 1;
397  m1[3] << 1, 1, 0;
398  t[0]=1;
399  t[1]=3;
400  t[2]=4;
401  t[3]=7;
402  t[4]=9;
403 
404  // set the times
405  spline_creator.set_t0(t[0]);
406  spline_creator.set_segment_dt(t[1]-t[0], 0);
407  spline_creator.set_segment_dt(t[2]-t[1], 1);
408  spline_creator.set_segment_dt(t[3]-t[2], 2);
409  spline_creator.set_segment_dt(t[4]-t[3], 3);
410 
411  // set the points and slopes
412  spline_creator.set_segment_point_slope(pt[0], m0[0], pt[1], m1[0], 0);
413  spline_creator.set_segment_point_slope(pt[1], m0[1], pt[2], m1[1], 1);
414  spline_creator.set_segment_point_slope(pt[2], m0[2], pt[3], m1[2], 2);
415  spline_creator.set_segment_point_slope(pt[3], m0[3], pt[4], m1[3], 3);
416 
417  // test time step settings
418  TEST_ASSERT(spline_creator.get_t0()==t[0]);
419  dt=spline_creator.get_segment_dt(0);
420  TEST_ASSERT(dt==t[1]-t[0]);
421  dt=spline_creator.get_segment_dt(1);
422  TEST_ASSERT(dt==t[2]-t[1]);
423  dt=spline_creator.get_segment_dt(2);
424  TEST_ASSERT(dt==t[3]-t[2]);
425  dt=spline_creator.get_segment_dt(3);
426  TEST_ASSERT(dt==t[4]-t[3]);
427 
428  // create the spline
429  TEST_ASSERT(spline_creator.create(pc));
430 
431  // check the number segments
432  nseg=pc.number_segments();
433  TEST_ASSERT(nseg==static_cast<index_type>(pt.size()-1));
434 
435  // check the starting time
436  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
437 
438  // test the curve
439  data_type small(std::numeric_limits<data_type>::epsilon());
440  i=0;
441  pt_a=pc.f(t[i]);
442  TEST_ASSERT(tol.approximately_equal(pt_a, pt[i]));
443  pt_b=pc.fp(t[i]);
444  TEST_ASSERT(tol.approximately_equal(pt_b, m0[i]));
445  for (i=1; i<nseg-1; ++i)
446  {
447  pt_b=pc.f(t[i]*(1+small));
448  pt_a=pc.f(t[i]*(1-small));
449  TEST_ASSERT(tol.approximately_equal(pt_a, pt[i]));
450  TEST_ASSERT(tol.approximately_equal(pt_b, pt[i]));
451  pt_b=pc.fp(t[i]*(1+small));
452  pt_a=pc.fp(t[i]*(1-small));
453  TEST_ASSERT(tol.approximately_equal(pt_a, m1[i-1]));
454 // FIX: Need method to obtain the derivatives on both sides of point
455 // TEST_ASSERT(tol.approximately_equal(pt_b, m0[i]));
456  }
457  pt_a=pc.f(t[i+1]);
458  TEST_ASSERT(tol.approximately_equal(pt_a, pt[i+1]));
459  pt_b=pc.fp(t[i+1]);
460  TEST_ASSERT(tol.approximately_equal(pt_b, m1[i]));
461  }
462 
463  // create with default times
464  {
465  piecewise_curve_type pc;
466  cubic_spline_creator_type spline_creator(4);
467  point_type pt_b, pt_a;
468  std::vector<point_type, Eigen::aligned_allocator<point_type> > pt(5), m0(4), m1(4);
469  data_type dt;
470  index_type i, nseg;
471 
472  // set the points and times
473  pt[0] << 2, 0, 0;
474  pt[1] << 1, 1, 0;
475  pt[2] << 2, 1, 1;
476  pt[3] << 0, 2, 1;
477  pt[4] << 0, 1, 0;
478  m0[0] << 0, 1, 0;
479  m1[0] << 1, 1, 1;
480  m0[1] << 1, 1, 1;
481  m1[1] << 0, 1, 0;
482  m0[2] << 1, 0, 1;
483  m1[2] << 1, 1, 1;
484  m0[3] << 0, 1, 1;
485  m1[3] << 1, 1, 0;
486 
487  // set the points and slopes
488  spline_creator.set_segment_point_slope(pt[0], m0[0], pt[1], m1[0], 0);
489  spline_creator.set_segment_point_slope(pt[1], m0[1], pt[2], m1[1], 1);
490  spline_creator.set_segment_point_slope(pt[2], m0[2], pt[3], m1[2], 2);
491  spline_creator.set_segment_point_slope(pt[3], m0[3], pt[4], m1[3], 3);
492 
493  // test time step settings
494  TEST_ASSERT(spline_creator.get_t0()==0);
495  dt=spline_creator.get_segment_dt(0);
496  TEST_ASSERT(dt==1);
497  dt=spline_creator.get_segment_dt(1);
498  TEST_ASSERT(dt==1);
499  dt=spline_creator.get_segment_dt(2);
500  TEST_ASSERT(dt==1);
501  dt=spline_creator.get_segment_dt(3);
502  TEST_ASSERT(dt==1);
503 
504  // create the spline
505  TEST_ASSERT(spline_creator.create(pc));
506 
507  // check the number segments
508  nseg=pc.number_segments();
509  TEST_ASSERT(nseg==static_cast<index_type>(pt.size()-1));
510 
511  // check the starting time
512  TEST_ASSERT(tol.approximately_equal(0, pc.get_t0()));
513 
514  // test the curve
515  data_type small(std::numeric_limits<data_type>::epsilon());
516  i=0;
517  pt_a=pc.f(static_cast<data_type>(i));
518  TEST_ASSERT(tol.approximately_equal(pt_a, pt[i]));
519  pt_b=pc.fp(static_cast<data_type>(i));
520  TEST_ASSERT(tol.approximately_equal(pt_b, m0[i]));
521  for (i=1; i<nseg-1; ++i)
522  {
523  pt_b=pc.f(i*(1+small));
524  pt_a=pc.f(i*(1-small));
525  TEST_ASSERT(tol.approximately_equal(pt_a, pt[i]));
526  TEST_ASSERT(tol.approximately_equal(pt_b, pt[i]));
527  pt_b=pc.fp(i*(1+small));
528  pt_a=pc.fp(i*(1-small));
529  TEST_ASSERT(tol.approximately_equal(pt_a, m1[i-1]));
530 // FIX: Need method to obtain the derivatives on both sides of point
531 // TEST_ASSERT(tol.approximately_equal(pt_b, m0[i]));
532  }
533  pt_a=pc.f(static_cast<data_type>(i+1));
534  TEST_ASSERT(tol.approximately_equal(pt_a, pt[i+1]));
535  pt_b=pc.fp(static_cast<data_type>(i+1));
536  TEST_ASSERT(tol.approximately_equal(pt_b, m1[i]));
537  }
538  }
539 
541  {
542  // create with specified times
543  {
544  piecewise_curve_type pc;
545  cubic_spline_creator_type spline_creator(4);
546  point_type pt_b, pt_a;
547  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
548  std::vector<data_type> t(5);
549  data_type dt;
550  index_type i, nseg;
552 
553  // set the points and times
554  pts[0] << 1, 3, 2;
555  pts[1] << 0, 2, 3;
556  pts[2] << -1, 4, 1;
557  pts[3] << 0, 5, 0;
558  pts[4] << 1, 6, -1;
559  t[0]=1;
560  t[1]=3;
561  t[2]=4;
562  t[3]=7;
563  t[4]=9;
564 
565  // set up the creator
566  spline_creator.set_t0(t[0]);
567  for (i=0; i<spline_creator.get_number_segments(); ++i)
568  {
569  spline_creator.set_segment_dt(t[i+1]-t[i], i);
570  }
571  spline_creator.set_chip(pts.begin(), eli::geom::general::NOT_CONNECTED);
572 
573  // test time step settings
574  TEST_ASSERT(spline_creator.get_t0()==t[0]);
575  dt=spline_creator.get_segment_dt(0);
576  TEST_ASSERT(dt==t[1]-t[0]);
577  dt=spline_creator.get_segment_dt(1);
578  TEST_ASSERT(dt==t[2]-t[1]);
579  dt=spline_creator.get_segment_dt(2);
580  TEST_ASSERT(dt==t[3]-t[2]);
581  dt=spline_creator.get_segment_dt(3);
582  TEST_ASSERT(dt==t[4]-t[3]);
583 
584  // create the piecewise curve
585  TEST_ASSERT(spline_creator.create(pc));
586 
587  // check the number segments
588  nseg=pc.number_segments();
589  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
590 
591  // check the starting time
592  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
593 
594  // check the continuity at each point
595  for (i=1; i<nseg; ++i)
596  {
597  cont=pc.continuity(t[i]);
598  TEST_ASSERT(cont==eli::geom::general::C1);
599  }
600  }
601 
602  // create with default times
603  {
604  piecewise_curve_type pc;
605  cubic_spline_creator_type spline_creator(4);
606  point_type pt_b, pt_a;
607  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
608  data_type dt;
609  index_type i, nseg;
611 
612  // set the points and times
613  pts[0] << 1, 3, 2;
614  pts[1] << 0, 2, 3;
615  pts[2] << -1, 4, 1;
616  pts[3] << 0, 5, 0;
617  pts[4] << 1, 6, -1;
618 
619  spline_creator.set_chip(pts.begin(), eli::geom::general::NOT_CONNECTED);
620 
621  // test time step settings
622  TEST_ASSERT(spline_creator.get_t0()==0);
623  dt=spline_creator.get_segment_dt(0);
624  TEST_ASSERT(dt==1);
625  dt=spline_creator.get_segment_dt(1);
626  TEST_ASSERT(dt==1);
627  dt=spline_creator.get_segment_dt(2);
628  TEST_ASSERT(dt==1);
629  dt=spline_creator.get_segment_dt(3);
630  TEST_ASSERT(dt==1);
631 
632  // create the piecewise curve
633  TEST_ASSERT(spline_creator.create(pc));
634 
635  // check the number segments
636  nseg=pc.number_segments();
637  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
638 
639  // check the continuity at each point
640  for (i=1; i<nseg; ++i)
641  {
642  cont=pc.continuity(static_cast<data_type>(i));
643  TEST_ASSERT(cont==eli::geom::general::C1);
644  }
645  }
646  }
647 
649  {
650  // create non-smooth with specified times
651  {
652  piecewise_curve_type pc;
653  cubic_spline_creator_type spline_creator(5);
654  point_type pt_b, pt_a;
655  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
656  std::vector<data_type> t(6);
657  data_type dt;
658  index_type i, nseg;
660 
661  // set the points and times
662  pts[0] << 1, 3, 2;
663  pts[1] << 0, 2, 3;
664  pts[2] << -1, 4, 1;
665  pts[3] << 0, 5, -1;
666  pts[4] << 1, 4, 1;
667  t[0]=1;
668  t[1]=3;
669  t[2]=4;
670  t[3]=7;
671  t[4]=9;
672  t[5]=10;
673 
674  // set up the creator
675  spline_creator.set_t0(t[0]);
676  for (i=0; i<spline_creator.get_number_segments(); ++i)
677  {
678  spline_creator.set_segment_dt(t[i+1]-t[i], i);
679  }
680 
681  spline_creator.set_chip(pts.begin(), eli::geom::general::C0);
682 
683  // test time step settings
684  TEST_ASSERT(spline_creator.get_t0()==t[0]);
685  dt=spline_creator.get_segment_dt(0);
686  TEST_ASSERT(dt==t[1]-t[0]);
687  dt=spline_creator.get_segment_dt(1);
688  TEST_ASSERT(dt==t[2]-t[1]);
689  dt=spline_creator.get_segment_dt(2);
690  TEST_ASSERT(dt==t[3]-t[2]);
691  dt=spline_creator.get_segment_dt(3);
692  TEST_ASSERT(dt==t[4]-t[3]);
693  dt=spline_creator.get_segment_dt(4);
694  TEST_ASSERT(dt==t[5]-t[4]);
695 
696  // create the piecewise curve
697  TEST_ASSERT(spline_creator.create(pc));
698 
699  // check the number segments
700  nseg=pc.number_segments();
701  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()));
702 
703  // check the starting time
704  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
705 
706  // check if closed
707  TEST_ASSERT(pc.closed());
708 
709  // check the continuity at each point
710  for (i=1; i<(nseg-1); ++i)
711  {
712  cont=pc.continuity(t[i]);
713  TEST_ASSERT(cont==eli::geom::general::C1);
714  }
715 
716  // test the end conditions
717  cont=pc.continuity(t[0]);
718  TEST_ASSERT(cont==eli::geom::general::C0);
719  cont=pc.continuity(t[5]);
720  TEST_ASSERT(cont==eli::geom::general::C0);
721  }
722 
723  // create smooth with specified times
724  {
725  piecewise_curve_type pc;
726  cubic_spline_creator_type spline_creator(5);
727  point_type pt_b, pt_a;
728  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
729  std::vector<data_type> t(6);
730  data_type dt;
731  index_type i, nseg;
733 
734  // set the points and times
735  pts[0] << 1, 3, 2;
736  pts[1] << 0, 2, 3;
737  pts[2] << -1, 4, 1;
738  pts[3] << 0, 5, -1;
739  pts[4] << 1, 4, 1;
740  t[0]=1;
741  t[1]=3;
742  t[2]=4;
743  t[3]=7;
744  t[4]=9;
745  t[5]=10;
746 
747  // set up the creator
748  spline_creator.set_t0(t[0]);
749  for (i=0; i<spline_creator.get_number_segments(); ++i)
750  {
751  spline_creator.set_segment_dt(t[i+1]-t[i], i);
752  }
753 
754  spline_creator.set_chip(pts.begin(), eli::geom::general::C1);
755 
756  // test time step settings
757  TEST_ASSERT(spline_creator.get_t0()==t[0]);
758  dt=spline_creator.get_segment_dt(0);
759  TEST_ASSERT(dt==t[1]-t[0]);
760  dt=spline_creator.get_segment_dt(1);
761  TEST_ASSERT(dt==t[2]-t[1]);
762  dt=spline_creator.get_segment_dt(2);
763  TEST_ASSERT(dt==t[3]-t[2]);
764  dt=spline_creator.get_segment_dt(3);
765  TEST_ASSERT(dt==t[4]-t[3]);
766 
767  // create the piecewise curve
768  TEST_ASSERT(spline_creator.create(pc));
769 
770  // check the number segments
771  nseg=pc.number_segments();
772  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()));
773 
774  // check the starting time
775  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
776 
777  // check if closed
778  TEST_ASSERT(pc.closed());
779 
780  // check the continuity at each point
781  for (i=1; i<(nseg-1); ++i)
782  {
783  cont=pc.continuity(t[i]);
784  TEST_ASSERT(cont==eli::geom::general::C1);
785  }
786 
787  // test the end conditions
788  cont=pc.continuity(t[0]);
789  TEST_ASSERT(cont==eli::geom::general::C1);
790  cont=pc.continuity(t[5]);
791  TEST_ASSERT(cont==eli::geom::general::C1);
792  }
793 
794  // create non-smooth with default times
795  {
796  piecewise_curve_type pc;
797  cubic_spline_creator_type spline_creator(5);
798  point_type pt_b, pt_a;
799  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
800  std::vector<data_type> t(6);
801  data_type dt;
802  index_type i, nseg;
804 
805  // set the points and times
806  pts[0] << 1, 3, 2;
807  pts[1] << 0, 2, 3;
808  pts[2] << -1, 4, 1;
809  pts[3] << 0, 5, -1;
810  pts[4] << 1, 4, 1;
811 
812  // set up the creator
813  spline_creator.set_chip(pts.begin(), eli::geom::general::C0);
814 
815  // test time step settings
816  TEST_ASSERT(spline_creator.get_t0()==0);
817  dt=spline_creator.get_segment_dt(0);
818  TEST_ASSERT(dt==1);
819  dt=spline_creator.get_segment_dt(1);
820  TEST_ASSERT(dt==1);
821  dt=spline_creator.get_segment_dt(2);
822  TEST_ASSERT(dt==1);
823  dt=spline_creator.get_segment_dt(3);
824  TEST_ASSERT(dt==1);
825  dt=spline_creator.get_segment_dt(4);
826  TEST_ASSERT(dt==1);
827 
828  // create the piecewise curve
829  TEST_ASSERT(spline_creator.create(pc));
830 
831  // check the number segments
832  nseg=pc.number_segments();
833  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()));
834 
835  // check the starting time
836  TEST_ASSERT(tol.approximately_equal(0, pc.get_t0()));
837 
838  // check if closed
839  TEST_ASSERT(pc.closed());
840 
841  // check the continuity at each point
842  for (i=1; i<(nseg-1); ++i)
843  {
844  cont=pc.continuity(static_cast<data_type>(i));
845  TEST_ASSERT(cont==eli::geom::general::C1);
846  }
847 
848  // test the end conditions
849  cont=pc.continuity(0);
850  TEST_ASSERT(cont==eli::geom::general::C0);
851  cont=pc.continuity(static_cast<data_type>(nseg));
852  TEST_ASSERT(cont==eli::geom::general::C0);
853  }
854 
855  // create smooth with default times
856  {
857  piecewise_curve_type pc;
858  cubic_spline_creator_type spline_creator(5);
859  point_type pt_b, pt_a;
860  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
861  std::vector<data_type> t(6);
862  data_type dt;
863  index_type i, nseg;
865 
866  // set the points and times
867  pts[0] << 1, 3, 2;
868  pts[1] << 0, 2, 3;
869  pts[2] << -1, 4, 1;
870  pts[3] << 0, 5, -1;
871  pts[4] << 1, 4, 1;
872 
873  // set up the creator
874  spline_creator.set_chip(pts.begin(), eli::geom::general::C1);
875 
876  // test time step settings
877  TEST_ASSERT(spline_creator.get_t0()==0);
878  dt=spline_creator.get_segment_dt(0);
879  TEST_ASSERT(dt==1);
880  dt=spline_creator.get_segment_dt(1);
881  TEST_ASSERT(dt==1);
882  dt=spline_creator.get_segment_dt(2);
883  TEST_ASSERT(dt==1);
884  dt=spline_creator.get_segment_dt(3);
885  TEST_ASSERT(dt==1);
886  dt=spline_creator.get_segment_dt(4);
887  TEST_ASSERT(dt==1);
888 
889  // create the piecewise curve
890  TEST_ASSERT(spline_creator.create(pc));
891 
892  // check the number segments
893  nseg=pc.number_segments();
894  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()));
895 
896  // check the starting time
897  TEST_ASSERT(tol.approximately_equal(0, pc.get_t0()));
898 
899  // check if closed
900  TEST_ASSERT(pc.closed());
901 
902  // check the continuity at each point
903  for (i=1; i<(nseg-1); ++i)
904  {
905  cont=pc.continuity(static_cast<data_type>(i));
906  TEST_ASSERT(cont==eli::geom::general::C1);
907  }
908 
909  // test the end conditions
910  cont=pc.continuity(0);
911  TEST_ASSERT(cont==eli::geom::general::C1);
912  cont=pc.continuity(static_cast<data_type>(nseg));
913  TEST_ASSERT(cont==eli::geom::general::C1);
914  }
915  }
916 
918  {
919  // create with specified times
920  {
921  piecewise_curve_type pc;
922  cubic_spline_creator_type spline_creator(4);
923  point_type pt_b, pt_a;
924  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
925  std::vector<data_type> t(5);
926  data_type dt;
927  index_type i, nseg;
929 
930  // set the points and times
931  pts[0] << 1, 3, 2;
932  pts[1] << 0, 2, 3;
933  pts[2] << -1, 4, 1;
934  pts[3] << 0, 5, 0;
935  pts[4] << 1, 6, -1;
936  t[0]=1;
937  t[1]=3;
938  t[2]=4;
939  t[3]=7;
940  t[4]=9;
941 
942  // set up the creator
943  spline_creator.set_t0(t[0]);
944  for (i=0; i<spline_creator.get_number_segments(); ++i)
945  {
946  spline_creator.set_segment_dt(t[i+1]-t[i], i);
947  }
948  spline_creator.set_cardinal(pts.begin(), static_cast<data_type>(0.75), eli::geom::general::NOT_CONNECTED);
949 
950  // test time step settings
951  TEST_ASSERT(spline_creator.get_t0()==t[0]);
952  dt=spline_creator.get_segment_dt(0);
953  TEST_ASSERT(dt==t[1]-t[0]);
954  dt=spline_creator.get_segment_dt(1);
955  TEST_ASSERT(dt==t[2]-t[1]);
956  dt=spline_creator.get_segment_dt(2);
957  TEST_ASSERT(dt==t[3]-t[2]);
958  dt=spline_creator.get_segment_dt(3);
959  TEST_ASSERT(dt==t[4]-t[3]);
960 
961  // create the piecewise curve
962  TEST_ASSERT(spline_creator.create(pc));
963 
964  // check the number segments
965  nseg=pc.number_segments();
966  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
967 
968  // check the starting time
969  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
970 
971  // check the continuity at each point
972  for (i=1; i<nseg; ++i)
973  {
974  cont=pc.continuity(t[i]);
975  TEST_ASSERT(cont==eli::geom::general::C1);
976  }
977  }
978 
979  // create with default times
980  {
981  piecewise_curve_type pc;
982  cubic_spline_creator_type spline_creator(4);
983  point_type pt_b, pt_a;
984  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
985  data_type dt;
986  index_type i, nseg;
988 
989  // set the points and times
990  pts[0] << 1, 3, 2;
991  pts[1] << 0, 2, 3;
992  pts[2] << -1, 4, 1;
993  pts[3] << 0, 5, 0;
994  pts[4] << 1, 6, -1;
995 
996  spline_creator.set_cardinal(pts.begin(), static_cast<data_type>(0.75), eli::geom::general::NOT_CONNECTED);
997 
998  // test time step settings
999  TEST_ASSERT(spline_creator.get_t0()==0);
1000  dt=spline_creator.get_segment_dt(0);
1001  TEST_ASSERT(dt==1);
1002  dt=spline_creator.get_segment_dt(1);
1003  TEST_ASSERT(dt==1);
1004  dt=spline_creator.get_segment_dt(2);
1005  TEST_ASSERT(dt==1);
1006  dt=spline_creator.get_segment_dt(3);
1007  TEST_ASSERT(dt==1);
1008 
1009  // create the piecewise curve
1010  TEST_ASSERT(spline_creator.create(pc));
1011 
1012  // check the number segments
1013  nseg=pc.number_segments();
1014  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
1015 
1016  // check the continuity at each point
1017  for (i=1; i<nseg; ++i)
1018  {
1019  cont=pc.continuity(static_cast<data_type>(i));
1020  TEST_ASSERT(cont==eli::geom::general::C1);
1021  }
1022  }
1023  }
1024 
1026  {
1027  // create non-smooth with specified times
1028  {
1029  piecewise_curve_type pc;
1030  cubic_spline_creator_type spline_creator(5);
1031  point_type pt_b, pt_a;
1032  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1033  std::vector<data_type> t(6);
1034  data_type dt;
1035  index_type i, nseg;
1037 
1038  // set the points and times
1039  pts[0] << 1, 3, 2;
1040  pts[1] << 0, 2, 3;
1041  pts[2] << -1, 4, 1;
1042  pts[3] << 0, 5, -1;
1043  pts[4] << 1, 4, 1;
1044  t[0]=1;
1045  t[1]=3;
1046  t[2]=4;
1047  t[3]=7;
1048  t[4]=9;
1049  t[5]=10;
1050 
1051  // set up the creator
1052  spline_creator.set_t0(t[0]);
1053  for (i=0; i<spline_creator.get_number_segments(); ++i)
1054  {
1055  spline_creator.set_segment_dt(t[i+1]-t[i], i);
1056  }
1057 
1058  spline_creator.set_cardinal(pts.begin(), static_cast<data_type>(0.75), eli::geom::general::C0);
1059 
1060  // test time step settings
1061  TEST_ASSERT(spline_creator.get_t0()==t[0]);
1062  dt=spline_creator.get_segment_dt(0);
1063  TEST_ASSERT(dt==t[1]-t[0]);
1064  dt=spline_creator.get_segment_dt(1);
1065  TEST_ASSERT(dt==t[2]-t[1]);
1066  dt=spline_creator.get_segment_dt(2);
1067  TEST_ASSERT(dt==t[3]-t[2]);
1068  dt=spline_creator.get_segment_dt(3);
1069  TEST_ASSERT(dt==t[4]-t[3]);
1070  dt=spline_creator.get_segment_dt(4);
1071  TEST_ASSERT(dt==t[5]-t[4]);
1072 
1073  // create the piecewise curve
1074  TEST_ASSERT(spline_creator.create(pc));
1075 
1076  // check the number segments
1077  nseg=pc.number_segments();
1078  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()));
1079 
1080  // check the starting time
1081  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
1082 
1083  // check if closed
1084  TEST_ASSERT(pc.closed());
1085 
1086  // check the continuity at each point
1087  for (i=1; i<(nseg-1); ++i)
1088  {
1089  cont=pc.continuity(t[i]);
1090  TEST_ASSERT(cont==eli::geom::general::C1);
1091  }
1092 
1093  // test the end conditions
1094  cont=pc.continuity(t[0]);
1095  TEST_ASSERT(cont==eli::geom::general::C0);
1096  cont=pc.continuity(t[5]);
1097  TEST_ASSERT(cont==eli::geom::general::C0);
1098  }
1099 
1100  // create smooth with specified times
1101  {
1102  piecewise_curve_type pc;
1103  cubic_spline_creator_type spline_creator(5);
1104  point_type pt_b, pt_a;
1105  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1106  std::vector<data_type> t(6);
1107  data_type dt;
1108  index_type i, nseg;
1110 
1111  // set the points and times
1112  pts[0] << 1, 3, 2;
1113  pts[1] << 0, 2, 3;
1114  pts[2] << -1, 4, 1;
1115  pts[3] << 0, 5, -1;
1116  pts[4] << 1, 4, 1;
1117  t[0]=1;
1118  t[1]=3;
1119  t[2]=4;
1120  t[3]=7;
1121  t[4]=9;
1122  t[5]=10;
1123 
1124  // set up the creator
1125  spline_creator.set_t0(t[0]);
1126  for (i=0; i<spline_creator.get_number_segments(); ++i)
1127  {
1128  spline_creator.set_segment_dt(t[i+1]-t[i], i);
1129  }
1130 
1131  spline_creator.set_cardinal(pts.begin(), static_cast<data_type>(0.75), eli::geom::general::C1);
1132 
1133  // test time step settings
1134  TEST_ASSERT(spline_creator.get_t0()==t[0]);
1135  dt=spline_creator.get_segment_dt(0);
1136  TEST_ASSERT(dt==t[1]-t[0]);
1137  dt=spline_creator.get_segment_dt(1);
1138  TEST_ASSERT(dt==t[2]-t[1]);
1139  dt=spline_creator.get_segment_dt(2);
1140  TEST_ASSERT(dt==t[3]-t[2]);
1141  dt=spline_creator.get_segment_dt(3);
1142  TEST_ASSERT(dt==t[4]-t[3]);
1143 
1144  // create the piecewise curve
1145  TEST_ASSERT(spline_creator.create(pc));
1146 
1147  // check the number segments
1148  nseg=pc.number_segments();
1149  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()));
1150 
1151  // check the starting time
1152  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
1153 
1154  // check if closed
1155  TEST_ASSERT(pc.closed());
1156 
1157  // check the continuity at each point
1158  for (i=1; i<(nseg-1); ++i)
1159  {
1160  cont=pc.continuity(t[i]);
1161  TEST_ASSERT(cont==eli::geom::general::C1);
1162  }
1163 
1164  // test the end conditions
1165  cont=pc.continuity(t[0]);
1166  TEST_ASSERT(cont==eli::geom::general::C1);
1167  cont=pc.continuity(t[5]);
1168  TEST_ASSERT(cont==eli::geom::general::C1);
1169  }
1170 
1171  // create non-smooth with default times
1172  {
1173  piecewise_curve_type pc;
1174  cubic_spline_creator_type spline_creator(5);
1175  point_type pt_b, pt_a;
1176  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1177  std::vector<data_type> t(6);
1178  data_type dt;
1179  index_type i, nseg;
1181 
1182  // set the points and times
1183  pts[0] << 1, 3, 2;
1184  pts[1] << 0, 2, 3;
1185  pts[2] << -1, 4, 1;
1186  pts[3] << 0, 5, -1;
1187  pts[4] << 1, 4, 1;
1188 
1189  // set up the creator
1190  spline_creator.set_cardinal(pts.begin(), static_cast<data_type>(0.75), eli::geom::general::C0);
1191 
1192  // test time step settings
1193  TEST_ASSERT(spline_creator.get_t0()==0);
1194  dt=spline_creator.get_segment_dt(0);
1195  TEST_ASSERT(dt==1);
1196  dt=spline_creator.get_segment_dt(1);
1197  TEST_ASSERT(dt==1);
1198  dt=spline_creator.get_segment_dt(2);
1199  TEST_ASSERT(dt==1);
1200  dt=spline_creator.get_segment_dt(3);
1201  TEST_ASSERT(dt==1);
1202  dt=spline_creator.get_segment_dt(4);
1203  TEST_ASSERT(dt==1);
1204 
1205  // create the piecewise curve
1206  TEST_ASSERT(spline_creator.create(pc));
1207 
1208  // check the number segments
1209  nseg=pc.number_segments();
1210  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()));
1211 
1212  // check the starting time
1213  TEST_ASSERT(tol.approximately_equal(0, pc.get_t0()));
1214 
1215  // check if closed
1216  TEST_ASSERT(pc.closed());
1217 
1218  // check the continuity at each point
1219  for (i=1; i<(nseg-1); ++i)
1220  {
1221  cont=pc.continuity(static_cast<data_type>(i));
1222  TEST_ASSERT(cont==eli::geom::general::C1);
1223  }
1224 
1225  // test the end conditions
1226  cont=pc.continuity(0);
1227  TEST_ASSERT(cont==eli::geom::general::C0);
1228  cont=pc.continuity(static_cast<data_type>(nseg));
1229  TEST_ASSERT(cont==eli::geom::general::C0);
1230  }
1231 
1232  // create smooth with default times
1233  {
1234  piecewise_curve_type pc;
1235  cubic_spline_creator_type spline_creator(5);
1236  point_type pt_b, pt_a;
1237  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1238  std::vector<data_type> t(6);
1239  data_type dt;
1240  index_type i, nseg;
1242 
1243  // set the points and times
1244  pts[0] << 1, 3, 2;
1245  pts[1] << 0, 2, 3;
1246  pts[2] << -1, 4, 1;
1247  pts[3] << 0, 5, -1;
1248  pts[4] << 1, 4, 1;
1249 
1250  // set up the creator
1251  spline_creator.set_cardinal(pts.begin(), static_cast<data_type>(0.75), eli::geom::general::C1);
1252 
1253  // test time step settings
1254  TEST_ASSERT(spline_creator.get_t0()==0);
1255  dt=spline_creator.get_segment_dt(0);
1256  TEST_ASSERT(dt==1);
1257  dt=spline_creator.get_segment_dt(1);
1258  TEST_ASSERT(dt==1);
1259  dt=spline_creator.get_segment_dt(2);
1260  TEST_ASSERT(dt==1);
1261  dt=spline_creator.get_segment_dt(3);
1262  TEST_ASSERT(dt==1);
1263  dt=spline_creator.get_segment_dt(4);
1264  TEST_ASSERT(dt==1);
1265 
1266  // create the piecewise curve
1267  TEST_ASSERT(spline_creator.create(pc));
1268 
1269  // check the number segments
1270  nseg=pc.number_segments();
1271  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()));
1272 
1273  // check the starting time
1274  TEST_ASSERT(tol.approximately_equal(0, pc.get_t0()));
1275 
1276  // check if closed
1277  TEST_ASSERT(pc.closed());
1278 
1279  // check the continuity at each point
1280  for (i=1; i<(nseg-1); ++i)
1281  {
1282  cont=pc.continuity(static_cast<data_type>(i));
1283  TEST_ASSERT(cont==eli::geom::general::C1);
1284  }
1285 
1286  // test the end conditions
1287  cont=pc.continuity(0);
1288  TEST_ASSERT(cont==eli::geom::general::C1);
1289  cont=pc.continuity(static_cast<data_type>(nseg));
1290  TEST_ASSERT(cont==eli::geom::general::C1);
1291  }
1292  }
1293 
1295  {
1296  // create with specified times
1297  {
1298  piecewise_curve_type pc;
1299  cubic_spline_creator_type spline_creator(4);
1300  point_type pt_b, pt_a;
1301  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1302  std::vector<data_type> t(5);
1303  data_type dt;
1304  index_type i, nseg;
1306 
1307  // set the points and times
1308  pts[0] << 1, 3, 2;
1309  pts[1] << 0, 2, 3;
1310  pts[2] << -1, 4, 1;
1311  pts[3] << 0, 5, 0;
1312  pts[4] << 1, 6, -1;
1313  t[0]=1;
1314  t[1]=3;
1315  t[2]=4;
1316  t[3]=7;
1317  t[4]=9;
1318 
1319  // set up the creator
1320  spline_creator.set_t0(t[0]);
1321  for (i=0; i<spline_creator.get_number_segments(); ++i)
1322  {
1323  spline_creator.set_segment_dt(t[i+1]-t[i], i);
1324  }
1325  spline_creator.set_catmull_rom(pts.begin(), eli::geom::general::NOT_CONNECTED);
1326 
1327  // test time step settings
1328  TEST_ASSERT(spline_creator.get_t0()==t[0]);
1329  dt=spline_creator.get_segment_dt(0);
1330  TEST_ASSERT(dt==t[1]-t[0]);
1331  dt=spline_creator.get_segment_dt(1);
1332  TEST_ASSERT(dt==t[2]-t[1]);
1333  dt=spline_creator.get_segment_dt(2);
1334  TEST_ASSERT(dt==t[3]-t[2]);
1335  dt=spline_creator.get_segment_dt(3);
1336  TEST_ASSERT(dt==t[4]-t[3]);
1337 
1338  // create the piecewise curve
1339  TEST_ASSERT(spline_creator.create(pc));
1340 
1341  // check the number segments
1342  nseg=pc.number_segments();
1343  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
1344 
1345  // check the starting time
1346  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
1347 
1348  // check the continuity at each point
1349  for (i=1; i<nseg; ++i)
1350  {
1351  cont=pc.continuity(t[i]);
1352  TEST_ASSERT(cont==eli::geom::general::C1);
1353  }
1354  }
1355 
1356  // create with default times
1357  {
1358  piecewise_curve_type pc;
1359  cubic_spline_creator_type spline_creator(4);
1360  point_type pt_b, pt_a;
1361  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1362  data_type dt;
1363  index_type i, nseg;
1365 
1366  // set the points and times
1367  pts[0] << 1, 3, 2;
1368  pts[1] << 0, 2, 3;
1369  pts[2] << -1, 4, 1;
1370  pts[3] << 0, 5, 0;
1371  pts[4] << 1, 6, -1;
1372 
1373  spline_creator.set_catmull_rom(pts.begin(), eli::geom::general::NOT_CONNECTED);
1374 
1375  // test time step settings
1376  TEST_ASSERT(spline_creator.get_t0()==0);
1377  dt=spline_creator.get_segment_dt(0);
1378  TEST_ASSERT(dt==1);
1379  dt=spline_creator.get_segment_dt(1);
1380  TEST_ASSERT(dt==1);
1381  dt=spline_creator.get_segment_dt(2);
1382  TEST_ASSERT(dt==1);
1383  dt=spline_creator.get_segment_dt(3);
1384  TEST_ASSERT(dt==1);
1385 
1386  // create the piecewise curve
1387  TEST_ASSERT(spline_creator.create(pc));
1388 
1389  // check the number segments
1390  nseg=pc.number_segments();
1391  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
1392 
1393  // check the continuity at each point
1394  for (i=1; i<nseg; ++i)
1395  {
1396  cont=pc.continuity(static_cast<data_type>(i));
1397  TEST_ASSERT(cont==eli::geom::general::C1);
1398  }
1399  }
1400  }
1401 
1403  {
1404  // create non-smooth with specified times
1405  {
1406  piecewise_curve_type pc;
1407  cubic_spline_creator_type spline_creator(5);
1408  point_type pt_b, pt_a;
1409  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1410  std::vector<data_type> t(6);
1411  data_type dt;
1412  index_type i, nseg;
1414 
1415  // set the points and times
1416  pts[0] << 1, 3, 2;
1417  pts[1] << 0, 2, 3;
1418  pts[2] << -1, 4, 1;
1419  pts[3] << 0, 5, -1;
1420  pts[4] << 1, 4, 1;
1421  t[0]=1;
1422  t[1]=3;
1423  t[2]=4;
1424  t[3]=7;
1425  t[4]=9;
1426  t[5]=10;
1427 
1428  // set up the creator
1429  spline_creator.set_t0(t[0]);
1430  for (i=0; i<spline_creator.get_number_segments(); ++i)
1431  {
1432  spline_creator.set_segment_dt(t[i+1]-t[i], i);
1433  }
1434 
1435  spline_creator.set_catmull_rom(pts.begin(), eli::geom::general::C0);
1436 
1437  // test time step settings
1438  TEST_ASSERT(spline_creator.get_t0()==t[0]);
1439  dt=spline_creator.get_segment_dt(0);
1440  TEST_ASSERT(dt==t[1]-t[0]);
1441  dt=spline_creator.get_segment_dt(1);
1442  TEST_ASSERT(dt==t[2]-t[1]);
1443  dt=spline_creator.get_segment_dt(2);
1444  TEST_ASSERT(dt==t[3]-t[2]);
1445  dt=spline_creator.get_segment_dt(3);
1446  TEST_ASSERT(dt==t[4]-t[3]);
1447  dt=spline_creator.get_segment_dt(4);
1448  TEST_ASSERT(dt==t[5]-t[4]);
1449 
1450  // create the piecewise curve
1451  TEST_ASSERT(spline_creator.create(pc));
1452 
1453  // check the number segments
1454  nseg=pc.number_segments();
1455  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()));
1456 
1457  // check the starting time
1458  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
1459 
1460  // check if closed
1461  TEST_ASSERT(pc.closed());
1462 
1463  // check the continuity at each point
1464  for (i=1; i<(nseg-1); ++i)
1465  {
1466  cont=pc.continuity(t[i]);
1467  TEST_ASSERT(cont==eli::geom::general::C1);
1468  }
1469 
1470  // test the end conditions
1471  cont=pc.continuity(t[0]);
1472  TEST_ASSERT(cont==eli::geom::general::C0);
1473  cont=pc.continuity(t[5]);
1474  TEST_ASSERT(cont==eli::geom::general::C0);
1475  }
1476 
1477  // create smooth with specified times
1478  {
1479  piecewise_curve_type pc;
1480  cubic_spline_creator_type spline_creator(5);
1481  point_type pt_b, pt_a;
1482  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1483  std::vector<data_type> t(6);
1484  data_type dt;
1485  index_type i, nseg;
1487 
1488  // set the points and times
1489  pts[0] << 1, 3, 2;
1490  pts[1] << 0, 2, 3;
1491  pts[2] << -1, 4, 1;
1492  pts[3] << 0, 5, -1;
1493  pts[4] << 1, 4, 1;
1494  t[0]=1;
1495  t[1]=3;
1496  t[2]=4;
1497  t[3]=7;
1498  t[4]=9;
1499  t[5]=10;
1500 
1501  // set up the creator
1502  spline_creator.set_t0(t[0]);
1503  for (i=0; i<spline_creator.get_number_segments(); ++i)
1504  {
1505  spline_creator.set_segment_dt(t[i+1]-t[i], i);
1506  }
1507 
1508  spline_creator.set_catmull_rom(pts.begin(), eli::geom::general::C1);
1509 
1510  // test time step settings
1511  TEST_ASSERT(spline_creator.get_t0()==t[0]);
1512  dt=spline_creator.get_segment_dt(0);
1513  TEST_ASSERT(dt==t[1]-t[0]);
1514  dt=spline_creator.get_segment_dt(1);
1515  TEST_ASSERT(dt==t[2]-t[1]);
1516  dt=spline_creator.get_segment_dt(2);
1517  TEST_ASSERT(dt==t[3]-t[2]);
1518  dt=spline_creator.get_segment_dt(3);
1519  TEST_ASSERT(dt==t[4]-t[3]);
1520 
1521  // create the piecewise curve
1522  TEST_ASSERT(spline_creator.create(pc));
1523 
1524  // check the number segments
1525  nseg=pc.number_segments();
1526  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()));
1527 
1528  // check the starting time
1529  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
1530 
1531  // check if closed
1532  TEST_ASSERT(pc.closed());
1533 
1534  // check the continuity at each point
1535  for (i=1; i<(nseg-1); ++i)
1536  {
1537  cont=pc.continuity(t[i]);
1538  TEST_ASSERT(cont==eli::geom::general::C1);
1539  }
1540 
1541  // test the end conditions
1542  cont=pc.continuity(t[0]);
1543  TEST_ASSERT(cont==eli::geom::general::C1);
1544  cont=pc.continuity(t[5]);
1545  }
1546 
1547  // create non-smooth with default times
1548  {
1549  piecewise_curve_type pc;
1550  cubic_spline_creator_type spline_creator(5);
1551  point_type pt_b, pt_a;
1552  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1553  std::vector<data_type> t(6);
1554  data_type dt;
1555  index_type i, nseg;
1557 
1558  // set the points and times
1559  pts[0] << 1, 3, 2;
1560  pts[1] << 0, 2, 3;
1561  pts[2] << -1, 4, 1;
1562  pts[3] << 0, 5, -1;
1563  pts[4] << 1, 4, 1;
1564 
1565  // set up the creator
1566  spline_creator.set_catmull_rom(pts.begin(), eli::geom::general::C0);
1567 
1568  // test time step settings
1569  TEST_ASSERT(spline_creator.get_t0()==0);
1570  dt=spline_creator.get_segment_dt(0);
1571  TEST_ASSERT(dt==1);
1572  dt=spline_creator.get_segment_dt(1);
1573  TEST_ASSERT(dt==1);
1574  dt=spline_creator.get_segment_dt(2);
1575  TEST_ASSERT(dt==1);
1576  dt=spline_creator.get_segment_dt(3);
1577  TEST_ASSERT(dt==1);
1578  dt=spline_creator.get_segment_dt(4);
1579  TEST_ASSERT(dt==1);
1580 
1581  // create the piecewise curve
1582  TEST_ASSERT(spline_creator.create(pc));
1583 
1584  // check the number segments
1585  nseg=pc.number_segments();
1586  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()));
1587 
1588  // check the starting time
1589  TEST_ASSERT(tol.approximately_equal(0, pc.get_t0()));
1590 
1591  // check if closed
1592  TEST_ASSERT(pc.closed());
1593 
1594  // check the continuity at each point
1595  for (i=1; i<(nseg-1); ++i)
1596  {
1597  cont=pc.continuity(static_cast<data_type>(i));
1598  TEST_ASSERT(cont==eli::geom::general::C1);
1599  }
1600 
1601  // test the end conditions
1602  cont=pc.continuity(0);
1603  TEST_ASSERT(cont==eli::geom::general::C0);
1604  cont=pc.continuity(static_cast<data_type>(nseg));
1605  TEST_ASSERT(cont==eli::geom::general::C0);
1606  }
1607 
1608  // create smooth with default times
1609  {
1610  piecewise_curve_type pc;
1611  cubic_spline_creator_type spline_creator(5);
1612  point_type pt_b, pt_a;
1613  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1614  std::vector<data_type> t(6);
1615  data_type dt;
1616  index_type i, nseg;
1618 
1619  // set the points and times
1620  pts[0] << 1, 3, 2;
1621  pts[1] << 0, 2, 3;
1622  pts[2] << -1, 4, 1;
1623  pts[3] << 0, 5, -1;
1624  pts[4] << 1, 4, 1;
1625 
1626  // set up the creator
1627  spline_creator.set_catmull_rom(pts.begin(), eli::geom::general::C1);
1628 
1629  // test time step settings
1630  TEST_ASSERT(spline_creator.get_t0()==0);
1631  dt=spline_creator.get_segment_dt(0);
1632  TEST_ASSERT(dt==1);
1633  dt=spline_creator.get_segment_dt(1);
1634  TEST_ASSERT(dt==1);
1635  dt=spline_creator.get_segment_dt(2);
1636  TEST_ASSERT(dt==1);
1637  dt=spline_creator.get_segment_dt(3);
1638  TEST_ASSERT(dt==1);
1639  dt=spline_creator.get_segment_dt(4);
1640  TEST_ASSERT(dt==1);
1641 
1642  // create the piecewise curve
1643  TEST_ASSERT(spline_creator.create(pc));
1644 
1645  // check the number segments
1646  nseg=pc.number_segments();
1647  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()));
1648 
1649  // check the starting time
1650  TEST_ASSERT(tol.approximately_equal(0, pc.get_t0()));
1651 
1652  // check if closed
1653  TEST_ASSERT(pc.closed());
1654 
1655  // check the continuity at each point
1656  for (i=1; i<(nseg-1); ++i)
1657  {
1658  cont=pc.continuity(static_cast<data_type>(i));
1659  TEST_ASSERT(cont==eli::geom::general::C1);
1660  }
1661 
1662  // test the end conditions
1663  cont=pc.continuity(0);
1664  TEST_ASSERT(cont==eli::geom::general::C1);
1665  cont=pc.continuity(static_cast<data_type>(nseg));
1666  }
1667  }
1668 
1670  {
1671  // create with specified times
1672  {
1673  piecewise_curve_type pc;
1674  cubic_spline_creator_type spline_creator(4);
1675  point_type pt_b, pt_a;
1676  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1677  std::vector<data_type> t(5);
1678  data_type dt, ten(0.75), bia(0.75), con(0);
1679  index_type i, nseg;
1681 
1682  // set the points and times
1683  pts[0] << 1, 3, 2;
1684  pts[1] << 0, 2, 3;
1685  pts[2] << -1, 4, 1;
1686  pts[3] << 0, 5, 0;
1687  pts[4] << 1, 6, -1;
1688  t[0]=1;
1689  t[1]=3;
1690  t[2]=4;
1691  t[3]=7;
1692  t[4]=9;
1693 
1694  // set up the creator
1695  spline_creator.set_t0(t[0]);
1696  for (i=0; i<spline_creator.get_number_segments(); ++i)
1697  {
1698  spline_creator.set_segment_dt(t[i+1]-t[i], i);
1699  }
1700  spline_creator.set_kochanek_bartels(pts.begin(), ten, bia, con, eli::geom::general::NOT_CONNECTED);
1701 
1702  // test time step settings
1703  TEST_ASSERT(spline_creator.get_t0()==t[0]);
1704  dt=spline_creator.get_segment_dt(0);
1705  TEST_ASSERT(dt==t[1]-t[0]);
1706  dt=spline_creator.get_segment_dt(1);
1707  TEST_ASSERT(dt==t[2]-t[1]);
1708  dt=spline_creator.get_segment_dt(2);
1709  TEST_ASSERT(dt==t[3]-t[2]);
1710  dt=spline_creator.get_segment_dt(3);
1711  TEST_ASSERT(dt==t[4]-t[3]);
1712 
1713  // create the piecewise curve
1714  TEST_ASSERT(spline_creator.create(pc));
1715 
1716  // check the number segments
1717  nseg=pc.number_segments();
1718  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
1719 
1720  // check the starting time
1721  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
1722 
1723  // check the continuity at each point
1724  for (i=1; i<nseg; ++i)
1725  {
1726  cont=pc.continuity(t[i]);
1727  TEST_ASSERT(cont==eli::geom::general::C1);
1728  }
1729  }
1730 
1731  // create with default times
1732  {
1733  piecewise_curve_type pc;
1734  cubic_spline_creator_type spline_creator(4);
1735  point_type pt_b, pt_a;
1736  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1737  data_type dt, ten(0.75), bia(0.75), con(0);
1738  index_type i, nseg;
1740 
1741  // set the points and times
1742  pts[0] << 1, 3, 2;
1743  pts[1] << 0, 2, 3;
1744  pts[2] << -1, 4, 1;
1745  pts[3] << 0, 5, 0;
1746  pts[4] << 1, 6, -1;
1747 
1748  spline_creator.set_kochanek_bartels(pts.begin(), ten, bia, con, eli::geom::general::NOT_CONNECTED);
1749 
1750  // test time step settings
1751  TEST_ASSERT(spline_creator.get_t0()==0);
1752  dt=spline_creator.get_segment_dt(0);
1753  TEST_ASSERT(dt==1);
1754  dt=spline_creator.get_segment_dt(1);
1755  TEST_ASSERT(dt==1);
1756  dt=spline_creator.get_segment_dt(2);
1757  TEST_ASSERT(dt==1);
1758  dt=spline_creator.get_segment_dt(3);
1759  TEST_ASSERT(dt==1);
1760 
1761  // create the piecewise curve
1762  TEST_ASSERT(spline_creator.create(pc));
1763 
1764  // check the number segments
1765  nseg=pc.number_segments();
1766  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
1767 
1768  // check the continuity at each point
1769  for (i=1; i<nseg; ++i)
1770  {
1771  cont=pc.continuity(static_cast<data_type>(i));
1772  TEST_ASSERT(cont==eli::geom::general::C1);
1773  }
1774  }
1775  }
1776 
1778  {
1779  // create non-smooth with specified times
1780  {
1781  piecewise_curve_type pc;
1782  cubic_spline_creator_type spline_creator(5);
1783  point_type pt_b, pt_a;
1784  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1785  std::vector<data_type> t(6);
1786  data_type dt, ten(0.75), bia(0.75), con(0);
1787  index_type i, nseg;
1789 
1790  // set the points and times
1791  pts[0] << 1, 3, 2;
1792  pts[1] << 0, 2, 3;
1793  pts[2] << -1, 4, 1;
1794  pts[3] << 0, 5, -1;
1795  pts[4] << 1, 4, 1;
1796  t[0]=1;
1797  t[1]=3;
1798  t[2]=4;
1799  t[3]=7;
1800  t[4]=9;
1801  t[5]=10;
1802 
1803  spline_creator.set_t0(t[0]);
1804  for (i=0; i<spline_creator.get_number_segments(); ++i)
1805  {
1806  spline_creator.set_segment_dt(t[i+1]-t[i], i);
1807  }
1808  spline_creator.set_kochanek_bartels(pts.begin(), ten, bia, con, eli::geom::general::C0);
1809 
1810  // test time step settings
1811  TEST_ASSERT(spline_creator.get_t0()==t[0]);
1812  dt=spline_creator.get_segment_dt(0);
1813  TEST_ASSERT(dt==t[1]-t[0]);
1814  dt=spline_creator.get_segment_dt(1);
1815  TEST_ASSERT(dt==t[2]-t[1]);
1816  dt=spline_creator.get_segment_dt(2);
1817  TEST_ASSERT(dt==t[3]-t[2]);
1818  dt=spline_creator.get_segment_dt(3);
1819  TEST_ASSERT(dt==t[4]-t[3]);
1820  dt=spline_creator.get_segment_dt(4);
1821  TEST_ASSERT(dt==t[5]-t[4]);
1822 
1823  // create the piecewise curve
1824  TEST_ASSERT(spline_creator.create(pc));
1825 
1826  // check the number segments
1827  nseg=pc.number_segments();
1828  TEST_ASSERT(nseg==(static_cast<index_type>(pts.size())));
1829 
1830  // check the starting time
1831  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
1832 
1833  // check if closed
1834  TEST_ASSERT(pc.closed());
1835 
1836  // check the continuity at each point
1837  for (i=1; i<(nseg-1); ++i)
1838  {
1839  cont=pc.continuity(t[i]);
1840  TEST_ASSERT(cont==eli::geom::general::C1);
1841  }
1842 
1843  // test the end conditions
1844  cont=pc.continuity(t[0]);
1845  TEST_ASSERT(cont==eli::geom::general::C0);
1846  cont=pc.continuity(t[5]);
1847  TEST_ASSERT(cont==eli::geom::general::C0);
1848  }
1849 
1850  // create smooth with specified times
1851  {
1852  piecewise_curve_type pc;
1853  cubic_spline_creator_type spline_creator(5);
1854  point_type pt_b, pt_a;
1855  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1856  std::vector<data_type> t(6);
1857  data_type dt, ten(0.75), bia(0.75), con(0);
1858  index_type i, nseg;
1860 
1861  // set the points and times
1862  pts[0] << 1, 3, 2;
1863  pts[1] << 0, 2, 3;
1864  pts[2] << -1, 4, 1;
1865  pts[3] << 0, 5, -1;
1866  pts[4] << 1, 4, 1;
1867  t[0]=1;
1868  t[1]=3;
1869  t[2]=4;
1870  t[3]=7;
1871  t[4]=9;
1872  t[5]=10;
1873 
1874  spline_creator.set_t0(t[0]);
1875  for (i=0; i<spline_creator.get_number_segments(); ++i)
1876  {
1877  spline_creator.set_segment_dt(t[i+1]-t[i], i);
1878  }
1879  spline_creator.set_kochanek_bartels(pts.begin(), ten, bia, con, eli::geom::general::C1);
1880 
1881  // test time step settings
1882  TEST_ASSERT(spline_creator.get_t0()==t[0]);
1883  dt=spline_creator.get_segment_dt(0);
1884  TEST_ASSERT(dt==t[1]-t[0]);
1885  dt=spline_creator.get_segment_dt(1);
1886  TEST_ASSERT(dt==t[2]-t[1]);
1887  dt=spline_creator.get_segment_dt(2);
1888  TEST_ASSERT(dt==t[3]-t[2]);
1889  dt=spline_creator.get_segment_dt(3);
1890  TEST_ASSERT(dt==t[4]-t[3]);
1891  dt=spline_creator.get_segment_dt(4);
1892  TEST_ASSERT(dt==t[5]-t[4]);
1893 
1894  // create the piecewise curve
1895  TEST_ASSERT(spline_creator.create(pc));
1896 
1897  // check the number segments
1898  nseg=pc.number_segments();
1899  TEST_ASSERT(nseg==(static_cast<index_type>(pts.size())));
1900 
1901  // check the starting time
1902  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
1903 
1904  // check if closed
1905  TEST_ASSERT(pc.closed());
1906 
1907  // check the continuity at each point
1908  for (i=1; i<(nseg-1); ++i)
1909  {
1910  cont=pc.continuity(t[i]);
1911  TEST_ASSERT(cont==eli::geom::general::C1);
1912  }
1913 
1914  // test the end conditions
1915  cont=pc.continuity(t[0]);
1916  TEST_ASSERT(cont==eli::geom::general::C1);
1917  cont=pc.continuity(t[5]);
1918  TEST_ASSERT(cont==eli::geom::general::C1);
1919  }
1920 
1921  // create non-smooth with default times
1922  {
1923  piecewise_curve_type pc;
1924  cubic_spline_creator_type spline_creator(5);
1925  point_type pt_b, pt_a;
1926  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1927  data_type dt, ten(0.75), bia(0.75), con(0);
1928  index_type i, nseg;
1930 
1931  // set the points and times
1932  pts[0] << 1, 3, 2;
1933  pts[1] << 0, 2, 3;
1934  pts[2] << -1, 4, 1;
1935  pts[3] << 0, 5, -1;
1936  pts[4] << 1, 4, 1;
1937 
1938  spline_creator.set_kochanek_bartels(pts.begin(), ten, bia, con, eli::geom::general::C0);
1939 
1940  // test time step settings
1941  TEST_ASSERT(spline_creator.get_t0()==0);
1942  dt=spline_creator.get_segment_dt(0);
1943  TEST_ASSERT(dt==1);
1944  dt=spline_creator.get_segment_dt(1);
1945  TEST_ASSERT(dt==1);
1946  dt=spline_creator.get_segment_dt(2);
1947  TEST_ASSERT(dt==1);
1948  dt=spline_creator.get_segment_dt(3);
1949  TEST_ASSERT(dt==1);
1950  dt=spline_creator.get_segment_dt(4);
1951  TEST_ASSERT(dt==1);
1952 
1953  // create the piecewise curve
1954  TEST_ASSERT(spline_creator.create(pc));
1955 
1956  // check the number segments
1957  nseg=pc.number_segments();
1958  TEST_ASSERT(nseg==(static_cast<index_type>(pts.size())));
1959 
1960  // check the starting time
1961  TEST_ASSERT(tol.approximately_equal(0, pc.get_t0()));
1962 
1963  // check if closed
1964  TEST_ASSERT(pc.closed());
1965 
1966  // check the continuity at each point
1967  for (i=1; i<(nseg-1); ++i)
1968  {
1969  cont=pc.continuity(static_cast<data_type>(i));
1970  TEST_ASSERT(cont==eli::geom::general::C1);
1971  }
1972 
1973  // test the end conditions
1974  cont=pc.continuity(0);
1975  TEST_ASSERT(cont==eli::geom::general::C0);
1976  cont=pc.continuity(5);
1977  TEST_ASSERT(cont==eli::geom::general::C0);
1978  }
1979 
1980  // create smooth with default times
1981  {
1982  piecewise_curve_type pc;
1983  cubic_spline_creator_type spline_creator(5);
1984  point_type pt_b, pt_a;
1985  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
1986  data_type dt, ten(0.75), bia(0.75), con(0);
1987  index_type i, nseg;
1989 
1990  // set the points and times
1991  pts[0] << 1, 3, 2;
1992  pts[1] << 0, 2, 3;
1993  pts[2] << -1, 4, 1;
1994  pts[3] << 0, 5, -1;
1995  pts[4] << 1, 4, 1;
1996 
1997  spline_creator.set_kochanek_bartels(pts.begin(), ten, bia, con, eli::geom::general::C1);
1998 
1999  // test time step settings
2000  TEST_ASSERT(spline_creator.get_t0()==0);
2001  dt=spline_creator.get_segment_dt(0);
2002  TEST_ASSERT(dt==1);
2003  dt=spline_creator.get_segment_dt(1);
2004  TEST_ASSERT(dt==1);
2005  dt=spline_creator.get_segment_dt(2);
2006  TEST_ASSERT(dt==1);
2007  dt=spline_creator.get_segment_dt(3);
2008  TEST_ASSERT(dt==1);
2009  dt=spline_creator.get_segment_dt(4);
2010  TEST_ASSERT(dt==1);
2011 
2012  // create the piecewise curve
2013  TEST_ASSERT(spline_creator.create(pc));
2014 
2015  // check the number segments
2016  nseg=pc.number_segments();
2017  TEST_ASSERT(nseg==(static_cast<index_type>(pts.size())));
2018 
2019  // check the starting time
2020  TEST_ASSERT(tol.approximately_equal(0, pc.get_t0()));
2021 
2022  // check if closed
2023  TEST_ASSERT(pc.closed());
2024 
2025  // check the continuity at each point
2026  for (i=1; i<(nseg-1); ++i)
2027  {
2028  cont=pc.continuity(static_cast<data_type>(i));
2029  TEST_ASSERT(cont==eli::geom::general::C1);
2030  }
2031 
2032  // test the end conditions
2033  cont=pc.continuity(0);
2034  TEST_ASSERT(cont==eli::geom::general::C1);
2035  cont=pc.continuity(5);
2036  TEST_ASSERT(cont==eli::geom::general::C1);
2037  }
2038  }
2039 
2041  {
2042  // create with specified times
2043  {
2044  piecewise_curve_type pc;
2045  cubic_spline_creator_type spline_creator(4);
2046  point_type pt_b, pt_a;
2047  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
2048  std::vector<data_type> t(5);
2049  data_type dt;
2050  index_type i, nseg;
2052 
2053  // set the points and times
2054  pts[0] << 1, 3, 2;
2055  pts[1] << 0, 2, 3;
2056  pts[2] << -1, 4, 1;
2057  pts[3] << 0, 5, 0;
2058  pts[4] << 1, 6, -1;
2059  t[0]=1;
2060  t[1]=3;
2061  t[2]=4;
2062  t[3]=7;
2063  t[4]=9;
2064 
2065  // set up the creator
2066  spline_creator.set_t0(t[0]);
2067  for (i=0; i<spline_creator.get_number_segments(); ++i)
2068  {
2069  spline_creator.set_segment_dt(t[i+1]-t[i], i);
2070  }
2071  spline_creator.set_cubic_spline(pts.begin());
2072 
2073  // test time step settings
2074  TEST_ASSERT(spline_creator.get_t0()==t[0]);
2075  dt=spline_creator.get_segment_dt(0);
2076  TEST_ASSERT(dt==t[1]-t[0]);
2077  dt=spline_creator.get_segment_dt(1);
2078  TEST_ASSERT(dt==t[2]-t[1]);
2079  dt=spline_creator.get_segment_dt(2);
2080  TEST_ASSERT(dt==t[3]-t[2]);
2081  dt=spline_creator.get_segment_dt(3);
2082  TEST_ASSERT(dt==t[4]-t[3]);
2083 
2084  // create the piecewise curve
2085  TEST_ASSERT(spline_creator.create(pc));
2086 
2087  // check the number segments
2088  nseg=pc.number_segments();
2089  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
2090 
2091  // check the starting time
2092  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
2093 
2094  // check the continuity at each point
2095  for (i=1; i<nseg; ++i)
2096  {
2097  cont=pc.continuity(t[i]);
2098  if ((i==1) || (i==3))
2099  {
2100  TEST_ASSERT(cont==eli::geom::general::C3);
2101  }
2102  else
2103  {
2104  TEST_ASSERT(cont==eli::geom::general::C2);
2105  }
2106  }
2107 
2108  // check the end points
2109  TEST_ASSERT(tol.approximately_equal(pts[0], pc.f(t[0])));
2110  TEST_ASSERT(tol.approximately_equal(pts[4], pc.f(t[4])));
2111  }
2112 
2113  // create with default times
2114  {
2115  piecewise_curve_type pc;
2116  cubic_spline_creator_type spline_creator(4);
2117  point_type pt_b, pt_a;
2118  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
2119  data_type dt;
2120  index_type i, nseg;
2122 
2123  // set the points and times
2124  pts[0] << 1, 3, 2;
2125  pts[1] << 0, 2, 3;
2126  pts[2] << -1, 4, 1;
2127  pts[3] << 0, 5, 0;
2128  pts[4] << 1, 6, -1;
2129 
2130  // set up the creator
2131  spline_creator.set_cubic_spline(pts.begin());
2132 
2133  // test time step settings
2134  TEST_ASSERT(spline_creator.get_t0()==0);
2135  dt=spline_creator.get_segment_dt(0);
2136  TEST_ASSERT(dt==1);
2137  dt=spline_creator.get_segment_dt(1);
2138  TEST_ASSERT(dt==1);
2139  dt=spline_creator.get_segment_dt(2);
2140  TEST_ASSERT(dt==1);
2141  dt=spline_creator.get_segment_dt(3);
2142  TEST_ASSERT(dt==1);
2143 
2144  // create the piecewise curve
2145  TEST_ASSERT(spline_creator.create(pc));
2146 
2147  // check the number segments
2148  nseg=pc.number_segments();
2149  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
2150 
2151  // check the starting time
2152  TEST_ASSERT(tol.approximately_equal(0, pc.get_t0()));
2153 
2154  // check the continuity at each point
2155  for (i=1; i<nseg; ++i)
2156  {
2157  cont=pc.continuity(static_cast<data_type>(i));
2158  if ((i==1) || (i==3))
2159  {
2160  TEST_ASSERT(cont==eli::geom::general::C3);
2161  }
2162  else
2163  {
2164  TEST_ASSERT(cont==eli::geom::general::C2);
2165  }
2166  }
2167 
2168  // check the end points
2169  TEST_ASSERT(tol.approximately_equal(pts[0], pc.f(0)));
2170  TEST_ASSERT(tol.approximately_equal(pts[4], pc.f(4)));
2171  }
2172  }
2173 
2175  {
2176  // create with specified times
2177  {
2178  piecewise_curve_type pc;
2179  cubic_spline_creator_type spline_creator(4);
2180  point_type pt_b, pt_a;
2181  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
2182  std::vector<data_type> t(5);
2183  data_type dt;
2184  index_type i, nseg;
2186 
2187  // set the points and times
2188  pts[0] << 1, 3, 2;
2189  pts[1] << 0, 2, 3;
2190  pts[2] << -1, 4, 1;
2191  pts[3] << 0, 5, 0;
2192  pts[4] << 1, 6, -1;
2193  t[0]=1;
2194  t[1]=3;
2195  t[2]=4;
2196  t[3]=7;
2197  t[4]=9;
2198 
2199  // set up the creator
2200  spline_creator.set_t0(t[0]);
2201  for (i=0; i<spline_creator.get_number_segments(); ++i)
2202  {
2203  spline_creator.set_segment_dt(t[i+1]-t[i], i);
2204  }
2205  point_type m0, m1;
2206  m0 << -1, -1, 1;
2207  m1 << 1, 1, -1;
2208  spline_creator.set_clamped_cubic_spline(pts.begin(), m0, m1);
2209 
2210  // test time step settings
2211  TEST_ASSERT(spline_creator.get_t0()==t[0]);
2212  dt=spline_creator.get_segment_dt(0);
2213  TEST_ASSERT(dt==t[1]-t[0]);
2214  dt=spline_creator.get_segment_dt(1);
2215  TEST_ASSERT(dt==t[2]-t[1]);
2216  dt=spline_creator.get_segment_dt(2);
2217  TEST_ASSERT(dt==t[3]-t[2]);
2218  dt=spline_creator.get_segment_dt(3);
2219  TEST_ASSERT(dt==t[4]-t[3]);
2220 
2221  // create the piecewise curve
2222  TEST_ASSERT(spline_creator.create(pc));
2223 
2224  // check the number segments
2225  nseg=pc.number_segments();
2226  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
2227 
2228  // check the starting time
2229  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
2230 
2231  // check the continuity at each point
2232  for (i=1; i<nseg; ++i)
2233  {
2234  cont=pc.continuity(t[i]);
2235  TEST_ASSERT(cont==eli::geom::general::C2);
2236  }
2237 
2238  // check the end points
2239  TEST_ASSERT(tol.approximately_equal(pts[0], pc.f(t[0])));
2240  TEST_ASSERT(tol.approximately_equal(m0, pc.fp(t[0])));
2241  TEST_ASSERT(tol.approximately_equal(pts[4], pc.f(t[4])));
2242  TEST_ASSERT(tol.approximately_equal(m1, pc.fp(t[4])));
2243  }
2244 
2245  // create with default times
2246  {
2247  piecewise_curve_type pc;
2248  cubic_spline_creator_type spline_creator(4);
2249  point_type pt_b, pt_a;
2250  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
2251  data_type dt;
2252  index_type i, nseg;
2254 
2255  // set the points and times
2256  pts[0] << 1, 3, 2;
2257  pts[1] << 0, 2, 3;
2258  pts[2] << -1, 4, 1;
2259  pts[3] << 0, 5, 0;
2260  pts[4] << 1, 6, -1;
2261 
2262  // set up the creator
2263  point_type m0, m1;
2264  m0 << -1, -1, 1;
2265  m1 << 1, 1, -1;
2266  spline_creator.set_clamped_cubic_spline(pts.begin(), m0, m1);
2267 
2268  // test time step settings
2269  TEST_ASSERT(spline_creator.get_t0()==0);
2270  dt=spline_creator.get_segment_dt(0);
2271  TEST_ASSERT(dt==1);
2272  dt=spline_creator.get_segment_dt(1);
2273  TEST_ASSERT(dt==1);
2274  dt=spline_creator.get_segment_dt(2);
2275  TEST_ASSERT(dt==1);
2276  dt=spline_creator.get_segment_dt(3);
2277  TEST_ASSERT(dt==1);
2278 
2279  // create the piecewise curve
2280  TEST_ASSERT(spline_creator.create(pc));
2281 
2282  // check the number segments
2283  nseg=pc.number_segments();
2284  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
2285 
2286  // check the starting time
2287  TEST_ASSERT(tol.approximately_equal(0, pc.get_t0()));
2288 
2289  // check the continuity at each point
2290  for (i=1; i<nseg; ++i)
2291  {
2292  cont=pc.continuity(static_cast<data_type>(i));
2293  TEST_ASSERT(cont==eli::geom::general::C2);
2294  }
2295 
2296  // check the end points
2297  TEST_ASSERT(tol.approximately_equal(pts[0], pc.f(0)));
2298  TEST_ASSERT(tol.approximately_equal(m0, pc.fp(0)));
2299  TEST_ASSERT(tol.approximately_equal(pts[4], pc.f(4)));
2300  TEST_ASSERT(tol.approximately_equal(m1, pc.fp(4)));
2301  }
2302  }
2303 
2305  {
2306  // create with specified times
2307  {
2308  piecewise_curve_type pc;
2309  cubic_spline_creator_type spline_creator(4);
2310  point_type pt_b, pt_a;
2311  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
2312  std::vector<data_type> t(5);
2313  data_type dt;
2314  index_type i, nseg;
2316 
2317  // set the points and times
2318  pts[0] << 1, 3, 2;
2319  pts[1] << 0, 2, 3;
2320  pts[2] << -1, 4, 1;
2321  pts[3] << 0, 5, 0;
2322  pts[4] << 1, 6, -1;
2323  t[0]=1;
2324  t[1]=3;
2325  t[2]=4;
2326  t[3]=7;
2327  t[4]=9;
2328 
2329  // set up the creator
2330  spline_creator.set_t0(t[0]);
2331  for (i=0; i<spline_creator.get_number_segments(); ++i)
2332  {
2333  spline_creator.set_segment_dt(t[i+1]-t[i], i);
2334  }
2335  spline_creator.set_natural_cubic_spline(pts.begin());
2336 
2337  // test time step settings
2338  TEST_ASSERT(spline_creator.get_t0()==t[0]);
2339  dt=spline_creator.get_segment_dt(0);
2340  TEST_ASSERT(dt==t[1]-t[0]);
2341  dt=spline_creator.get_segment_dt(1);
2342  TEST_ASSERT(dt==t[2]-t[1]);
2343  dt=spline_creator.get_segment_dt(2);
2344  TEST_ASSERT(dt==t[3]-t[2]);
2345  dt=spline_creator.get_segment_dt(3);
2346  TEST_ASSERT(dt==t[4]-t[3]);
2347 
2348  // create the piecewise curve
2349  TEST_ASSERT(spline_creator.create(pc));
2350 
2351  // check the number segments
2352  nseg=pc.number_segments();
2353  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
2354 
2355  // check the starting time
2356  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
2357 
2358  // check the continuity at each point
2359  for (i=1; i<nseg; ++i)
2360  {
2361  cont=pc.continuity(t[i]);
2362  TEST_ASSERT(cont==eli::geom::general::C2);
2363  }
2364 
2365  // check the end points
2366  pt_a.setZero();
2367  TEST_ASSERT(tol.approximately_equal(pts[0], pc.f(t[0])));
2368  TEST_ASSERT(tol.approximately_equal(pt_a, pc.fpp(t[0])));
2369  TEST_ASSERT(tol.approximately_equal(pts[4], pc.f(t[4])));
2370  TEST_ASSERT(tol.approximately_equal(pt_a, pc.fpp(t[4])));
2371  }
2372 
2373  // create with default times
2374  {
2375  piecewise_curve_type pc;
2376  cubic_spline_creator_type spline_creator(4);
2377  point_type pt_b, pt_a;
2378  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
2379  data_type dt;
2380  index_type i, nseg;
2382 
2383  // set the points and times
2384  pts[0] << 1, 3, 2;
2385  pts[1] << 0, 2, 3;
2386  pts[2] << -1, 4, 1;
2387  pts[3] << 0, 5, 0;
2388  pts[4] << 1, 6, -1;
2389 
2390  // set up the creator
2391  spline_creator.set_natural_cubic_spline(pts.begin());
2392 
2393  // test time step settings
2394  TEST_ASSERT(spline_creator.get_t0()==0);
2395  dt=spline_creator.get_segment_dt(0);
2396  TEST_ASSERT(dt==1);
2397  dt=spline_creator.get_segment_dt(1);
2398  TEST_ASSERT(dt==1);
2399  dt=spline_creator.get_segment_dt(2);
2400  TEST_ASSERT(dt==1);
2401  dt=spline_creator.get_segment_dt(3);
2402  TEST_ASSERT(dt==1);
2403 
2404  // create the piecewise curve
2405  TEST_ASSERT(spline_creator.create(pc));
2406 
2407  // check the number segments
2408  nseg=pc.number_segments();
2409  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
2410 
2411  // check the starting time
2412  TEST_ASSERT(tol.approximately_equal(0, pc.get_t0()));
2413 
2414  // check the continuity at each point
2415  for (i=1; i<nseg; ++i)
2416  {
2417  cont=pc.continuity(static_cast<data_type>(i));
2418  TEST_ASSERT(cont==eli::geom::general::C2);
2419  }
2420 
2421  // check the end points
2422  TEST_ASSERT(tol.approximately_equal(pts[0], pc.f(0)));
2423  pt_a.setZero();
2424  TEST_ASSERT(tol.approximately_equal(pt_a, pc.fpp(0)));
2425  TEST_ASSERT(tol.approximately_equal(pts[4], pc.f(4)));
2426  TEST_ASSERT(tol.approximately_equal(pt_a, pc.fpp(4)));
2427  }
2428  }
2429 
2431  {
2432  // create with specified times
2433  {
2434  piecewise_curve_type pc;
2435  cubic_spline_creator_type spline_creator(4);
2436  point_type pt_b, pt_a;
2437  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
2438  std::vector<data_type> t(5);
2439  data_type dt;
2440  index_type i, nseg;
2442 
2443  // set the points and times
2444  pts[0] << 1, 3, 2;
2445  pts[1] << 0, 2, 3;
2446  pts[2] << -1, 4, 1;
2447  pts[3] << 0, 5, 0;
2448  pts[4] << 1, 6, -1;
2449  t[0]=1;
2450  t[1]=3;
2451  t[2]=4;
2452  t[3]=7;
2453  t[4]=9;
2454 
2455  // set up the creator
2456  spline_creator.set_t0(t[0]);
2457  for (i=0; i<spline_creator.get_number_segments(); ++i)
2458  {
2459  spline_creator.set_segment_dt(t[i+1]-t[i], i);
2460  }
2461  spline_creator.set_periodic_cubic_spline(pts.begin());
2462 
2463  // test time step settings
2464  TEST_ASSERT(spline_creator.get_t0()==t[0]);
2465  dt=spline_creator.get_segment_dt(0);
2466  TEST_ASSERT(dt==t[1]-t[0]);
2467  dt=spline_creator.get_segment_dt(1);
2468  TEST_ASSERT(dt==t[2]-t[1]);
2469  dt=spline_creator.get_segment_dt(2);
2470  TEST_ASSERT(dt==t[3]-t[2]);
2471  dt=spline_creator.get_segment_dt(3);
2472  TEST_ASSERT(dt==t[4]-t[3]);
2473 
2474  // create the piecewise curve
2475  TEST_ASSERT(spline_creator.create(pc));
2476 
2477  // check the number segments
2478  nseg=pc.number_segments();
2479  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
2480 
2481  // check the starting time
2482  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
2483 
2484  // check the continuity at each point
2485  for (i=1; i<nseg; ++i)
2486  {
2487  cont=pc.continuity(t[i]);
2488  TEST_ASSERT(cont==eli::geom::general::C2);
2489  }
2490 
2491  // check the end points
2492  TEST_ASSERT(tol.approximately_equal(pts[0], pc.f(t[0])));
2493  TEST_ASSERT(tol.approximately_equal(pc.fp(t[4]), pc.fp(t[0])));
2494  TEST_ASSERT(tol.approximately_equal(pts[4], pc.f(t[4])));
2495  TEST_ASSERT(tol.approximately_equal(pc.fpp(t[4]), pc.fpp(t[0])));
2496  }
2497 
2498  // create with default times
2499  {
2500  piecewise_curve_type pc;
2501  cubic_spline_creator_type spline_creator(4);
2502  point_type pt_b, pt_a;
2503  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
2504  data_type dt;
2505  index_type i, nseg;
2507 
2508  // set the points and times
2509  pts[0] << 1, 3, 2;
2510  pts[1] << 0, 2, 3;
2511  pts[2] << -1, 4, 1;
2512  pts[3] << 0, 5, 0;
2513  pts[4] << 1, 6, -1;
2514 
2515  // set up the creator
2516  spline_creator.set_periodic_cubic_spline(pts.begin());
2517 
2518  // test time step settings
2519  TEST_ASSERT(spline_creator.get_t0()==0);
2520  dt=spline_creator.get_segment_dt(0);
2521  TEST_ASSERT(dt==1);
2522  dt=spline_creator.get_segment_dt(1);
2523  TEST_ASSERT(dt==1);
2524  dt=spline_creator.get_segment_dt(2);
2525  TEST_ASSERT(dt==1);
2526  dt=spline_creator.get_segment_dt(3);
2527  TEST_ASSERT(dt==1);
2528 
2529  // create the piecewise curve
2530  TEST_ASSERT(spline_creator.create(pc));
2531 
2532  // check the number segments
2533  nseg=pc.number_segments();
2534  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()-1));
2535 
2536  // check the starting time
2537  TEST_ASSERT(tol.approximately_equal(0, pc.get_t0()));
2538 
2539  // check the continuity at each point
2540  for (i=1; i<nseg; ++i)
2541  {
2542  cont=pc.continuity(static_cast<data_type>(i));
2543  TEST_ASSERT(cont==eli::geom::general::C2);
2544  }
2545 
2546  // check the end points
2547  TEST_ASSERT(tol.approximately_equal(pts[0], pc.f(0)));
2548  TEST_ASSERT(tol.approximately_equal(pc.fp(0), pc.fp(4)));
2549  TEST_ASSERT(tol.approximately_equal(pts[4], pc.f(4)));
2550  TEST_ASSERT(tol.approximately_equal(pc.fpp(0), pc.fpp(4)));
2551  }
2552  }
2553 
2555  {
2556  // create with specified times
2557  {
2558  piecewise_curve_type pc;
2559  cubic_spline_creator_type spline_creator(5);
2560  point_type pt_b, pt_a;
2561  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
2562  std::vector<data_type> t(6);
2563  data_type dt;
2564  index_type i, nseg;
2566 
2567  // set the points and times
2568  pts[0] << 1, 3, 2;
2569  pts[1] << 0, 2, 3;
2570  pts[2] << -1, 4, 1;
2571  pts[3] << 0, 5, 0;
2572  pts[4] << 1, 6, -1;
2573  t[0]=1;
2574  t[1]=3;
2575  t[2]=4;
2576  t[3]=7;
2577  t[4]=9;
2578  t[5]=10;
2579 
2580  // set up the creator
2581  spline_creator.set_t0(t[0]);
2582  for (i=0; i<spline_creator.get_number_segments(); ++i)
2583  {
2584  spline_creator.set_segment_dt(t[i+1]-t[i], i);
2585  }
2586  spline_creator.set_closed_cubic_spline(pts.begin());
2587 
2588  // test time step settings
2589  TEST_ASSERT(spline_creator.get_t0()==t[0]);
2590  dt=spline_creator.get_segment_dt(0);
2591  TEST_ASSERT(dt==t[1]-t[0]);
2592  dt=spline_creator.get_segment_dt(1);
2593  TEST_ASSERT(dt==t[2]-t[1]);
2594  dt=spline_creator.get_segment_dt(2);
2595  TEST_ASSERT(dt==t[3]-t[2]);
2596  dt=spline_creator.get_segment_dt(3);
2597  TEST_ASSERT(dt==t[4]-t[3]);
2598  dt=spline_creator.get_segment_dt(4);
2599  TEST_ASSERT(dt==t[5]-t[4]);
2600 
2601  // create the piecewise curve
2602  TEST_ASSERT(spline_creator.create(pc));
2603 
2604  // check the number segments
2605  nseg=pc.number_segments();
2606  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()));
2607 
2608  // check the starting time
2609  TEST_ASSERT(tol.approximately_equal(t[0], pc.get_t0()));
2610 
2611  // check the continuity at each point
2612  for (i=1; i<nseg; ++i)
2613  {
2614  cont=pc.continuity(t[i]);
2615  TEST_ASSERT(cont==eli::geom::general::C2);
2616  }
2617 
2618  // check the end points
2619  cont=pc.continuity(t[0]);
2620  TEST_ASSERT(cont==eli::geom::general::C2);
2621  cont=pc.continuity(t[5]);
2622  TEST_ASSERT(cont==eli::geom::general::C2);
2623  }
2624 
2625  // create with default times
2626  {
2627  piecewise_curve_type pc;
2628  cubic_spline_creator_type spline_creator(5);
2629  point_type pt_b, pt_a;
2630  std::vector<point_type, Eigen::aligned_allocator<point_type> > pts(5);
2631  data_type dt;
2632  index_type i, nseg;
2634 
2635  // set the points and times
2636  pts[0] << 1, 3, 2;
2637  pts[1] << 0, 2, 3;
2638  pts[2] << -1, 4, 1;
2639  pts[3] << 0, 5, 0;
2640  pts[4] << 1, 6, -1;
2641 
2642  // set up the creator
2643  spline_creator.set_closed_cubic_spline(pts.begin());
2644 
2645  // test time step settings
2646  TEST_ASSERT(spline_creator.get_t0()==0);
2647  dt=spline_creator.get_segment_dt(0);
2648  TEST_ASSERT(dt==1);
2649  dt=spline_creator.get_segment_dt(1);
2650  TEST_ASSERT(dt==1);
2651  dt=spline_creator.get_segment_dt(2);
2652  TEST_ASSERT(dt==1);
2653  dt=spline_creator.get_segment_dt(3);
2654  TEST_ASSERT(dt==1);
2655  dt=spline_creator.get_segment_dt(4);
2656  TEST_ASSERT(dt==1);
2657 
2658  // create the piecewise curve
2659  TEST_ASSERT(spline_creator.create(pc));
2660 
2661  // check the number segments
2662  nseg=pc.number_segments();
2663  TEST_ASSERT(nseg==static_cast<index_type>(pts.size()));
2664 
2665  // check the starting time
2666  TEST_ASSERT(tol.approximately_equal(0, pc.get_t0()));
2667 
2668  // check the continuity at each point
2669  for (i=1; i<nseg; ++i)
2670  {
2671  cont=pc.continuity(static_cast<data_type>(i));
2672  TEST_ASSERT(cont==eli::geom::general::C2);
2673  }
2674 
2675  // check the end points
2676  cont=pc.continuity(0);
2677  TEST_ASSERT(cont==eli::geom::general::C2);
2678  cont=pc.continuity(5);
2679  TEST_ASSERT(cont==eli::geom::general::C2);
2680  }
2681  }
2682 };
2683 
2684 #endif
2685 
void set_cubic_spline(point_it__ itb)
Definition: piecewise_cubic_spline_creator.hpp:773
void create_control_points_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:216
void set_segment_point_slope(const point_type &p0, const point_type &m0, const point_type &p1, const point_type &m1, const index_type &i)
Definition: piecewise_cubic_spline_creator.hpp:74
Definition: continuity.hpp:26
Definition: continuity.hpp:28
void get_segment_control_points(point_type &cp0, point_type &cp1, point_type &cp2, point_type &cp3, const index_type &i) const
Definition: piecewise_cubic_spline_creator.hpp:50
void AddTests(const double &)
Definition: piecewise_cubic_spline_creator_test_suite.hpp:62
void create_piecewise_kochanek_bartels_spline_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:1669
void set_segment_dt(const data_type &dtt, const index_type &i)
Definition: piecewise_creator_base.hpp:64
piecewise_curve_type::data_type data_type
Definition: piecewise_cubic_spline_creator_test_suite.hpp:35
piecewise_curve_type::index_type index_type
Definition: piecewise_cubic_spline_creator_test_suite.hpp:36
void create_closed_cubic_spline_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:2554
tol__ tolerance_type
Definition: piecewise.hpp:278
void create_piecewise_chip_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:540
void set_chip(point_it__ itb, const eli::geom::general::continuity &end_cont)
Definition: piecewise_cubic_spline_creator.hpp:141
data__ data_type
Definition: piecewise.hpp:276
void AddTests(const long double &)
Definition: piecewise_cubic_spline_creator_test_suite.hpp:81
data_type get_parameter_min() const
Definition: piecewise.hpp:366
curve_type::index_type index_type
Definition: piecewise.hpp:271
index_type number_segments() const
Definition: piecewise.hpp:419
void set_cardinal(point_it__ itb, const data__ &c, const eli::geom::general::continuity &end_cont)
Definition: piecewise_cubic_spline_creator.hpp:390
bool closed() const
Definition: piecewise.hpp:501
piecewise_cubic_spline_creator_test_suite()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:102
void create_clamped_cubic_spline_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:2174
Definition: math.hpp:25
void set_segment_control_points(const point_type &cp0, const point_type &cp1, const point_type &cp2, const point_type &cp3, const index_type &i)
Definition: piecewise_cubic_spline_creator.hpp:62
Definition: piecewise.hpp:244
point_type fpp(const data_type &t) const
Definition: piecewise.hpp:1765
Definition: continuity.hpp:27
curve__< data__, dim__, tol__ > curve_type
Definition: piecewise.hpp:270
void create_closed_piecewise_kochanek_bartels_spline_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:1777
index_type get_number_segments() const
Definition: piecewise_creator_base.hpp:47
void set_kochanek_bartels(point_it__ itb, const data__ &tension, const data__ &bias, const data__ &continuity, const eli::geom::general::continuity &end_cont)
Definition: piecewise_cubic_spline_creator.hpp:579
eli::geom::curve::piecewise_cubic_spline_creator< data__, 3, tolerance_type > cubic_spline_creator_type
Definition: piecewise_cubic_spline_creator_test_suite.hpp:38
void AddTests(const float &)
Definition: piecewise_cubic_spline_creator_test_suite.hpp:43
Definition: continuity.hpp:30
void create_piecewise_cardinal_spline_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:917
void create_natural_cubic_spline_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:2304
Definition: piecewise_cubic_spline_creator.hpp:35
void create_closed_piecewise_catmull_rom_spline_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:1402
piecewise_curve_type::curve_type curve_type
Definition: piecewise_cubic_spline_creator_test_suite.hpp:33
void create_points_slopes_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:372
void create_piecewise_catmull_rom_spline_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:1294
void create_cubic_spline_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:2040
~piecewise_cubic_spline_creator_test_suite()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:106
virtual bool create(piecewise< bezier, data_type, dim__, tolerance_type > &pc) const
Definition: piecewise_cubic_spline_creator.hpp:90
eli::geom::curve::piecewise< eli::geom::curve::bezier, data__, 3 > piecewise_curve_type
Definition: piecewise_cubic_spline_creator_test_suite.hpp:32
void set_catmull_rom(point_it__ itb, const eli::geom::general::continuity &end_cont)
Definition: piecewise_cubic_spline_creator.hpp:564
data_type get_segment_dt(const index_type &i) const
Definition: piecewise_creator_base.hpp:78
data_type get_parameter_max() const
Definition: piecewise.hpp:374
piecewise_curve_type::tolerance_type tolerance_type
Definition: piecewise_cubic_spline_creator_test_suite.hpp:37
point_type fp(const data_type &t) const
Definition: piecewise.hpp:1748
data_type get_t0() const
Definition: piecewise.hpp:335
piecewise_curve_type::point_type point_type
Definition: piecewise_cubic_spline_creator_test_suite.hpp:34
void set_natural_cubic_spline(point_it__ itb)
Definition: piecewise_cubic_spline_creator.hpp:866
point_type f(const data_type &t) const
Definition: piecewise.hpp:1732
continuity
Definition: continuity.hpp:24
Definition: piecewise_cubic_spline_creator_test_suite.hpp:29
error_code get(curve_type &curve, const index_type &index) const
Definition: piecewise.hpp:729
data_type get_t0() const
Definition: piecewise_creator_base.hpp:62
tolerance_type tol
Definition: piecewise_cubic_spline_creator_test_suite.hpp:40
void octave_print(int figno, const piecewise_curve_type &pc) const
Definition: piecewise_cubic_spline_creator_test_suite.hpp:111
curve_type::point_type point_type
Definition: piecewise.hpp:272
void set_t0(const data_type &tt0)
Definition: piecewise_creator_base.hpp:61
void create_closed_piecewise_cardinal_spline_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:1025
void create_closed_piecewise_chip_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:648
void set_closed_cubic_spline(point_it__ itb)
Definition: piecewise_cubic_spline_creator.hpp:900
Definition: continuity.hpp:29
void set_periodic_cubic_spline(point_it__ itb)
Definition: piecewise_cubic_spline_creator.hpp:923
eli::geom::general::continuity continuity(const data_type &t) const
Definition: piecewise.hpp:1486
void set_clamped_cubic_spline(point_it__ itb, const point_type &start_slope, const point_type &end_slope)
Definition: piecewise_cubic_spline_creator.hpp:831
void create_periodic_cubic_spline_test()
Definition: piecewise_cubic_spline_creator_test_suite.hpp:2430