Code-Eli  0.3.6
piecewise_general_creator_test_suite.hpp
Go to the documentation of this file.
1 /*********************************************************************************
2 * Copyright (c) 2014 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_general_creator_test_suite_hpp
14 #define piecewise_general_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__>
29 class piecewise_general_creator_test_suite : public Test::Suite
30 {
31  private:
40 
41  tolerance_type tol;
42 
43  protected:
44  void AddTests(const float &)
45  {
46  // add the tests
52  }
53  void AddTests(const double &)
54  {
55  // add the tests
61  }
62  void AddTests(const long double &)
63  {
64  // add the tests
70  }
71 
72  public:
74  {
75  AddTests(data__());
76  }
78  {
79  }
80 
81  private:
82  void octave_print(int figno, const piecewise_curve_type &pc) const
83  {
84  index_type i, pp, ns;
85  data_type tmin, tmax;
86 
87  ns=pc.number_segments();
88  pc.get_parameter_min(tmin);
89  pc.get_parameter_max(tmax);
90 
91  std::cout << "figure(" << figno << ");" << std::endl;
92 
93  // get control points and print
94  std::cout << "cp_x=[";
95  for (pp=0; pp<ns; ++pp)
96  {
97  curve_type bez;
98  pc.get(bez, pp);
99  for (i=0; i<=bez.degree(); ++i)
100  {
101  std::cout << bez.get_control_point(i).x();
102  if (i<bez.degree())
103  std::cout << ", ";
104  else if (pp<ns-1)
105  std::cout << ", ";
106  }
107 // std::cout << std::endl;
108  }
109  std::cout << "];" << std::endl;
110 
111  std::cout << "cp_y=[";
112  for (pp=0; pp<ns; ++pp)
113  {
114  curve_type bez;
115  pc.get(bez, pp);
116  for (i=0; i<=bez.degree(); ++i)
117  {
118  std::cout << bez.get_control_point(i).y();
119  if (i<bez.degree())
120  std::cout << ", ";
121  else if (pp<ns-1)
122  std::cout << ", ";
123  }
124 // std::cout << std::endl;
125  }
126  std::cout << "];" << std::endl;
127 
128  std::cout << "cp_z=[";
129  for (pp=0; pp<ns; ++pp)
130  {
131  curve_type bez;
132  pc.get(bez, pp);
133  for (i=0; i<=bez.degree(); ++i)
134  {
135  std::cout << bez.get_control_point(i).z();
136  if (i<bez.degree())
137  std::cout << ", ";
138  else if (pp<ns-1)
139  std::cout << ", ";
140  }
141 // std::cout << std::endl;
142  }
143  std::cout << "];" << std::endl;
144 
145  // initialize the t parameters
146  std::vector<data__> t(129);
147  for (i=0; i<static_cast<index_type>(t.size()); ++i)
148  {
149  t[i]=tmin+(tmax-tmin)*static_cast<data__>(i)/(t.size()-1);
150  }
151 
152  // set the surface points
153  std::cout << "surf_x=[";
154  for (i=0; i<static_cast<index_type>(t.size()); ++i)
155  {
156  std::cout << pc.f(t[i]).x();
157  if (i<static_cast<index_type>(t.size()-1))
158  std::cout << ", ";
159  }
160  std::cout << "];" << std::endl;
161 
162  std::cout << "surf_y=[";
163  for (i=0; i<static_cast<index_type>(t.size()); ++i)
164  {
165  std::cout << pc.f(t[i]).y();
166  if (i<static_cast<index_type>(t.size()-1))
167  std::cout << ", ";
168  }
169  std::cout << "];" << std::endl;
170 
171  std::cout << "surf_z=[";
172  for (i=0; i<static_cast<index_type>(t.size()); ++i)
173  {
174  std::cout << pc.f(t[i]).z();
175  if (i<static_cast<index_type>(t.size()-1))
176  std::cout << ", ";
177  }
178  std::cout << "];" << std::endl;
179 
180  std::cout << "setenv('GNUTERM', 'x11');" << std::endl;
181  std::cout << "plot3(surf_x, surf_y, surf_z, '-k');" << std::endl;
182  std::cout << "hold on;" << std::endl;
183  std::cout << "plot3(cp_x', cp_y', cp_z', '-ok', 'MarkerFaceColor', [0 0 0]);" << std::endl;
184  std::cout << "hold off;" << std::endl;
185  }
186 
188  {
189  point_type p1, p2;
190  bool rtn_flag;
191 
192  p1 << 1, 0, 0;
193  p2 << 2, 2, 2;
194 
195  // set point
196  {
197  joint_data_type joint;
198 
199  // should start in bad state
200  rtn_flag=joint.check_state();
201  TEST_ASSERT(!rtn_flag);
202  TEST_ASSERT(joint.get_continuity()==general_creator_type::C0);
203  TEST_ASSERT(!joint.use_f());
204 
205  // add point
206  rtn_flag=joint.set_f(p1);
207  TEST_ASSERT(rtn_flag);
208  TEST_ASSERT(joint.get_continuity()==general_creator_type::C0);
209  TEST_ASSERT(joint.use_f());
210 
211  // unset point
212  rtn_flag=joint.unset_f();
213  TEST_ASSERT(!rtn_flag);
214  TEST_ASSERT(!joint.use_f());
215  }
216 
217  // set point and fp
218  {
219  joint_data_type joint;
220 
221  // should start in bad state
222  rtn_flag=joint.check_state();
223  TEST_ASSERT(!rtn_flag);
224  TEST_ASSERT(joint.get_continuity()==general_creator_type::C0);
225  TEST_ASSERT(!joint.use_f());
226  TEST_ASSERT(!joint.use_left_fp());
227  TEST_ASSERT(!joint.use_right_fp());
228 
229  // add left fp
230  rtn_flag=joint.set_left_fp(p1);
231  TEST_ASSERT(!rtn_flag);
232  TEST_ASSERT(joint.get_left_fp()==p1);
233  TEST_ASSERT(!joint.use_f());
234  TEST_ASSERT(joint.use_left_fp());
235  TEST_ASSERT(!joint.use_right_fp());
236 
237  // add point
238  rtn_flag=joint.set_f(p1);
239  TEST_ASSERT(rtn_flag);
240  TEST_ASSERT(joint.get_continuity()==general_creator_type::C0);
241  TEST_ASSERT(joint.use_f());
242  TEST_ASSERT(joint.use_left_fp());
243  TEST_ASSERT(!joint.use_right_fp());
244 
245  // add right fp
246  rtn_flag=joint.set_right_fp(p2);
247  TEST_ASSERT(rtn_flag);
248  TEST_ASSERT(joint.get_right_fp()==p2);
249  TEST_ASSERT(joint.use_f());
250  TEST_ASSERT(joint.use_left_fp());
251  TEST_ASSERT(joint.use_right_fp());
252 
253  // remove left fp
254  rtn_flag=joint.unset_left_fp();
255  TEST_ASSERT(rtn_flag);
256  TEST_ASSERT(joint.use_f());
257  TEST_ASSERT(!joint.use_left_fp());
258  TEST_ASSERT(joint.use_right_fp());
259 
260  // remove left fp again
261  rtn_flag=joint.unset_left_fp();
262  TEST_ASSERT(rtn_flag);
263  TEST_ASSERT(joint.use_f());
264  TEST_ASSERT(!joint.use_left_fp());
265  TEST_ASSERT(joint.use_right_fp());
266 
267  // remove right fp
268  rtn_flag=joint.unset_right_fp();
269  TEST_ASSERT(rtn_flag);
270  TEST_ASSERT(joint.use_f());
271  TEST_ASSERT(!joint.use_left_fp());
272  TEST_ASSERT(!joint.use_right_fp());
273 
274  // add fp
275  rtn_flag=joint.set_fp(p2);
276  TEST_ASSERT(rtn_flag);
277  TEST_ASSERT(joint.get_left_fp()==p2);
278  TEST_ASSERT(joint.get_right_fp()==p2);
279  TEST_ASSERT(joint.use_f());
280  TEST_ASSERT(joint.use_left_fp());
281  TEST_ASSERT(joint.use_right_fp());
282 
283  // remove right fp
284  rtn_flag=joint.unset_right_fp();
285  TEST_ASSERT(rtn_flag);
286  TEST_ASSERT(joint.use_f());
287  TEST_ASSERT(joint.use_left_fp());
288  TEST_ASSERT(!joint.use_right_fp());
289  }
290 
291  // set point, fp and fpp
292  {
293  joint_data_type joint;
294 
295  // should start in bad state
296  rtn_flag=joint.check_state();
297  TEST_ASSERT(!rtn_flag);
298  TEST_ASSERT(joint.get_continuity()==general_creator_type::C0);
299  TEST_ASSERT(!joint.use_f());
300  TEST_ASSERT(!joint.use_left_fp());
301  TEST_ASSERT(!joint.use_right_fp());
302  TEST_ASSERT(!joint.use_left_fpp());
303  TEST_ASSERT(!joint.use_right_fpp());
304 
305  // add left fpp
306  rtn_flag=joint.set_left_fpp(p1);
307  TEST_ASSERT(!rtn_flag);
308  TEST_ASSERT(joint.get_left_fpp()==p1);
309  TEST_ASSERT(!joint.use_f());
310  TEST_ASSERT(!joint.use_left_fp());
311  TEST_ASSERT(!joint.use_right_fp());
312  TEST_ASSERT(joint.use_left_fpp());
313  TEST_ASSERT(!joint.use_right_fpp());
314 
315  // add right fpp
316  rtn_flag=joint.set_right_fpp(p2);
317  TEST_ASSERT(!rtn_flag);
318  TEST_ASSERT(joint.get_right_fpp()==p2);
319  TEST_ASSERT(!joint.use_f());
320  TEST_ASSERT(!joint.use_left_fp());
321  TEST_ASSERT(!joint.use_right_fp());
322  TEST_ASSERT(joint.use_left_fpp());
323  TEST_ASSERT(joint.use_right_fpp());
324 
325  // add point
326  rtn_flag=joint.set_f(p1);
327  TEST_ASSERT(rtn_flag);
328  TEST_ASSERT(joint.get_continuity()==general_creator_type::C0);
329  TEST_ASSERT(joint.use_f());
330  TEST_ASSERT(!joint.use_left_fp());
331  TEST_ASSERT(!joint.use_right_fp());
332  TEST_ASSERT(joint.use_left_fpp());
333  TEST_ASSERT(joint.use_right_fpp());
334 
335  // remove right fpp
336  rtn_flag=joint.unset_right_fpp();
337  TEST_ASSERT(rtn_flag);
338  TEST_ASSERT(joint.use_f());
339  TEST_ASSERT(!joint.use_left_fp());
340  TEST_ASSERT(!joint.use_right_fp());
341  TEST_ASSERT(joint.use_left_fpp());
342  TEST_ASSERT(!joint.use_right_fp());
343 
344  // remove right fpp again
345  rtn_flag=joint.unset_right_fpp();
346  TEST_ASSERT(rtn_flag);
347  TEST_ASSERT(joint.use_f());
348  TEST_ASSERT(!joint.use_left_fp());
349  TEST_ASSERT(!joint.use_right_fp());
350  TEST_ASSERT(joint.use_left_fpp());
351  TEST_ASSERT(!joint.use_right_fp());
352 
353  // remove left fpp
354  rtn_flag=joint.unset_left_fpp();
355  TEST_ASSERT(rtn_flag);
356  TEST_ASSERT(joint.use_f());
357  TEST_ASSERT(!joint.use_left_fp());
358  TEST_ASSERT(!joint.use_right_fp());
359  TEST_ASSERT(!joint.use_left_fpp());
360  TEST_ASSERT(!joint.use_right_fpp());
361 
362  // add fp
363  rtn_flag=joint.set_fp(p2);
364  TEST_ASSERT(rtn_flag);
365  TEST_ASSERT(joint.get_left_fp()==p2);
366  TEST_ASSERT(joint.get_right_fp()==p2);
367  TEST_ASSERT(joint.use_f());
368  TEST_ASSERT(joint.use_left_fp());
369  TEST_ASSERT(joint.use_right_fp());
370  TEST_ASSERT(!joint.use_left_fpp());
371  TEST_ASSERT(!joint.use_right_fpp());
372 
373  // add fpp
374  rtn_flag=joint.set_fpp(p1);
375  TEST_ASSERT(rtn_flag);
376  TEST_ASSERT(joint.get_left_fpp()==p1);
377  TEST_ASSERT(joint.get_right_fpp()==p1);
378  TEST_ASSERT(joint.use_f());
379  TEST_ASSERT(joint.use_left_fp());
380  TEST_ASSERT(joint.use_right_fp());
381  TEST_ASSERT(joint.use_left_fpp());
382  TEST_ASSERT(joint.use_right_fpp());
383 
384  // remove right fp
385  rtn_flag=joint.unset_right_fp();
386  TEST_ASSERT(rtn_flag);
387  TEST_ASSERT(joint.use_f());
388  TEST_ASSERT(joint.use_left_fp());
389  TEST_ASSERT(!joint.use_right_fp());
390  TEST_ASSERT(joint.use_left_fpp());
391  TEST_ASSERT(joint.use_right_fpp());
392 
393  // remove right fpp
394  rtn_flag=joint.unset_right_fpp();
395  TEST_ASSERT(rtn_flag);
396  TEST_ASSERT(joint.use_f());
397  TEST_ASSERT(joint.use_left_fp());
398  TEST_ASSERT(!joint.use_right_fp());
399  TEST_ASSERT(joint.use_left_fpp());
400  TEST_ASSERT(!joint.use_right_fpp());
401 
402  // remove everything
403  rtn_flag=joint.unset_fpp();
404  TEST_ASSERT(rtn_flag);
405  rtn_flag=joint.unset_fp();
406  TEST_ASSERT(rtn_flag);
407  rtn_flag=joint.unset_f();
408  TEST_ASSERT(!rtn_flag);
409 
410  // add everything to right only
411  rtn_flag=joint.set_f(p2);
412  TEST_ASSERT(rtn_flag);
413  rtn_flag=joint.set_right_fp(p1);
414  TEST_ASSERT(rtn_flag);
415  rtn_flag=joint.set_right_fpp(p2);
416  TEST_ASSERT(rtn_flag);
417  TEST_ASSERT(joint.use_f());
418  TEST_ASSERT(joint.get_f()==p2);
419  TEST_ASSERT(joint.get_right_fp()==p1);
420  TEST_ASSERT(joint.get_right_fpp()==p2);
421  TEST_ASSERT(!joint.use_left_fp());
422  TEST_ASSERT(joint.use_right_fp());
423  TEST_ASSERT(!joint.use_left_fpp());
424  TEST_ASSERT(joint.use_right_fpp());
425  }
426 
427  // set conditions with C1
428  {
429  joint_data_type joint;
430 
431  // start with point
432  rtn_flag=joint.set_f(p1);
433  TEST_ASSERT(rtn_flag);
434  TEST_ASSERT(joint.get_continuity()==general_creator_type::C0);
435  TEST_ASSERT(joint.use_f());
436  TEST_ASSERT(!joint.use_left_fp());
437  TEST_ASSERT(!joint.use_right_fp());
438  TEST_ASSERT(!joint.use_left_fpp());
439  TEST_ASSERT(!joint.use_right_fpp());
440 
441  // set continuity to C1
443  TEST_ASSERT(rtn_flag);
444  TEST_ASSERT(joint.get_continuity()==general_creator_type::C1);
445  TEST_ASSERT(joint.use_f());
446  TEST_ASSERT(!joint.use_left_fp());
447  TEST_ASSERT(!joint.use_right_fp());
448  TEST_ASSERT(!joint.use_left_fpp());
449  TEST_ASSERT(!joint.use_right_fpp());
450 
451  // add left fp
452  rtn_flag=joint.set_left_fp(p2);
453  TEST_ASSERT(rtn_flag);
454  TEST_ASSERT(joint.get_continuity()==general_creator_type::C1);
455  TEST_ASSERT(joint.use_f());
456  TEST_ASSERT(joint.use_left_fp());
457  TEST_ASSERT(joint.use_right_fp());
458  TEST_ASSERT(!joint.use_left_fpp());
459  TEST_ASSERT(!joint.use_right_fpp());
460 
461  // unset left fp
462  rtn_flag=joint.unset_left_fp();
463  TEST_ASSERT(!rtn_flag);
464  rtn_flag=joint.unset_right_fp();
465  TEST_ASSERT(rtn_flag);
466  TEST_ASSERT(joint.get_continuity()==general_creator_type::C1);
467  TEST_ASSERT(joint.use_f());
468  TEST_ASSERT(!joint.use_left_fp());
469  TEST_ASSERT(!joint.use_right_fp());
470  TEST_ASSERT(!joint.use_left_fpp());
471  TEST_ASSERT(!joint.use_right_fpp());
472 
473  // add right fp
474  rtn_flag=joint.set_right_fp(p2);
475  TEST_ASSERT(rtn_flag);
476  TEST_ASSERT(joint.get_continuity()==general_creator_type::C1);
477  TEST_ASSERT(joint.use_f());
478  TEST_ASSERT(joint.use_left_fp());
479  TEST_ASSERT(joint.use_right_fp());
480  TEST_ASSERT(!joint.use_left_fpp());
481  TEST_ASSERT(!joint.use_right_fpp());
482 
483  // change continuity
484  rtn_flag=joint.unset_left_fp();
485  TEST_ASSERT(!rtn_flag);
487  TEST_ASSERT(rtn_flag);
488  TEST_ASSERT(joint.get_continuity()==general_creator_type::C0);
489  TEST_ASSERT(joint.use_f());
490  TEST_ASSERT(!joint.use_left_fp());
491  TEST_ASSERT(joint.use_right_fp());
492  TEST_ASSERT(!joint.use_left_fpp());
493  TEST_ASSERT(!joint.use_right_fpp());
494 
495  // add fp
496  rtn_flag=joint.set_fp(p1);
497  TEST_ASSERT(rtn_flag);
498  TEST_ASSERT(joint.get_continuity()==general_creator_type::C0);
499  TEST_ASSERT(joint.use_f());
500  TEST_ASSERT(joint.use_left_fp());
501  TEST_ASSERT(joint.use_right_fp());
502  TEST_ASSERT(!joint.use_left_fpp());
503  TEST_ASSERT(!joint.use_right_fpp());
504 
505  // change continuity
507  TEST_ASSERT(rtn_flag);
508  TEST_ASSERT(joint.get_continuity()==general_creator_type::C1);
509  TEST_ASSERT(joint.use_f());
510  TEST_ASSERT(joint.use_left_fp());
511  TEST_ASSERT(joint.use_right_fp());
512  TEST_ASSERT(!joint.use_left_fpp());
513  TEST_ASSERT(!joint.use_right_fpp());
514 
515  // unset left fp
516  rtn_flag=joint.unset_left_fp();
517  TEST_ASSERT(!rtn_flag);
518  TEST_ASSERT(joint.get_continuity()==general_creator_type::C1);
519  TEST_ASSERT(joint.use_f());
520  TEST_ASSERT(!joint.use_left_fp());
521  TEST_ASSERT(joint.use_right_fp());
522  TEST_ASSERT(!joint.use_left_fpp());
523  TEST_ASSERT(!joint.use_right_fpp());
524 
525  // set left fp to change left and right value
526  rtn_flag=joint.set_left_fp(p2);
527  TEST_ASSERT(rtn_flag);
528  TEST_ASSERT(joint.get_left_fp()==p2);
529  TEST_ASSERT(joint.get_right_fp()==p2);
530  TEST_ASSERT(joint.get_continuity()==general_creator_type::C1);
531  TEST_ASSERT(joint.use_f());
532  TEST_ASSERT(joint.use_left_fp());
533  TEST_ASSERT(joint.use_right_fp());
534  TEST_ASSERT(!joint.use_left_fpp());
535  TEST_ASSERT(!joint.use_right_fpp());
536 
537  // set left fp
538  rtn_flag=joint.set_left_fp(joint.get_right_fp());
539  TEST_ASSERT(rtn_flag);
540  TEST_ASSERT(joint.get_continuity()==general_creator_type::C1);
541  TEST_ASSERT(joint.use_f());
542  TEST_ASSERT(joint.use_left_fp());
543  TEST_ASSERT(joint.use_right_fp());
544  TEST_ASSERT(!joint.use_left_fpp());
545  TEST_ASSERT(!joint.use_right_fpp());
546  }
547 
548  // set point, fp, fpp and C2
549  {
550  joint_data_type joint;
551 
552  // start with point and fp
553  rtn_flag=joint.set_f(p1);
554  TEST_ASSERT(rtn_flag);
555  rtn_flag=joint.set_fp(p2);
556  TEST_ASSERT(rtn_flag);
558  TEST_ASSERT(rtn_flag);
559  TEST_ASSERT(joint.get_continuity()==general_creator_type::C1);
560  TEST_ASSERT(joint.use_f());
561  TEST_ASSERT(joint.use_left_fp());
562  TEST_ASSERT(joint.use_right_fp());
563  TEST_ASSERT(!joint.use_left_fpp());
564  TEST_ASSERT(!joint.use_right_fpp());
565 
566  // set continuity to C2
568  TEST_ASSERT(rtn_flag);
569  TEST_ASSERT(joint.get_continuity()==general_creator_type::C2);
570  TEST_ASSERT(joint.use_f());
571  TEST_ASSERT(joint.use_left_fp());
572  TEST_ASSERT(joint.use_right_fp());
573  TEST_ASSERT(!joint.use_left_fpp());
574  TEST_ASSERT(!joint.use_right_fpp());
575 
576  // unset left fp
577  rtn_flag=joint.unset_left_fp();
578  TEST_ASSERT(!rtn_flag);
579  TEST_ASSERT(joint.get_continuity()==general_creator_type::C2);
580  TEST_ASSERT(joint.use_f());
581  TEST_ASSERT(!joint.use_left_fp());
582  TEST_ASSERT(joint.use_right_fp());
583  TEST_ASSERT(!joint.use_left_fpp());
584  TEST_ASSERT(!joint.use_right_fpp());
585 
586  // unset right fp
587  rtn_flag=joint.unset_right_fp();
588  TEST_ASSERT(rtn_flag);
589  TEST_ASSERT(joint.get_continuity()==general_creator_type::C2);
590  TEST_ASSERT(joint.use_f());
591  TEST_ASSERT(!joint.use_left_fp());
592  TEST_ASSERT(!joint.use_right_fp());
593  TEST_ASSERT(!joint.use_left_fpp());
594  TEST_ASSERT(!joint.use_right_fpp());
595 
596  // set fpp
597  rtn_flag=joint.set_fpp(p1);
598  TEST_ASSERT(rtn_flag);
599  TEST_ASSERT(joint.get_continuity()==general_creator_type::C2);
600  TEST_ASSERT(joint.use_f());
601  TEST_ASSERT(!joint.use_left_fp());
602  TEST_ASSERT(!joint.use_right_fp());
603  TEST_ASSERT(joint.use_left_fpp());
604  TEST_ASSERT(joint.use_right_fpp());
605 
606  // unset left fpp
607  rtn_flag=joint.unset_left_fpp();
608  TEST_ASSERT(!rtn_flag);
609  TEST_ASSERT(joint.get_continuity()==general_creator_type::C2);
610  TEST_ASSERT(joint.use_f());
611  TEST_ASSERT(!joint.use_left_fp());
612  TEST_ASSERT(!joint.use_right_fp());
613  TEST_ASSERT(!joint.use_left_fpp());
614  TEST_ASSERT(joint.use_right_fpp());
615 
616  // set left fpp to set both left and right values
617  rtn_flag=joint.set_left_fpp(p2);
618  TEST_ASSERT(rtn_flag);
619  TEST_ASSERT(joint.get_continuity()==general_creator_type::C2);
620  TEST_ASSERT(joint.use_f());
621  TEST_ASSERT(!joint.use_left_fp());
622  TEST_ASSERT(!joint.use_right_fp());
623  TEST_ASSERT(joint.use_left_fpp());
624  TEST_ASSERT(joint.use_right_fpp());
625 
626  // set left fpp
627  rtn_flag=joint.set_left_fpp(joint.get_right_fpp());
628  TEST_ASSERT(rtn_flag);
629  TEST_ASSERT(joint.get_continuity()==general_creator_type::C2);
630  TEST_ASSERT(joint.use_f());
631  TEST_ASSERT(!joint.use_left_fp());
632  TEST_ASSERT(!joint.use_right_fp());
633  TEST_ASSERT(joint.use_left_fpp());
634  TEST_ASSERT(joint.use_right_fpp());
635 
636  // set fp
637  rtn_flag=joint.set_fp(p2);
638  TEST_ASSERT(rtn_flag);
639  TEST_ASSERT(joint.get_continuity()==general_creator_type::C2);
640  TEST_ASSERT(joint.use_f());
641  TEST_ASSERT(joint.use_left_fp());
642  TEST_ASSERT(joint.use_right_fp());
643  TEST_ASSERT(joint.use_left_fpp());
644  TEST_ASSERT(joint.use_right_fpp());
645  }
646 
647  // copy constructor, equivalence and assignment operators
648  {
649  joint_data_type j1, j2, j3;
650 
651  // defaults should be the same
652  TEST_ASSERT(j1==j2);
653 
654  // manually build identical ones
655  j1.set_f(p2);
656  j1.set_left_fp(p1);
657  j1.set_right_fpp(p2);
658  j2.set_f(p2);
659  j2.set_left_fp(p1);
660  j2.set_right_fpp(p2);
661  TEST_ASSERT(j1==j2);
662 
663  // assignment operator
664  j3=j2;
665  TEST_ASSERT(j3==j1);
666  TEST_ASSERT(j3==j2);
667 
668  // set value for j2's fpp and then don't use it
669  j1.unset_fpp();
670  j2.unset_fpp();
671  j3.unset_fpp();
672  j2.set_fpp(p1);
673  j2.unset_fpp();
674  TEST_ASSERT(j3==j1);
675  TEST_ASSERT(j3==j2);
676 
677  // copy constructor
678  joint_data_type j4(j3);
679  TEST_ASSERT(j4==j3);
680  }
681  }
682 
684  {
685  // simple line connecting 2 points
686  {
687  index_type nsegs(1);
688  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
689  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
690  point_type p;
691  general_creator_type gc;
692  piecewise_curve_type c;
693  data_type t0(2), t1(4);
694  bool rtn_flag;
695 
696  // set the joints
697  p << 1, 1, 0;
698  joints[0].set_f(p);
699  p << 0, 0, -1;
700  joints[1].set_f(p);
701 
702  // set the maximum degrees of each segment
703  max_degree[0]=4;
704 
705  // create curve
706  rtn_flag=gc.set_conditions(joints, max_degree, false);
707  TEST_ASSERT(rtn_flag);
708  gc.set_t0(t0);
709  gc.set_segment_dt(t1-t0, 0);
710  rtn_flag=gc.create(c);
711  TEST_ASSERT(rtn_flag);
712 
713  // test the resulting curve
714  point_type p_test;
715 
716  p_test=c.f(t0);
717  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
718 // std::cout << "p=" << joints[0].get_f()
719 // << "\tp_test=" << p_test << "\tdiff="
720 // << (joints[0].get_f()-p_test).norm() << std::endl;
721  p_test=c.f(t1);
722  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
723 // std::cout << "p=" << joints[1].get_f()
724 // << "\tp_test=" << p_test << "\tdiff="
725 // << (joints[1].get_f()-p_test).norm() << std::endl;
726 
727 // if (rtn_flag && (typeid(data_type)==typeid(double)))
728 // octave_print(1, c);
729  }
730 
731  // simple 2nd degree curve with 1st derivative specified
732  {
733  index_type nsegs(1);
734  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
735  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
736  point_type p;
737  general_creator_type gc;
738  piecewise_curve_type c;
739  data_type t0(2), t1(4);
740  bool rtn_flag;
741 
742  // set the joints
743  p << 1, 1, 0;
744  joints[0].set_f(p);
745  p << 0, 0, -1;
746  joints[1].set_f(p);
747 
748  // set joint 1st derivative
749  p << 1, -1, 1;
750  joints[0].set_right_fp(p);
751 
752  // set the maximum degrees of each segment
753  max_degree[0]=4;
754 
755  // create curve
756  rtn_flag=gc.set_conditions(joints, max_degree, false);
757  TEST_ASSERT(rtn_flag);
758  gc.set_t0(t0);
759  gc.set_segment_dt(t1-t0, 0);
760  rtn_flag=gc.create(c);
761  TEST_ASSERT(rtn_flag);
762 
763  // test the resulting curve
764  point_type p_test;
765 
766  p_test=c.f(t0);
767  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
768 // std::cout << "p=" << joints[0].get_f()
769 // << "\tp_test=" << p_test << "\tdiff="
770 // << (joints[0].get_f()-p_test).norm() << std::endl;
771  p_test=c.f(t1);
772  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
773 // std::cout << "p=" << joints[1].get_f()
774 // << "\tp_test=" << p_test << "\tdiff="
775 // << (joints[1].get_f()-p_test).norm() << std::endl;
776  p_test=c.fp(t0);
777  TEST_ASSERT(tol.approximately_equal(joints[0].get_right_fp(), p_test));
778 // std::cout << "p=" << joints[0].get_right_fp()
779 // << "\tp_test=" << p_test << "\tdiff="
780 // << (joints[0].get_right_fp()-p_test).norm() << std::endl;
781 
782 // if (rtn_flag && (typeid(data_type)==typeid(double)))
783 // octave_print(1, c);
784  }
785 
786  // simple 2nd degree curve with 2nd derivative specified
787  {
788  index_type nsegs(1);
789  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
790  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
791  point_type p;
792  general_creator_type gc;
793  piecewise_curve_type c;
794  data_type t0(2), t1(4);
795  bool rtn_flag;
796 
797  // set the joints
798  p << 1, 1, 0;
799  joints[0].set_f(p);
800  p << 0, 0, -1;
801  joints[1].set_f(p);
802 
803  // set joint 2nd derivative
804  p << 1, -1, 1;
805  joints[0].set_right_fpp(p);
806 
807  // set the maximum degrees of each segment
808  max_degree[0]=4;
809 
810  // create curve
811  rtn_flag=gc.set_conditions(joints, max_degree, false);
812  TEST_ASSERT(rtn_flag);
813  gc.set_t0(t0);
814  gc.set_segment_dt(t1-t0, 0);
815  rtn_flag=gc.create(c);
816  TEST_ASSERT(rtn_flag);
817 
818  // test the resulting curve
819  point_type p_test;
820 
821  p_test=c.f(t0);
822  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
823 // std::cout << "p=" << joints[0].get_f()
824 // << "\tp_test=" << p_test << "\tdiff="
825 // << (joints[0].get_f()-p_test).norm() << std::endl;
826  p_test=c.f(t1);
827  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
828 // std::cout << "p=" << joints[1].get_f()
829 // << "\tp_test=" << p_test << "\tdiff="
830 // << (joints[1].get_f()-p_test).norm() << std::endl;
831  p_test=c.fpp(t0);
832  TEST_ASSERT(tol.approximately_equal(joints[0].get_right_fpp(), p_test));
833 // std::cout << "p=" << joints[0].get_right_fpp()
834 // << "\tp_test=" << p_test << "\tdiff="
835 // << (joints[0].get_right_fpp()-p_test).norm() << std::endl;
836 
837 // if (rtn_flag && (typeid(data_type)==typeid(double)))
838 // octave_print(1, c);
839  }
840 
841  // simple 3rd degree curve with both 1st derivatives specified
842  {
843  index_type nsegs(1);
844  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
845  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
846  point_type p;
847  general_creator_type gc;
848  piecewise_curve_type c;
849  data_type t0(2), t1(4);
850  bool rtn_flag;
851 
852  // set the joints
853  p << 1, 1, 0;
854  joints[0].set_f(p);
855  p << 0, 0, -1;
856  joints[1].set_f(p);
857 
858  // set joint 1st derivatives
859  p << 1, -1, 1;
860  joints[0].set_right_fp(p);
861  p << 1, 0, 0;
862  joints[1].set_left_fp(p);
863 
864  // set the maximum degrees of each segment to be too small
865  max_degree[0]=2;
866 
867  // create curve
868  rtn_flag=gc.set_conditions(joints, max_degree, false);
869  TEST_ASSERT(rtn_flag);
870  gc.set_t0(t0);
871  gc.set_segment_dt(t1-t0, 0);
872  rtn_flag=gc.create(c);
873  TEST_ASSERT(!rtn_flag);
874 
875  // set the maximum degrees of each segment
876  max_degree[0]=4;
877 
878  // create curve
879  rtn_flag=gc.set_conditions(joints, max_degree, false);
880  TEST_ASSERT(rtn_flag);
881  gc.set_t0(t0);
882  gc.set_segment_dt(t1-t0, 0);
883  rtn_flag=gc.create(c);
884  TEST_ASSERT(rtn_flag);
885 
886  // test the resulting curve
887  point_type p_test;
888 
889  p_test=c.f(t0);
890  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
891 // std::cout << "p=" << joints[0].get_f()
892 // << "\tp_test=" << p_test << "\tdiff="
893 // << (joints[0].get_f()-p_test).norm() << std::endl;
894  p_test=c.f(t1);
895  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
896 // std::cout << "p=" << joints[1].get_f()
897 // << "\tp_test=" << p_test << "\tdiff="
898 // << (joints[1].get_f()-p_test).norm() << std::endl;
899  p_test=c.fp(t0);
900  TEST_ASSERT(tol.approximately_equal(joints[0].get_right_fp(), p_test));
901 // std::cout << "p=" << joints[0].get_right_fp()
902 // << "\tp_test=" << p_test << "\tdiff="
903 // << (joints[0].get_right_fp()-p_test).norm() << std::endl;
904  p_test=c.fp(t1);
905  TEST_ASSERT(tol.approximately_equal(joints[1].get_left_fp(), p_test));
906 // std::cout << "p=" << joints[1].get_left_fp()
907 // << "\tp_test=" << p_test << "\tdiff="
908 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
909 
910 // if (rtn_flag && (typeid(data_type)==typeid(double)))
911 // octave_print(1, c);
912  }
913 
914  // simple 5th degree curve with both 1st and 2nd derivatives specified
915  {
916  index_type nsegs(1);
917  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
918  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
919  point_type p;
920  general_creator_type gc;
921  piecewise_curve_type c;
922  data_type t0(2), t1(4);
923  bool rtn_flag;
924 
925  // set the joints
926  p << 1, 1, 0;
927  joints[0].set_f(p);
928  p << 0, 0, -1;
929  joints[1].set_f(p);
930 
931  // set joint 1st derivatives
932  p << 1, -1, 1;
933  joints[0].set_right_fp(p);
934  p << 1, 0, 0;
935  joints[1].set_left_fp(p);
936 
937  // set joint 2nd derivatives
938  p << 0, -1, 0;
939  joints[0].set_right_fpp(p);
940  p << 0, 1, 0;
941  joints[1].set_left_fpp(p);
942 
943  // set the maximum degrees of each segment
944  max_degree[0]=6;
945 
946  // create curve
947  rtn_flag=gc.set_conditions(joints, max_degree, false);
948  TEST_ASSERT(rtn_flag);
949  gc.set_t0(t0);
950  gc.set_segment_dt(t1-t0, 0);
951  rtn_flag=gc.create(c);
952  TEST_ASSERT(rtn_flag);
953 
954  // test the resulting curve
955  point_type p_test;
956 
957  p_test=c.f(t0);
958  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
959 // std::cout << "p=" << joints[0].get_f()
960 // << "\tp_test=" << p_test << "\tdiff="
961 // << (joints[0].get_f()-p_test).norm() << std::endl;
962  p_test=c.f(t1);
963  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
964 // std::cout << "p=" << joints[1].get_f()
965 // << "\tp_test=" << p_test << "\tdiff="
966 // << (joints[1].get_f()-p_test).norm() << std::endl;
967  p_test=c.fp(t0);
968  TEST_ASSERT(tol.approximately_equal(joints[0].get_right_fp(), p_test));
969 // std::cout << "p=" << joints[0].get_right_fp()
970 // << "\tp_test=" << p_test << "\tdiff="
971 // << (joints[0].get_right_fp()-p_test).norm() << std::endl;
972  p_test=c.fp(t1);
973  TEST_ASSERT(tol.approximately_equal(joints[1].get_left_fp(), p_test));
974 // std::cout << "p=" << joints[1].get_left_fp()
975 // << "\tp_test=" << p_test << "\tdiff="
976 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
977  p_test=c.fpp(t0);
978  TEST_ASSERT(tol.approximately_equal(joints[0].get_right_fpp(), p_test));
979 // std::cout << "p=" << joints[0].get_right_fpp()
980 // << "\tp_test=" << p_test << "\tdiff="
981 // << (joints[0].get_right_fpp()-p_test).norm() << std::endl;
982  p_test=c.fpp(t1);
983  TEST_ASSERT(tol.approximately_equal(joints[1].get_left_fpp(), p_test));
984 // std::cout << "p=" << joints[1].get_left_fpp()
985 // << "\tp_test=" << p_test << "\tdiff="
986 // << (joints[1].get_left_fpp()-p_test).norm() << std::endl;
987 
988 // if (rtn_flag && (typeid(data_type)==typeid(double)))
989 // octave_print(1, c);
990  }
991  }
992 
994  {
995  // create two simple segments
996  {
997  index_type nsegs(2);
998  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
999  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1000  point_type p;
1001  general_creator_type gc;
1002  piecewise_curve_type c;
1003  std::vector<data_type> t(nsegs+1);
1004  bool rtn_flag;
1005 
1006  // set the times
1007  t[0]=2;
1008  t[1]=4;
1009  t[2]=7;
1010 
1011  // set the joints
1012  p << 0, 0, 0;
1013  joints[0].set_f(p);
1014  p << 0, 1, 0;
1015  joints[1].set_f(p);
1016  p << 1, 1, 1;
1017  joints[2].set_f(p);
1018 
1019  // set joint 1st derivatives
1020  p << 0, 1, 1;
1021  joints[0].set_right_fp(p);
1022  p << 0, 0, 1;
1023  joints[1].set_left_fp(p);
1024  p << 1, 0, 1;
1025  joints[1].set_right_fp(p);
1026  p << 0, 1, 1;
1027  joints[2].set_left_fp(p);
1028 
1029  // set the maximum degrees of each segment to be too small
1030  max_degree[0]=4;
1031  max_degree[1]=2;
1032 
1033  // create curve
1034  rtn_flag=gc.set_conditions(joints, max_degree, false);
1035  TEST_ASSERT(rtn_flag);
1036  gc.set_t0(t[0]);
1037  gc.set_segment_dt(t[1]-t[0], 0);
1038  gc.set_segment_dt(t[2]-t[1], 1);
1039  rtn_flag=gc.create(c);
1040  TEST_ASSERT(!rtn_flag);
1041 
1042  // set the maximum degrees of each segment
1043  max_degree[0]=4;
1044  max_degree[1]=4;
1045 
1046  // create curve
1047  rtn_flag=gc.set_conditions(joints, max_degree, false);
1048  TEST_ASSERT(rtn_flag);
1049  gc.set_t0(t[0]);
1050  gc.set_segment_dt(t[1]-t[0], 0);
1051  gc.set_segment_dt(t[2]-t[1], 1);
1052  rtn_flag=gc.create(c);
1053  TEST_ASSERT(rtn_flag);
1054 
1055  // test the resulting curve
1056  point_type p_test;
1057  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
1058 
1059  p_test=c.f(t[0]);
1060  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
1061 // std::cout << "p=" << joints[0].get_f()
1062 // << "\tp_test=" << p_test << "\tdiff="
1063 // << (joints[0].get_f()-p_test).norm() << std::endl;
1064  p_test=c.f(t[1]);
1065  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
1066 // std::cout << "p=" << joints[1].get_f()
1067 // << "\tp_test=" << p_test << "\tdiff="
1068 // << (joints[1].get_f()-p_test).norm() << std::endl;
1069  p_test=c.f(t[2]);
1070  TEST_ASSERT(tol.approximately_equal(joints[2].get_f(), p_test));
1071 // std::cout << "p=" << joints[1].get_f()
1072 // << "\tp_test=" << p_test << "\tdiff="
1073 // << (joints[1].get_f()-p_test).norm() << std::endl;
1074  p_test=c.fp(t[0]);
1075  TEST_ASSERT(tol.approximately_equal(joints[0].get_right_fp(), p_test));
1076 // std::cout << "p=" << joints[0].get_right_fp()
1077 // << "\tp_test=" << p_test << "\tdiff="
1078 // << (joints[0].get_right_fp()-p_test).norm() << std::endl;
1079  p_test=c.fp(t[1]-small_num);
1080  TEST_ASSERT(tol.approximately_equal(joints[1].get_left_fp(), p_test));
1081 // std::cout << "p=" << joints[1].get_left_fp()
1082 // << "\tp_test=" << p_test << "\tdiff="
1083 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
1084  p_test=c.fp(t[1]+small_num);
1085  TEST_ASSERT(tol.approximately_equal(joints[1].get_right_fp(), p_test));
1086 // std::cout << "p=" << joints[1].get_right_fp()
1087 // << "\tp_test=" << p_test << "\tdiff="
1088 // << (joints[1].get_right_fp()-p_test).norm() << std::endl;
1089  p_test=c.fp(t[2]);
1090  TEST_ASSERT(tol.approximately_equal(joints[2].get_left_fp(), p_test));
1091 // std::cout << "p=" << joints[1].get_left_fp()
1092 // << "\tp_test=" << p_test << "\tdiff="
1093 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
1094 
1095 // if (rtn_flag && (typeid(data_type)==typeid(double)))
1096 // octave_print(1, c);
1097  }
1098 
1099  // create five simple segments
1100  {
1101  index_type i, nsegs(5);
1102  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
1103  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1104  point_type p;
1105  general_creator_type gc;
1106  piecewise_curve_type c;
1107  std::vector<data_type> t(nsegs+1);
1108  bool rtn_flag;
1109 
1110  // set the times
1111  t[0]=2;
1112  t[1]=4;
1113  t[2]=7;
1114  t[3]=8;
1115  t[4]=10;
1116  t[5]=12;
1117 
1118  // set the joints
1119  p << 0, 0, 0;
1120  joints[0].set_f(p);
1121  p << 0, 1, 0;
1122  joints[1].set_f(p);
1123  p << 1, 1, 1;
1124  joints[2].set_f(p);
1125  p << 1, 1, 2;
1126  joints[3].set_f(p);
1127  p << 0, 2, 1;
1128  joints[4].set_f(p);
1129  p << 3, 3, 3;
1130  joints[5].set_f(p);
1131 
1132  // set joint 1st derivatives
1133  p << 0, 1, 1;
1134  joints[0].set_right_fp(p);
1135  p << 0, 0, 1;
1136  joints[1].set_left_fp(p);
1137  p << 1, 0, 1;
1138  joints[1].set_right_fp(p);
1139  p << 0, 1, 1;
1140  joints[2].set_left_fp(p);
1141  p << 1, 0, 1;
1142  joints[2].set_right_fp(p);
1143  p << 0, 1, 1;
1144  joints[3].set_left_fp(p);
1145  p << 0, 1, 1;
1146  joints[3].set_right_fp(p);
1147  p << 0, 0, 1;
1148  joints[4].set_left_fp(p);
1149  p << 1, 0, 1;
1150  joints[4].set_right_fp(p);
1151  p << 0, 0, 1;
1152  joints[5].set_left_fp(p);
1153 
1154  // set the maximum degrees of each segment
1155  max_degree[0]=4;
1156  max_degree[1]=4;
1157  max_degree[2]=4;
1158  max_degree[3]=4;
1159  max_degree[4]=4;
1160 
1161  // create curve
1162  rtn_flag=gc.set_conditions(joints, max_degree, false);
1163  TEST_ASSERT(rtn_flag);
1164  gc.set_t0(t[0]);
1165  for (i=0; i<nsegs; ++i)
1166  {
1167  gc.set_segment_dt(t[i+1]-t[i], i);
1168  }
1169  rtn_flag=gc.create(c);
1170  TEST_ASSERT(rtn_flag);
1171 
1172  // test the resulting curve
1173  point_type p_test;
1174  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
1175 
1176  p_test=c.f(t[0]);
1177  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
1178 // std::cout << "p=" << joints[0].get_f()
1179 // << "\tp_test=" << p_test << "\tdiff="
1180 // << (joints[0].get_f()-p_test).norm() << std::endl;
1181  p_test=c.f(t[1]);
1182  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
1183 // std::cout << "p=" << joints[1].get_f()
1184 // << "\tp_test=" << p_test << "\tdiff="
1185 // << (joints[1].get_f()-p_test).norm() << std::endl;
1186  p_test=c.f(t[2]);
1187  TEST_ASSERT(tol.approximately_equal(joints[2].get_f(), p_test));
1188 // std::cout << "p=" << joints[1].get_f()
1189 // << "\tp_test=" << p_test << "\tdiff="
1190 // << (joints[1].get_f()-p_test).norm() << std::endl;
1191  p_test=c.f(t[3]);
1192  TEST_ASSERT(tol.approximately_equal(joints[3].get_f(), p_test));
1193 // std::cout << "p=" << joints[1].get_f()
1194 // << "\tp_test=" << p_test << "\tdiff="
1195 // << (joints[1].get_f()-p_test).norm() << std::endl;
1196  p_test=c.f(t[4]);
1197  TEST_ASSERT(tol.approximately_equal(joints[4].get_f(), p_test));
1198 // std::cout << "p=" << joints[1].get_f()
1199 // << "\tp_test=" << p_test << "\tdiff="
1200 // << (joints[1].get_f()-p_test).norm() << std::endl;
1201  p_test=c.f(t[5]);
1202  TEST_ASSERT(tol.approximately_equal(joints[5].get_f(), p_test));
1203 // std::cout << "p=" << joints[1].get_f()
1204 // << "\tp_test=" << p_test << "\tdiff="
1205 // << (joints[1].get_f()-p_test).norm() << std::endl;
1206  p_test=c.fp(t[0]);
1207  TEST_ASSERT(tol.approximately_equal(joints[0].get_right_fp(), p_test));
1208 // std::cout << "p=" << joints[0].get_right_fp()
1209 // << "\tp_test=" << p_test << "\tdiff="
1210 // << (joints[0].get_right_fp()-p_test).norm() << std::endl;
1211  p_test=c.fp(t[1]-small_num);
1212  TEST_ASSERT(tol.approximately_equal(joints[1].get_left_fp(), p_test));
1213 // std::cout << "p=" << joints[1].get_left_fp()
1214 // << "\tp_test=" << p_test << "\tdiff="
1215 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
1216  p_test=c.fp(t[1]+small_num);
1217  TEST_ASSERT(tol.approximately_equal(joints[1].get_right_fp(), p_test));
1218 // std::cout << "p=" << joints[1].get_left_fp()
1219 // << "\tp_test=" << p_test << "\tdiff="
1220 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
1221  p_test=c.fp(t[2]-small_num);
1222  TEST_ASSERT(tol.approximately_equal(joints[2].get_left_fp(), p_test));
1223 // std::cout << "p=" << joints[1].get_left_fp()
1224 // << "\tp_test=" << p_test << "\tdiff="
1225 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
1226  p_test=c.fp(t[2]+small_num);
1227  TEST_ASSERT(tol.approximately_equal(joints[2].get_right_fp(), p_test));
1228 // std::cout << "p=" << joints[1].get_left_fp()
1229 // << "\tp_test=" << p_test << "\tdiff="
1230 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
1231  p_test=c.fp(t[3]-small_num);
1232  TEST_ASSERT(tol.approximately_equal(joints[3].get_left_fp(), p_test));
1233 // std::cout << "p=" << joints[1].get_left_fp()
1234 // << "\tp_test=" << p_test << "\tdiff="
1235 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
1236  p_test=c.fp(t[3]+small_num);
1237  TEST_ASSERT(tol.approximately_equal(joints[3].get_right_fp(), p_test));
1238 // std::cout << "p=" << joints[1].get_left_fp()
1239 // << "\tp_test=" << p_test << "\tdiff="
1240 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
1241  p_test=c.fp(t[4]-small_num);
1242  TEST_ASSERT(tol.approximately_equal(joints[4].get_left_fp(), p_test));
1243 // std::cout << "p=" << joints[1].get_left_fp()
1244 // << "\tp_test=" << p_test << "\tdiff="
1245 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
1246  p_test=c.fp(t[4]+small_num);
1247  TEST_ASSERT(tol.approximately_equal(joints[4].get_right_fp(), p_test));
1248 // std::cout << "p=" << joints[1].get_left_fp()
1249 // << "\tp_test=" << p_test << "\tdiff="
1250 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
1251  p_test=c.fp(t[5]);
1252  TEST_ASSERT(tol.approximately_equal(joints[5].get_left_fp(), p_test));
1253 // std::cout << "p=" << joints[1].get_left_fp()
1254 // << "\tp_test=" << p_test << "\tdiff="
1255 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
1256 
1257 // if (rtn_flag && (typeid(data_type)==typeid(double)))
1258 // octave_print(1, c);
1259  }
1260  }
1261 
1263  {
1264  // create two simple segments with 1st derivative continuity
1265  {
1266  index_type nsegs(2);
1267  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
1268  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1269  point_type p;
1270  general_creator_type gc;
1271  piecewise_curve_type c;
1272  std::vector<data_type> t(nsegs+1);
1273  bool rtn_flag;
1274 
1275  // set the times
1276  t[0]=2;
1277  t[1]=4;
1278  t[2]=7;
1279 
1280  // set the joints
1281  p << 0, 0, 0;
1282  joints[0].set_f(p);
1283  p << 0, 1, 0;
1284  joints[1].set_f(p);
1285  p << 1, 1, 1;
1286  joints[2].set_f(p);
1287 
1288  // set joint 1st derivative smoothness
1289  joints[1].set_continuity(general_creator_type::C1);
1290 
1291  // set the maximum degrees of each segment
1292  max_degree[0]=4;
1293  max_degree[1]=4;
1294 
1295  // create curve
1296  rtn_flag=gc.set_conditions(joints, max_degree, false);
1297  TEST_ASSERT(rtn_flag);
1298  gc.set_t0(t[0]);
1299  gc.set_segment_dt(t[1]-t[0], 0);
1300  gc.set_segment_dt(t[2]-t[1], 1);
1301  rtn_flag=gc.create(c);
1302  TEST_ASSERT(rtn_flag);
1303 
1304  // test the resulting curve
1305  point_type p_test, p_test1;
1306  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
1307 
1308  p_test=c.f(t[0]);
1309  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
1310 // std::cout << "p=" << joints[0].get_f()
1311 // << "\tp_test=" << p_test << "\tdiff="
1312 // << (joints[0].get_f()-p_test).norm() << std::endl;
1313  p_test=c.f(t[1]);
1314  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
1315 // std::cout << "p=" << joints[1].get_f()
1316 // << "\tp_test=" << p_test << "\tdiff="
1317 // << (joints[1].get_f()-p_test).norm() << std::endl;
1318  p_test=c.f(t[2]);
1319  TEST_ASSERT(tol.approximately_equal(joints[2].get_f(), p_test));
1320 // std::cout << "p=" << joints[2].get_f()
1321 // << "\tp_test=" << p_test << "\tdiff="
1322 // << (joints[2].get_f()-p_test).norm() << std::endl;
1323  p_test=c.fp(t[1]-small_num);
1324  p_test1=c.fp(t[1]+small_num);
1325  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1326 // std::cout << "p_test=" << p_test
1327 // << "\tp_test1=" << p_test1 << "\tdiff="
1328 // << (p_test-p_test1).norm() << std::endl;
1329 
1330 // if (rtn_flag && (typeid(data_type)==typeid(double)))
1331 // octave_print(1, c);
1332  }
1333 
1334  // create three segments where 1st interior joint has discontinuous, specified 1st derivative
1335  // and 2nd has continuous 1st derivative
1336  {
1337  index_type nsegs(3);
1338  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
1339  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1340  point_type p;
1341  general_creator_type gc;
1342  piecewise_curve_type c;
1343  std::vector<data_type> t(nsegs+1);
1344  bool rtn_flag;
1345 
1346  // set the times
1347  t[0]=2;
1348  t[1]=4;
1349  t[2]=7;
1350  t[3]=9;
1351 
1352  // set the joints
1353  p << 0, 0, 0;
1354  joints[0].set_f(p);
1355  p << 0, 1, 0;
1356  joints[1].set_f(p);
1357  p << 1, 1, 1;
1358  joints[2].set_f(p);
1359  p << 1, 1, 2;
1360  joints[3].set_f(p);
1361 
1362  // set joint 1st derivative smoothness
1363 
1364  // set joint 1st derivatives
1365  p << 0, 1, 1;
1366  joints[0].set_right_fp(p);
1367  p << 0, 0, 1;
1368  joints[1].set_left_fp(p);
1369  p << -1, 0, 1;
1370  joints[1].set_right_fp(p);
1371  joints[2].set_continuity(general_creator_type::C1);
1372  p << 0, 1, 1;
1373  joints[3].set_left_fp(p);
1374 
1375  // set the maximum degrees of each segment
1376  max_degree[0]=4;
1377  max_degree[1]=4;
1378  max_degree[2]=4;
1379 
1380  // create curve
1381  rtn_flag=gc.set_conditions(joints, max_degree, false);
1382  TEST_ASSERT(rtn_flag);
1383  gc.set_t0(t[0]);
1384  gc.set_segment_dt(t[1]-t[0], 0);
1385  gc.set_segment_dt(t[2]-t[1], 1);
1386  gc.set_segment_dt(t[3]-t[2], 2);
1387  rtn_flag=gc.create(c);
1388  TEST_ASSERT(rtn_flag);
1389 
1390  // test the resulting curve
1391  point_type p_test, p_test1;
1392  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
1393 
1394  p_test=c.f(t[0]);
1395  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
1396 // std::cout << "p=" << joints[0].get_f()
1397 // << "\tp_test=" << p_test << "\tdiff="
1398 // << (joints[0].get_f()-p_test).norm() << std::endl;
1399  p_test=c.f(t[1]);
1400  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
1401 // std::cout << "p=" << joints[1].get_f()
1402 // << "\tp_test=" << p_test << "\tdiff="
1403 // << (joints[1].get_f()-p_test).norm() << std::endl;
1404  p_test=c.f(t[2]);
1405  TEST_ASSERT(tol.approximately_equal(joints[2].get_f(), p_test));
1406 // std::cout << "p=" << joints[2].get_f()
1407 // << "\tp_test=" << p_test << "\tdiff="
1408 // << (joints[2].get_f()-p_test).norm() << std::endl;
1409  p_test=c.f(t[3]);
1410  TEST_ASSERT(tol.approximately_equal(joints[3].get_f(), p_test));
1411 // std::cout << "p=" << joints[3].get_f()
1412 // << "\tp_test=" << p_test << "\tdiff="
1413 // << (joints[3].get_f()-p_test).norm() << std::endl;
1414  p_test=c.fp(t[1]-small_num);
1415  TEST_ASSERT(tol.approximately_equal(joints[1].get_left_fp(), p_test));
1416 // std::cout << "p=" << joints[1].get_left_fp()
1417 // << "\tp_test=" << p_test << "\tdiff="
1418 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
1419  p_test=c.fp(t[1]+small_num);
1420  TEST_ASSERT(tol.approximately_equal(joints[1].get_right_fp(), p_test));
1421 // std::cout << "p=" << joints[1].get_right_fp()
1422 // << "\tp_test=" << p_test << "\tdiff="
1423 // << (joints[1].get_right_fp()-p_test).norm() << std::endl;
1424 
1425  p_test=c.fp(t[2]-small_num);
1426  p_test1=c.fp(t[2]+small_num);
1427  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1428 // std::cout << "p_test=" << p_test
1429 // << "\tp_test1=" << p_test1 << "\tdiff="
1430 // << (p_test-p_test1).norm() << std::endl;
1431 
1432 // if (rtn_flag && (typeid(data_type)==typeid(float)))
1433 // octave_print(1, c);
1434  }
1435 
1436  // create three segments where 1st interior joint has discontinuous, specified 1st derivative
1437  // and 2nd has one side slope specified and other is continuous 1st derivative
1438  {
1439  index_type nsegs(3);
1440  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
1441  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1442  point_type p;
1443  general_creator_type gc;
1444  piecewise_curve_type c;
1445  std::vector<data_type> t(nsegs+1);
1446  bool rtn_flag;
1447 
1448  // set the times
1449  t[0]=2;
1450  t[1]=4;
1451  t[2]=7;
1452  t[3]=9;
1453 
1454  // set the joints
1455  p << 0, 0, 0;
1456  joints[0].set_f(p);
1457  p << 0, 1, 0;
1458  joints[1].set_f(p);
1459  p << 1, 1, 1;
1460  joints[2].set_f(p);
1461  p << 1, 1, 2;
1462  joints[3].set_f(p);
1463 
1464  // set joint 1st derivative smoothness
1465 
1466  // set joint 1st derivatives
1467  p << 0, 1, 1;
1468  joints[0].set_right_fp(p);
1469  p << 0, 0, 1;
1470  joints[1].set_left_fp(p);
1471  p << -1, 0, 1;
1472  joints[1].set_right_fp(p);
1473  joints[2].set_continuity(general_creator_type::C1);
1474  p << 0, 1, 0;
1475  joints[2].set_right_fp(p);
1476  p << 0, 1, 1;
1477  joints[3].set_left_fp(p);
1478 
1479  // set the maximum degrees of each segment
1480  max_degree[0]=4;
1481  max_degree[1]=4;
1482  max_degree[2]=4;
1483 
1484  // create curve
1485  rtn_flag=gc.set_conditions(joints, max_degree, false);
1486  TEST_ASSERT(rtn_flag);
1487  gc.set_t0(t[0]);
1488  gc.set_segment_dt(t[1]-t[0], 0);
1489  gc.set_segment_dt(t[2]-t[1], 1);
1490  gc.set_segment_dt(t[3]-t[2], 2);
1491  rtn_flag=gc.create(c);
1492  TEST_ASSERT(rtn_flag);
1493 
1494  // test the resulting curve
1495  point_type p_test, p_test1;
1496  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
1497 
1498  p_test=c.f(t[0]);
1499  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
1500 // std::cout << "p=" << joints[0].get_f()
1501 // << "\tp_test=" << p_test << "\tdiff="
1502 // << (joints[0].get_f()-p_test).norm() << std::endl;
1503  p_test=c.f(t[1]);
1504  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
1505 // std::cout << "p=" << joints[1].get_f()
1506 // << "\tp_test=" << p_test << "\tdiff="
1507 // << (joints[1].get_f()-p_test).norm() << std::endl;
1508  p_test=c.f(t[2]);
1509  TEST_ASSERT(tol.approximately_equal(joints[2].get_f(), p_test));
1510 // std::cout << "p=" << joints[2].get_f()
1511 // << "\tp_test=" << p_test << "\tdiff="
1512 // << (joints[2].get_f()-p_test).norm() << std::endl;
1513  p_test=c.f(t[3]);
1514  TEST_ASSERT(tol.approximately_equal(joints[3].get_f(), p_test));
1515 // std::cout << "p=" << joints[3].get_f()
1516 // << "\tp_test=" << p_test << "\tdiff="
1517 // << (joints[3].get_f()-p_test).norm() << std::endl;
1518  p_test=c.fp(t[1]-small_num);
1519  TEST_ASSERT(tol.approximately_equal(joints[1].get_left_fp(), p_test));
1520 // std::cout << "p=" << joints[1].get_left_fp()
1521 // << "\tp_test=" << p_test << "\tdiff="
1522 // << (joints[1].get_left_fp()-p_test).norm() << std::endl;
1523  p_test=c.fp(t[1]+small_num);
1524  TEST_ASSERT(tol.approximately_equal(joints[1].get_right_fp(), p_test));
1525 // std::cout << "p=" << joints[1].get_right_fp()
1526 // << "\tp_test=" << p_test << "\tdiff="
1527 // << (joints[1].get_right_fp()-p_test).norm() << std::endl;
1528 
1529  p_test=c.fp(t[2]-small_num);
1530  p_test1=c.fp(t[2]+small_num);
1531  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1532  TEST_ASSERT(tol.approximately_equal(joints[2].get_right_fp(), p_test));
1533 // std::cout << "p_test=" << p_test
1534 // << "\tp_test1=" << p_test1 << "\tdiff="
1535 // << (p_test-p_test1).norm() << std::endl;
1536 
1537 // if (rtn_flag && (typeid(data_type)==typeid(float)))
1538 // octave_print(1, c);
1539  }
1540 
1541  // create five segments with all interior joints continuous 1st derivatives
1542  {
1543  index_type i, nsegs(5);
1544  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
1545  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1546  point_type p;
1547  general_creator_type gc;
1548  piecewise_curve_type c;
1549  std::vector<data_type> t(nsegs+1);
1550  bool rtn_flag;
1551 
1552  // set the times
1553  t[0]=2;
1554  t[1]=4;
1555  t[2]=7;
1556  t[3]=8;
1557  t[4]=10;
1558  t[5]=12;
1559 
1560  // set the joints
1561  p << 0, 0, 0;
1562  joints[0].set_f(p);
1563  p << 0, 1, 0;
1564  joints[1].set_f(p);
1565  p << 1, 1, 1;
1566  joints[2].set_f(p);
1567  p << 1, 1, 2;
1568  joints[3].set_f(p);
1569  p << 0, 2, 1;
1570  joints[4].set_f(p);
1571  p << 3, 3, 3;
1572  joints[5].set_f(p);
1573 
1574  // set joint 1st derivatives
1575  joints[1].set_continuity(general_creator_type::C1);
1576  joints[2].set_continuity(general_creator_type::C1);
1577  joints[3].set_continuity(general_creator_type::C1);
1578  joints[4].set_continuity(general_creator_type::C1);
1579 
1580  // set the maximum degrees of each segment
1581  max_degree[0]=4;
1582  max_degree[1]=4;
1583  max_degree[2]=4;
1584  max_degree[3]=4;
1585  max_degree[4]=4;
1586 
1587  // create curve
1588  rtn_flag=gc.set_conditions(joints, max_degree, false);
1589  TEST_ASSERT(rtn_flag);
1590  gc.set_t0(t[0]);
1591  for (i=0; i<nsegs; ++i)
1592  {
1593  gc.set_segment_dt(t[i+1]-t[i], i);
1594  }
1595  rtn_flag=gc.create(c);
1596  TEST_ASSERT(rtn_flag);
1597 
1598  // test the resulting curve
1599  point_type p_test, p_test1;
1600  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
1601 
1602  p_test=c.f(t[0]);
1603  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
1604 // std::cout << "p=" << joints[0].get_f()
1605 // << "\tp_test=" << p_test << "\tdiff="
1606 // << (joints[0].get_f()-p_test).norm() << std::endl;
1607  p_test=c.f(t[1]);
1608  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
1609 // std::cout << "p=" << joints[1].get_f()
1610 // << "\tp_test=" << p_test << "\tdiff="
1611 // << (joints[1].get_f()-p_test).norm() << std::endl;
1612  p_test=c.f(t[2]);
1613  TEST_ASSERT(tol.approximately_equal(joints[2].get_f(), p_test));
1614 // std::cout << "p=" << joints[1].get_f()
1615 // << "\tp_test=" << p_test << "\tdiff="
1616 // << (joints[1].get_f()-p_test).norm() << std::endl;
1617  p_test=c.f(t[3]);
1618  TEST_ASSERT(tol.approximately_equal(joints[3].get_f(), p_test));
1619 // std::cout << "p=" << joints[1].get_f()
1620 // << "\tp_test=" << p_test << "\tdiff="
1621 // << (joints[1].get_f()-p_test).norm() << std::endl;
1622  p_test=c.f(t[4]);
1623  TEST_ASSERT(tol.approximately_equal(joints[4].get_f(), p_test));
1624 // std::cout << "p=" << joints[1].get_f()
1625 // << "\tp_test=" << p_test << "\tdiff="
1626 // << (joints[1].get_f()-p_test).norm() << std::endl;
1627  p_test=c.f(t[5]);
1628  TEST_ASSERT(tol.approximately_equal(joints[5].get_f(), p_test));
1629 // std::cout << "p=" << joints[1].get_f()
1630 // << "\tp_test=" << p_test << "\tdiff="
1631 // << (joints[1].get_f()-p_test).norm() << std::endl;
1632  p_test=c.fp(t[1]-small_num);
1633  p_test1=c.fp(t[1]+small_num);
1634  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1635 // std::cout << "p_test=" << p_test
1636 // << "\tp_test1=" << p_test1 << "\tdiff="
1637 // << (p_test-p_test1).norm() << std::endl;
1638  p_test=c.fp(t[2]-small_num);
1639  p_test1=c.fp(t[2]+small_num);
1640  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1641 // std::cout << "p_test=" << p_test
1642 // << "\tp_test1=" << p_test1 << "\tdiff="
1643 // << (p_test-p_test1).norm() << std::endl;
1644  p_test=c.fp(t[3]-small_num);
1645  p_test1=c.fp(t[3]+small_num);
1646  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1647 // std::cout << "p_test=" << p_test
1648 // << "\tp_test1=" << p_test1 << "\tdiff="
1649 // << (p_test-p_test1).norm() << std::endl;
1650  p_test=c.fp(t[4]-small_num);
1651  p_test1=c.fp(t[4]+small_num);
1652  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1653 // std::cout << "p_test=" << p_test
1654 // << "\tp_test1=" << p_test1 << "\tdiff="
1655 // << (p_test-p_test1).norm() << std::endl;
1656 
1657 // if (rtn_flag && (typeid(data_type)==typeid(float)))
1658 // octave_print(1, c);
1659  }
1660  }
1662  {
1663  // create two simple segments with 2nd derivative continuity
1664  {
1665  index_type nsegs(2);
1666  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
1667  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1668  point_type p;
1669  general_creator_type gc;
1670  piecewise_curve_type c;
1671  std::vector<data_type> t(nsegs+1);
1672  bool rtn_flag;
1673 
1674  // set the times
1675  t[0]=2;
1676  t[1]=4;
1677  t[2]=7;
1678 
1679  // set the joints
1680  p << 0, 0, 0;
1681  joints[0].set_f(p);
1682  p << 0, 1, 0;
1683  joints[1].set_f(p);
1684  p << 1, 1, 1;
1685  joints[2].set_f(p);
1686 
1687  // set joint 2nd derivative smoothness
1688  joints[1].set_continuity(general_creator_type::C2);
1689 
1690  // set the maximum degrees of each segment
1691  max_degree[0]=4;
1692  max_degree[1]=4;
1693 
1694  // create curve
1695  rtn_flag=gc.set_conditions(joints, max_degree, false);
1696  TEST_ASSERT(rtn_flag);
1697  gc.set_t0(t[0]);
1698  gc.set_segment_dt(t[1]-t[0], 0);
1699  gc.set_segment_dt(t[2]-t[1], 1);
1700  rtn_flag=gc.create(c);
1701  TEST_ASSERT(rtn_flag);
1702 
1703  // test the resulting curve
1704  point_type p_test, p_test1;
1705  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
1706 
1707  p_test=c.f(t[0]);
1708  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
1709 // std::cout << "p=" << joints[0].get_f()
1710 // << "\tp_test=" << p_test << "\tdiff="
1711 // << (joints[0].get_f()-p_test).norm() << std::endl;
1712  p_test=c.f(t[1]);
1713  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
1714 // std::cout << "p=" << joints[1].get_f()
1715 // << "\tp_test=" << p_test << "\tdiff="
1716 // << (joints[1].get_f()-p_test).norm() << std::endl;
1717  p_test=c.f(t[2]);
1718  TEST_ASSERT(tol.approximately_equal(joints[2].get_f(), p_test));
1719 // std::cout << "p=" << joints[2].get_f()
1720 // << "\tp_test=" << p_test << "\tdiff="
1721 // << (joints[2].get_f()-p_test).norm() << std::endl;
1722  p_test=c.fp(t[1]-small_num);
1723  p_test1=c.fp(t[1]+small_num);
1724  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1725 // std::cout << "p_test=" << p_test
1726 // << "\tp_test1=" << p_test1 << "\tdiff="
1727 // << (p_test-p_test1).norm() << std::endl;
1728  p_test=c.fpp(t[1]-small_num);
1729  p_test1=c.fpp(t[1]+small_num);
1730  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1731 // std::cout << "p_test=" << p_test
1732 // << "\tp_test1=" << p_test1 << "\tdiff="
1733 // << (p_test-p_test1).norm() << std::endl;
1734 
1735 // if (rtn_flag && (typeid(data_type)==typeid(double)))
1736 // octave_print(1, c);
1737  }
1738 
1739  // create one line segment and another segment with 2nd derivative continuity
1740  {
1741  index_type nsegs(2);
1742  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
1743  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1744  point_type p;
1745  general_creator_type gc;
1746  piecewise_curve_type c;
1747  std::vector<data_type> t(nsegs+1);
1748  bool rtn_flag;
1749 
1750  // set the times
1751  t[0]=2;
1752  t[1]=4;
1753  t[2]=7;
1754 
1755  // set the joints
1756  p << 0, 0, 0;
1757  joints[0].set_f(p);
1758  p << 0, 1, 0;
1759  joints[1].set_f(p);
1760  p << 1, 1, 1;
1761  joints[2].set_f(p);
1762 
1763  // set joint 2nd derivative smoothness
1764  joints[1].set_continuity(general_creator_type::C2);
1765 
1766  // set the maximum degrees of each segment
1767  max_degree[0]=1;
1768  max_degree[1]=4;
1769 
1770  // create curve
1771  rtn_flag=gc.set_conditions(joints, max_degree, false);
1772  TEST_ASSERT(rtn_flag);
1773  gc.set_t0(t[0]);
1774  gc.set_segment_dt(t[1]-t[0], 0);
1775  gc.set_segment_dt(t[2]-t[1], 1);
1776  rtn_flag=gc.create(c);
1777  TEST_ASSERT(rtn_flag);
1778 
1779  // test the resulting curve
1780  point_type p_test, p_test1;
1781  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
1782 
1783  p_test=c.f(t[0]);
1784  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
1785 // std::cout << "p=" << joints[0].get_f()
1786 // << "\tp_test=" << p_test << "\tdiff="
1787 // << (joints[0].get_f()-p_test).norm() << std::endl;
1788  p_test=c.f(t[1]);
1789  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
1790 // std::cout << "p=" << joints[1].get_f()
1791 // << "\tp_test=" << p_test << "\tdiff="
1792 // << (joints[1].get_f()-p_test).norm() << std::endl;
1793  p_test=c.f(t[2]);
1794  TEST_ASSERT(tol.approximately_equal(joints[2].get_f(), p_test));
1795 // std::cout << "p=" << joints[2].get_f()
1796 // << "\tp_test=" << p_test << "\tdiff="
1797 // << (joints[2].get_f()-p_test).norm() << std::endl;
1798  p_test=c.fp(t[1]-small_num);
1799  p_test1=c.fp(t[1]+small_num);
1800  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1801 // std::cout << "p_test=" << p_test
1802 // << "\tp_test1=" << p_test1 << "\tdiff="
1803 // << (p_test-p_test1).norm() << std::endl;
1804  p_test=c.fpp(t[1]-small_num);
1805  p_test1=c.fpp(t[1]+small_num);
1806  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1807 // std::cout << "p_test=" << p_test
1808 // << "\tp_test1=" << p_test1 << "\tdiff="
1809 // << (p_test-p_test1).norm() << std::endl;
1810 
1811 // if (rtn_flag && (typeid(data_type)==typeid(float)))
1812 // octave_print(1, c);
1813  }
1814 
1815  // create one line segment and another segment with 2nd derivative continuity
1816  {
1817  index_type nsegs(2);
1818  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
1819  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1820  point_type p;
1821  general_creator_type gc;
1822  piecewise_curve_type c;
1823  std::vector<data_type> t(nsegs+1);
1824  bool rtn_flag;
1825 
1826  // set the times
1827  t[0]=2;
1828  t[1]=4;
1829  t[2]=7;
1830 
1831  // set the joints
1832  p << 0, 0, 0;
1833  joints[0].set_f(p);
1834  p << 0, 1, 0;
1835  joints[1].set_f(p);
1836  p << 1, 1, 1;
1837  joints[2].set_f(p);
1838 
1839  // set joint 2nd derivative smoothness
1840  joints[1].set_continuity(general_creator_type::C2);
1841 
1842  // set the maximum degrees of each segment
1843  max_degree[0]=4;
1844  max_degree[1]=1;
1845 
1846  // create curve
1847  rtn_flag=gc.set_conditions(joints, max_degree, false);
1848  TEST_ASSERT(rtn_flag);
1849  gc.set_t0(t[0]);
1850  gc.set_segment_dt(t[1]-t[0], 0);
1851  gc.set_segment_dt(t[2]-t[1], 1);
1852  rtn_flag=gc.create(c);
1853  TEST_ASSERT(rtn_flag);
1854 
1855  // test the resulting curve
1856  point_type p_test, p_test1;
1857  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
1858 
1859  p_test=c.f(t[0]);
1860  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
1861 // std::cout << "p=" << joints[0].get_f()
1862 // << "\tp_test=" << p_test << "\tdiff="
1863 // << (joints[0].get_f()-p_test).norm() << std::endl;
1864  p_test=c.f(t[1]);
1865  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
1866 // std::cout << "p=" << joints[1].get_f()
1867 // << "\tp_test=" << p_test << "\tdiff="
1868 // << (joints[1].get_f()-p_test).norm() << std::endl;
1869  p_test=c.f(t[2]);
1870  TEST_ASSERT(tol.approximately_equal(joints[2].get_f(), p_test));
1871 // std::cout << "p=" << joints[2].get_f()
1872 // << "\tp_test=" << p_test << "\tdiff="
1873 // << (joints[2].get_f()-p_test).norm() << std::endl;
1874  p_test=c.fp(t[1]-small_num);
1875  p_test1=c.fp(t[1]+small_num);
1876  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1877 // std::cout << "p_test=" << p_test
1878 // << "\tp_test1=" << p_test1 << "\tdiff="
1879 // << (p_test-p_test1).norm() << std::endl;
1880  p_test=c.fpp(t[1]-small_num);
1881  p_test1=c.fpp(t[1]+small_num);
1882  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1883 // std::cout << "p_test=" << p_test
1884 // << "\tp_test1=" << p_test1 << "\tdiff="
1885 // << (p_test-p_test1).norm() << std::endl;
1886 
1887 // if (rtn_flag && (typeid(data_type)==typeid(float)))
1888 // octave_print(1, c);
1889  }
1890 
1891  // create five segments with all interior joints continuous 2nd derivatives
1892  {
1893  index_type i, nsegs(5);
1894  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
1895  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1896  point_type p;
1897  general_creator_type gc;
1898  piecewise_curve_type c;
1899  std::vector<data_type> t(nsegs+1);
1900  bool rtn_flag;
1901 
1902  // set the times
1903  t[0]=2;
1904  t[1]=4;
1905  t[2]=7;
1906  t[3]=8;
1907  t[4]=10;
1908  t[5]=12;
1909 
1910  // set the joints
1911  p << 0, 0, 0;
1912  joints[0].set_f(p);
1913  p << 0, 1, 0;
1914  joints[1].set_f(p);
1915  p << 1, 1, 1;
1916  joints[2].set_f(p);
1917  p << 1, 1, 2;
1918  joints[3].set_f(p);
1919  p << 0, 2, 1;
1920  joints[4].set_f(p);
1921  p << 3, 3, 3;
1922  joints[5].set_f(p);
1923 
1924  // set joint 1st derivatives
1925  joints[1].set_continuity(general_creator_type::C2);
1926  joints[2].set_continuity(general_creator_type::C2);
1927  joints[3].set_continuity(general_creator_type::C2);
1928  joints[4].set_continuity(general_creator_type::C2);
1929 
1930  // set the maximum degrees of each segment
1931  max_degree[0]=4;
1932  max_degree[1]=4;
1933  max_degree[2]=4;
1934  max_degree[3]=4;
1935  max_degree[4]=4;
1936 
1937  // create curve
1938  rtn_flag=gc.set_conditions(joints, max_degree, false);
1939  TEST_ASSERT(rtn_flag);
1940  gc.set_t0(t[0]);
1941  for (i=0; i<nsegs; ++i)
1942  {
1943  gc.set_segment_dt(t[i+1]-t[i], i);
1944  }
1945  rtn_flag=gc.create(c);
1946  TEST_ASSERT(rtn_flag);
1947 
1948  // test the resulting curve
1949  point_type p_test, p_test1;
1950  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
1951 
1952  p_test=c.f(t[0]);
1953  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
1954 // std::cout << "p=" << joints[0].get_f()
1955 // << "\tp_test=" << p_test << "\tdiff="
1956 // << (joints[0].get_f()-p_test).norm() << std::endl;
1957  p_test=c.f(t[1]);
1958  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
1959 // std::cout << "p=" << joints[1].get_f()
1960 // << "\tp_test=" << p_test << "\tdiff="
1961 // << (joints[1].get_f()-p_test).norm() << std::endl;
1962  p_test=c.f(t[2]);
1963  TEST_ASSERT(tol.approximately_equal(joints[2].get_f(), p_test));
1964 // std::cout << "p=" << joints[1].get_f()
1965 // << "\tp_test=" << p_test << "\tdiff="
1966 // << (joints[1].get_f()-p_test).norm() << std::endl;
1967  p_test=c.f(t[3]);
1968  TEST_ASSERT(tol.approximately_equal(joints[3].get_f(), p_test));
1969 // std::cout << "p=" << joints[1].get_f()
1970 // << "\tp_test=" << p_test << "\tdiff="
1971 // << (joints[1].get_f()-p_test).norm() << std::endl;
1972  p_test=c.f(t[4]);
1973  TEST_ASSERT(tol.approximately_equal(joints[4].get_f(), p_test));
1974 // std::cout << "p=" << joints[1].get_f()
1975 // << "\tp_test=" << p_test << "\tdiff="
1976 // << (joints[1].get_f()-p_test).norm() << std::endl;
1977  p_test=c.f(t[5]);
1978  TEST_ASSERT(tol.approximately_equal(joints[5].get_f(), p_test));
1979 // std::cout << "p=" << joints[1].get_f()
1980 // << "\tp_test=" << p_test << "\tdiff="
1981 // << (joints[1].get_f()-p_test).norm() << std::endl;
1982  p_test=c.fp(t[1]-small_num);
1983  p_test1=c.fp(t[1]+small_num);
1984  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1985 // std::cout << "p_test=" << p_test
1986 // << "\tp_test1=" << p_test1 << "\tdiff="
1987 // << (p_test-p_test1).norm() << std::endl;
1988  p_test=c.fp(t[2]-small_num);
1989  p_test1=c.fp(t[2]+small_num);
1990  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1991 // std::cout << "p_test=" << p_test
1992 // << "\tp_test1=" << p_test1 << "\tdiff="
1993 // << (p_test-p_test1).norm() << std::endl;
1994  p_test=c.fp(t[3]-small_num);
1995  p_test1=c.fp(t[3]+small_num);
1996  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
1997 // std::cout << "p_test=" << p_test
1998 // << "\tp_test1=" << p_test1 << "\tdiff="
1999 // << (p_test-p_test1).norm() << std::endl;
2000  p_test=c.fp(t[4]-small_num);
2001  p_test1=c.fp(t[4]+small_num);
2002  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2003 // std::cout << "p_test=" << p_test
2004 // << "\tp_test1=" << p_test1 << "\tdiff="
2005 // << (p_test-p_test1).norm() << std::endl;
2006  p_test=c.fpp(t[1]-small_num);
2007  p_test1=c.fpp(t[1]+small_num);
2008  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2009 // std::cout << "p_test=" << p_test
2010 // << "\tp_test1=" << p_test1 << "\tdiff="
2011 // << (p_test-p_test1).norm() << std::endl;
2012  p_test=c.fpp(t[2]-small_num);
2013  p_test1=c.fpp(t[2]+small_num);
2014  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2015 // std::cout << "p_test=" << p_test
2016 // << "\tp_test1=" << p_test1 << "\tdiff="
2017 // << (p_test-p_test1).norm() << std::endl;
2018  p_test=c.fpp(t[3]-small_num);
2019  p_test1=c.fpp(t[3]+small_num);
2020  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2021 // std::cout << "p_test=" << p_test
2022 // << "\tp_test1=" << p_test1 << "\tdiff="
2023 // << (p_test-p_test1).norm() << std::endl;
2024  p_test=c.fpp(t[4]-small_num);
2025  p_test1=c.fpp(t[4]+small_num);
2026  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2027 // std::cout << "p_test=" << p_test
2028 // << "\tp_test1=" << p_test1 << "\tdiff="
2029 // << (p_test-p_test1).norm() << std::endl;
2030 
2031 // if (rtn_flag && (typeid(data_type)==typeid(float)))
2032 // octave_print(1, c);
2033  }
2034 
2035  // create five segments that are colinear and enforce 2nd derivative smoothness
2036  {
2037  index_type i, nsegs(5);
2038  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
2039  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
2040  point_type p;
2041  general_creator_type gc;
2042  piecewise_curve_type c;
2043  std::vector<data_type> t(nsegs+1);
2044  bool rtn_flag;
2045 
2046  // set the times
2047  t[0]=2;
2048  t[1]=4;
2049  t[2]=7;
2050  t[3]=8;
2051  t[4]=10;
2052  t[5]=12;
2053 
2054  // set the joints
2055  p << 0, 0, 0;
2056  joints[0].set_f(p);
2057  p << 1, 1, 1;
2058  joints[1].set_f(p);
2059  p << 2, 2, 2;
2060  joints[2].set_f(p);
2061  p << 4, 4, 4;
2062  joints[3].set_f(p);
2063  p << 5, 5, 5;
2064  joints[4].set_f(p);
2065  p << 7, 7, 7;
2066  joints[5].set_f(p);
2067 
2068  // set joint 1st derivatives
2069  joints[1].set_continuity(general_creator_type::C2);
2070  joints[2].set_continuity(general_creator_type::C2);
2071  joints[3].set_continuity(general_creator_type::C2);
2072  joints[4].set_continuity(general_creator_type::C2);
2073 
2074  // set the maximum degrees of each segment
2075  max_degree[0]=4;
2076  max_degree[1]=4;
2077  max_degree[2]=4;
2078  max_degree[3]=4;
2079  max_degree[4]=4;
2080 
2081  // create curve
2082  rtn_flag=gc.set_conditions(joints, max_degree, false);
2083  TEST_ASSERT(rtn_flag);
2084  gc.set_t0(t[0]);
2085  for (i=0; i<nsegs; ++i)
2086  {
2087  gc.set_segment_dt(t[i+1]-t[i], i);
2088  }
2089  rtn_flag=gc.create(c);
2090  TEST_ASSERT(rtn_flag);
2091 
2092  // test the resulting curve
2093  point_type p_test, p_test1;
2094  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
2095 
2096  p_test=c.f(t[0]);
2097  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
2098 // std::cout << "p=" << joints[0].get_f()
2099 // << "\tp_test=" << p_test << "\tdiff="
2100 // << (joints[0].get_f()-p_test).norm() << std::endl;
2101  p_test=c.f(t[1]);
2102  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
2103 // std::cout << "p=" << joints[1].get_f()
2104 // << "\tp_test=" << p_test << "\tdiff="
2105 // << (joints[1].get_f()-p_test).norm() << std::endl;
2106  p_test=c.f(t[2]);
2107  TEST_ASSERT(tol.approximately_equal(joints[2].get_f(), p_test));
2108 // std::cout << "p=" << joints[1].get_f()
2109 // << "\tp_test=" << p_test << "\tdiff="
2110 // << (joints[1].get_f()-p_test).norm() << std::endl;
2111  p_test=c.f(t[3]);
2112  TEST_ASSERT(tol.approximately_equal(joints[3].get_f(), p_test));
2113 // std::cout << "p=" << joints[1].get_f()
2114 // << "\tp_test=" << p_test << "\tdiff="
2115 // << (joints[1].get_f()-p_test).norm() << std::endl;
2116  p_test=c.f(t[4]);
2117  TEST_ASSERT(tol.approximately_equal(joints[4].get_f(), p_test));
2118 // std::cout << "p=" << joints[1].get_f()
2119 // << "\tp_test=" << p_test << "\tdiff="
2120 // << (joints[1].get_f()-p_test).norm() << std::endl;
2121  p_test=c.f(t[5]);
2122  TEST_ASSERT(tol.approximately_equal(joints[5].get_f(), p_test));
2123 // std::cout << "p=" << joints[1].get_f()
2124 // << "\tp_test=" << p_test << "\tdiff="
2125 // << (joints[1].get_f()-p_test).norm() << std::endl;
2126  p_test=c.fp(t[1]-small_num);
2127  p_test1=c.fp(t[1]+small_num);
2128  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2129 // std::cout << "p_test=" << p_test
2130 // << "\tp_test1=" << p_test1 << "\tdiff="
2131 // << (p_test-p_test1).norm() << std::endl;
2132  p_test=c.fp(t[2]-small_num);
2133  p_test1=c.fp(t[2]+small_num);
2134  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2135 // std::cout << "p_test=" << p_test
2136 // << "\tp_test1=" << p_test1 << "\tdiff="
2137 // << (p_test-p_test1).norm() << std::endl;
2138  p_test=c.fp(t[3]-small_num);
2139  p_test1=c.fp(t[3]+small_num);
2140  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2141 // std::cout << "p_test=" << p_test
2142 // << "\tp_test1=" << p_test1 << "\tdiff="
2143 // << (p_test-p_test1).norm() << std::endl;
2144  p_test=c.fp(t[4]-small_num);
2145  p_test1=c.fp(t[4]+small_num);
2146  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2147 // std::cout << "p_test=" << p_test
2148 // << "\tp_test1=" << p_test1 << "\tdiff="
2149 // << (p_test-p_test1).norm() << std::endl;
2150  p_test=c.fpp(t[1]-small_num);
2151  p_test1=c.fpp(t[1]+small_num);
2152  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2153 // std::cout << "p_test=" << p_test
2154 // << "\tp_test1=" << p_test1 << "\tdiff="
2155 // << (p_test-p_test1).norm() << std::endl;
2156  p_test=c.fpp(t[2]-small_num);
2157  p_test1=c.fpp(t[2]+small_num);
2158  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2159 // std::cout << "p_test=" << p_test
2160 // << "\tp_test1=" << p_test1 << "\tdiff="
2161 // << (p_test-p_test1).norm() << std::endl;
2162  p_test=c.fpp(t[3]-small_num);
2163  p_test1=c.fpp(t[3]+small_num);
2164  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2165 // std::cout << "p_test=" << p_test
2166 // << "\tp_test1=" << p_test1 << "\tdiff="
2167 // << (p_test-p_test1).norm() << std::endl;
2168  p_test=c.fpp(t[4]-small_num);
2169  p_test1=c.fpp(t[4]+small_num);
2170  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2171 // std::cout << "p_test=" << p_test
2172 // << "\tp_test1=" << p_test1 << "\tdiff="
2173 // << (p_test-p_test1).norm() << std::endl;
2174 
2175 // if (rtn_flag && (typeid(data_type)==typeid(float)))
2176 // octave_print(1, c);
2177  }
2178 
2179  // create five segments with a variety of continuities
2180  {
2181  index_type i, nsegs(5);
2182  std::vector<typename general_creator_type::joint_data> joints(nsegs+1);
2183  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
2184  point_type p;
2185  general_creator_type gc;
2186  piecewise_curve_type c;
2187  std::vector<data_type> t(nsegs+1);
2188  bool rtn_flag;
2189 
2190  // set the times
2191  t[0]=2;
2192  t[1]=4;
2193  t[2]=7;
2194  t[3]=8;
2195  t[4]=10;
2196  t[5]=12;
2197 
2198  // set the joints
2199  p << 0, 0, 0;
2200  joints[0].set_f(p);
2201  p << 0, 2, 0;
2202  joints[1].set_f(p);
2203  p << 1, 1, 1;
2204  joints[2].set_f(p);
2205  p << 1, 1, 2;
2206  joints[3].set_f(p);
2207  p << 0, 2, 1;
2208  joints[4].set_f(p);
2209  p << 3, 3, 3;
2210  joints[5].set_f(p);
2211 
2212  // set joint 1st derivatives
2213  joints[1].set_continuity(general_creator_type::C1);
2214  joints[2].set_continuity(general_creator_type::C0);
2215  joints[3].set_continuity(general_creator_type::C2);
2216  joints[4].set_continuity(general_creator_type::C2);
2217 
2218  // set the maximum degrees of each segment
2219  max_degree[0]=0;
2220  max_degree[1]=1;
2221  max_degree[2]=0;
2222  max_degree[3]=0;
2223  max_degree[4]=0;
2224 
2225  // create curve
2226  rtn_flag=gc.set_conditions(joints, max_degree, false);
2227  TEST_ASSERT(rtn_flag);
2228  gc.set_t0(t[0]);
2229  for (i=0; i<nsegs; ++i)
2230  {
2231  gc.set_segment_dt(t[i+1]-t[i], i);
2232  }
2233  rtn_flag=gc.create(c);
2234  TEST_ASSERT(rtn_flag);
2235 
2236  // test the resulting curve
2237  point_type p_test, p_test1;
2238  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
2239 
2240  p_test=c.f(t[0]);
2241  TEST_ASSERT(tol.approximately_equal(joints[0].get_f(), p_test));
2242 // std::cout << "p=" << joints[0].get_f()
2243 // << "\tp_test=" << p_test << "\tdiff="
2244 // << (joints[0].get_f()-p_test).norm() << std::endl;
2245  p_test=c.f(t[1]);
2246  TEST_ASSERT(tol.approximately_equal(joints[1].get_f(), p_test));
2247 // std::cout << "p=" << joints[1].get_f()
2248 // << "\tp_test=" << p_test << "\tdiff="
2249 // << (joints[1].get_f()-p_test).norm() << std::endl;
2250  p_test=c.f(t[2]);
2251  TEST_ASSERT(tol.approximately_equal(joints[2].get_f(), p_test));
2252 // std::cout << "p=" << joints[1].get_f()
2253 // << "\tp_test=" << p_test << "\tdiff="
2254 // << (joints[1].get_f()-p_test).norm() << std::endl;
2255  p_test=c.f(t[3]);
2256  TEST_ASSERT(tol.approximately_equal(joints[3].get_f(), p_test));
2257 // std::cout << "p=" << joints[1].get_f()
2258 // << "\tp_test=" << p_test << "\tdiff="
2259 // << (joints[1].get_f()-p_test).norm() << std::endl;
2260  p_test=c.f(t[4]);
2261  TEST_ASSERT(tol.approximately_equal(joints[4].get_f(), p_test));
2262 // std::cout << "p=" << joints[1].get_f()
2263 // << "\tp_test=" << p_test << "\tdiff="
2264 // << (joints[1].get_f()-p_test).norm() << std::endl;
2265  p_test=c.f(t[5]);
2266  TEST_ASSERT(tol.approximately_equal(joints[5].get_f(), p_test));
2267 // std::cout << "p=" << joints[1].get_f()
2268 // << "\tp_test=" << p_test << "\tdiff="
2269 // << (joints[1].get_f()-p_test).norm() << std::endl;
2270  p_test=c.fp(t[1]-small_num);
2271  p_test1=c.fp(t[1]+small_num);
2272  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2273 // std::cout << "p_test=" << p_test
2274 // << "\tp_test1=" << p_test1 << "\tdiff="
2275 // << (p_test-p_test1).norm() << std::endl;
2276  p_test=c.fp(t[2]-small_num);
2277  p_test1=c.fp(t[2]+small_num);
2278  TEST_ASSERT(!tol.approximately_equal(p_test, p_test1));
2279 // std::cout << "p_test=" << p_test
2280 // << "\tp_test1=" << p_test1 << "\tdiff="
2281 // << (p_test-p_test1).norm() << std::endl;
2282  p_test=c.fp(t[3]-small_num);
2283  p_test1=c.fp(t[3]+small_num);
2284  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2285 // std::cout << "p_test=" << p_test
2286 // << "\tp_test1=" << p_test1 << "\tdiff="
2287 // << (p_test-p_test1).norm() << std::endl;
2288  p_test=c.fp(t[4]-small_num);
2289  p_test1=c.fp(t[4]+small_num);
2290  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2291 // std::cout << "p_test=" << p_test
2292 // << "\tp_test1=" << p_test1 << "\tdiff="
2293 // << (p_test-p_test1).norm() << std::endl;
2294  p_test=c.fpp(t[1]-small_num);
2295  p_test1=c.fpp(t[1]+small_num);
2296  TEST_ASSERT(!tol.approximately_equal(p_test, p_test1));
2297 // std::cout << "p_test=" << p_test
2298 // << "\tp_test1=" << p_test1 << "\tdiff="
2299 // << (p_test-p_test1).norm() << std::endl;
2300  p_test=c.fpp(t[2]-small_num);
2301  p_test1=c.fpp(t[2]+small_num);
2302  TEST_ASSERT(!tol.approximately_equal(p_test, p_test1));
2303 // std::cout << "p_test=" << p_test
2304 // << "\tp_test1=" << p_test1 << "\tdiff="
2305 // << (p_test-p_test1).norm() << std::endl;
2306  p_test=c.fpp(t[3]-small_num);
2307  p_test1=c.fpp(t[3]+small_num);
2308  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2309 // std::cout << "p_test=" << p_test
2310 // << "\tp_test1=" << p_test1 << "\tdiff="
2311 // << (p_test-p_test1).norm() << std::endl;
2312  p_test=c.fpp(t[4]-small_num);
2313  p_test1=c.fpp(t[4]+small_num);
2314  TEST_ASSERT(tol.approximately_equal(p_test, p_test1));
2315 // std::cout << "p_test=" << p_test
2316 // << "\tp_test1=" << p_test1 << "\tdiff="
2317 // << (p_test-p_test1).norm() << std::endl;
2318 
2319 // if (rtn_flag && (typeid(data_type)==typeid(float)))
2320 // octave_print(1, c);
2321  }
2322  }
2323 };
2324 
2325 #endif
2326 
piecewise_curve_type::point_type point_type
Definition: piecewise_general_creator_test_suite.hpp:34
general_creator_type::joint_data joint_data_type
Definition: piecewise_general_creator_test_suite.hpp:39
point_type get_f() const
Definition: piecewise_general_creator.hpp:138
bool set_f(const point_type &p)
Definition: piecewise_general_creator.hpp:132
virtual bool create(piecewise< bezier, data_type, dim__, tolerance_type > &pc) const
Definition: piecewise_general_creator.hpp:432
void AddTests(const float &)
Definition: piecewise_general_creator_test_suite.hpp:44
Definition: piecewise_general_creator_test_suite.hpp:29
bool unset_left_fpp()
Definition: piecewise_general_creator.hpp:283
bool unset_right_fpp()
Definition: piecewise_general_creator.hpp:289
void set_segment_dt(const data_type &dtt, const index_type &i)
Definition: piecewise_creator_base.hpp:64
bool set_right_fpp(const point_type &fppr)
Definition: piecewise_general_creator.hpp:242
void AddTests(const double &)
Definition: piecewise_general_creator_test_suite.hpp:53
bool set_continuity(joint_continuity jc)
Definition: piecewise_general_creator.hpp:305
bool unset_fpp()
Definition: piecewise_general_creator.hpp:278
bool set_conditions(const std::vector< joint_data > &jnts, const std::vector< index_type > &maxd, bool cl=false)
Definition: piecewise_general_creator.hpp:392
point_type get_right_fpp() const
Definition: piecewise_general_creator.hpp:268
tol__ tolerance_type
Definition: piecewise.hpp:278
bool set_right_fp(const point_type &fpr)
Definition: piecewise_general_creator.hpp:164
data__ data_type
Definition: piecewise.hpp:276
~piecewise_general_creator_test_suite()
Definition: piecewise_general_creator_test_suite.hpp:77
point_type get_right_fp() const
Definition: piecewise_general_creator.hpp:190
data_type get_parameter_min() const
Definition: piecewise.hpp:366
bool unset_fp()
Definition: piecewise_general_creator.hpp:200
curve_type::index_type index_type
Definition: piecewise.hpp:271
bool use_left_fp() const
Definition: piecewise_general_creator.hpp:218
index_type number_segments() const
Definition: piecewise.hpp:419
point_type get_left_fpp() const
Definition: piecewise_general_creator.hpp:264
bool check_state() const
Definition: piecewise_general_creator.hpp:315
piecewise_curve_type::index_type index_type
Definition: piecewise_general_creator_test_suite.hpp:36
bool set_fp(const point_type &p)
Definition: piecewise_general_creator.hpp:178
joint_continuity get_continuity() const
Definition: piecewise_general_creator.hpp:310
Definition: piecewise.hpp:244
bool unset_left_fp()
Definition: piecewise_general_creator.hpp:205
Definition: piecewise_general_creator.hpp:36
point_type fpp(const data_type &t) const
Definition: piecewise.hpp:1765
bool use_right_fp() const
Definition: piecewise_general_creator.hpp:222
curve__< data__, dim__, tol__ > curve_type
Definition: piecewise.hpp:270
piecewise_curve_type::curve_type curve_type
Definition: piecewise_general_creator_test_suite.hpp:33
void create_multi_curve_2nd_deriv_dep_test()
Definition: piecewise_general_creator_test_suite.hpp:1661
void create_joint_test()
Definition: piecewise_general_creator_test_suite.hpp:187
void octave_print(int figno, const piecewise_curve_type &pc) const
Definition: piecewise_general_creator_test_suite.hpp:82
bool use_left_fpp() const
Definition: piecewise_general_creator.hpp:296
void create_multi_curve_1st_deriv_dep_test()
Definition: piecewise_general_creator_test_suite.hpp:1262
void create_single_curve_test()
Definition: piecewise_general_creator_test_suite.hpp:683
Definition: piecewise_general_creator.hpp:57
data_type get_parameter_max() const
Definition: piecewise.hpp:374
point_type fp(const data_type &t) const
Definition: piecewise.hpp:1748
bool unset_f()
Definition: piecewise_general_creator.hpp:139
void AddTests(const long double &)
Definition: piecewise_general_creator_test_suite.hpp:62
bool unset_right_fp()
Definition: piecewise_general_creator.hpp:211
Definition: piecewise_general_creator.hpp:58
point_type f(const data_type &t) const
Definition: piecewise.hpp:1732
eli::geom::curve::piecewise< eli::geom::curve::bezier, data__, 3 > piecewise_curve_type
Definition: piecewise_general_creator_test_suite.hpp:32
eli::geom::curve::piecewise_general_creator< data__, 3, tolerance_type > general_creator_type
Definition: piecewise_general_creator_test_suite.hpp:38
tolerance_type tol
Definition: piecewise_general_creator_test_suite.hpp:41
bool set_fpp(const point_type &p)
Definition: piecewise_general_creator.hpp:256
bool use_right_fpp() const
Definition: piecewise_general_creator.hpp:300
Definition: piecewise_general_creator.hpp:56
void create_multi_curve_no_dep_test()
Definition: piecewise_general_creator_test_suite.hpp:993
piecewise_curve_type::tolerance_type tolerance_type
Definition: piecewise_general_creator_test_suite.hpp:37
error_code get(curve_type &curve, const index_type &index) const
Definition: piecewise.hpp:729
curve_type::point_type point_type
Definition: piecewise.hpp:272
bool set_left_fpp(const point_type &fppl)
Definition: piecewise_general_creator.hpp:228
point_type get_left_fp() const
Definition: piecewise_general_creator.hpp:186
void set_t0(const data_type &tt0)
Definition: piecewise_creator_base.hpp:61
piecewise_general_creator_test_suite()
Definition: piecewise_general_creator_test_suite.hpp:73
bool set_left_fp(const point_type &fpl)
Definition: piecewise_general_creator.hpp:150
bool use_f() const
Definition: piecewise_general_creator.hpp:144
piecewise_curve_type::data_type data_type
Definition: piecewise_general_creator_test_suite.hpp:35
Definition: piecewise_general_creator.hpp:61