Code-Eli  0.3.6
explicit_bezier_curve_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 explicit_bezier_curve_test_suite_hpp
14 #define explicit_bezier_curve_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"
29 
30 template<typename data__>
31 class explicit_bezier_curve_test_suite : public Test::Suite
32 {
33  private:
37  typedef typename curve_type::data_type data_type;
39 
40  protected:
41  void AddTests(const float &)
42  {
43  // add the tests
51  }
52  void AddTests(const double &)
53  {
54  // add the tests
62  }
63  void AddTests(const long double &)
64  {
65  // add the tests
73  }
74 
75  public:
77  {
78  AddTests(data__());
79  }
81  {
82  }
83 
84  private:
85  void octave_print(int figno, const std::vector<point_type, Eigen::aligned_allocator<point_type> > &pts, const curve_type &bez) const
86  {
87  size_t i;
88 
89  std::cout << "figure(" << figno << ");" << std::endl;
90  std::cout << "xpts=[" << pts[0].x();
91  for (i=1; i<pts.size(); ++i)
92  std::cout << ", " << pts[i].x();
93  std::cout << "];" << std::endl;
94  std::cout << "ypts=[" << pts[0].y();
95  for (i=1; i<pts.size(); ++i)
96  std::cout << ", " << pts[i].y();
97  std::cout << "];" << std::endl;
98 
99  std::vector<data_type> t(101);
100  for (i=0; i<t.size(); ++i)
101  t[i]=static_cast<data_type>(i)/(t.size()-1);
102 
103  std::cout << "xint=[" << bez.f(t[0])(0);
104  for (i=1; i<t.size(); ++i)
105  std::cout << ", " << bez.f(t[i])(0);
106  std::cout << "];" << std::endl;
107  std::cout << "yint=[" << bez.f(t[0])(1);
108  for (i=1; i<t.size(); ++i)
109  std::cout << ", " << bez.f(t[i])(1);
110  std::cout << "];" << std::endl;
111 
112  std::cout << "plot(xpts, ypts, 'bo', xint, yint, 'k-');" << std::endl;
113  }
114 
115  void create_circle(std::vector<point_type, Eigen::aligned_allocator<point_type> > &pts)
116  {
117  // NOTE: This will create a semi-circle
118  size_t n=pts.size();
119  for (size_t i=0; i<n; ++i)
120  {
121  data__ theta(eli::constants::math<data__>::pi()*static_cast<data__>(i)/(n-1));
122  pts[i](0)=(1-std::cos(theta))/2;
123  pts[i](1)=std::sin(theta);
124  }
125  }
126 
128  {
129  curve_type ebc1(3), ebc2;
130  control_point_type cntrl_in[4];
131 
132  // test default constructor then set control points
133  cntrl_in[0] << 2.0;
134  cntrl_in[1] << 1.0;
135  cntrl_in[2] << 3.5;
136  cntrl_in[3] << 4.0;
137 
138  for (index_type i=0; i<4; ++i)
139  {
140  ebc1.set_control_point(cntrl_in[i], i);
141  }
142 
143  for (index_type i=0; i<4; ++i)
144  {
145  TEST_ASSERT(ebc1.get_control_point(i)==cntrl_in[i]);
146  }
147 
148  // test copy ctr
149  curve_type ebcc1(ebc1);
150  for (index_type i=0; i<4; ++i)
151  {
152  TEST_ASSERT(ebcc1.get_control_point(i)==cntrl_in[i]);
153  }
154 
155  // test assignment operator
156  ebc2=ebc1;
157  for (index_type i=0; i<4; ++i)
158  {
159  TEST_ASSERT(ebc2.get_control_point(i)==cntrl_in[i]);
160  }
161 
162  // test order
163  TEST_ASSERT(ebc2.degree()==3);
164  }
165 
167  {
168  curve_type ebc1(3), ebc2;
169  control_point_type cntrl_in[4];
170 
171  // test default constructor then set control points
172  cntrl_in[0] << 2.0;
173  cntrl_in[1] << 1.0;
174  cntrl_in[2] << 3.5;
175  cntrl_in[3] << 4.0;
176 
177  for (index_type i=0; i<4; ++i)
178  {
179  ebc1.set_control_point(cntrl_in[i], i);
180  }
181 
182  ebc2=ebc1;
183  ebc1.reverse();
184  for (index_type i=0; i<4; ++i)
185  {
186  TEST_ASSERT(ebc1.get_control_point(i)==ebc2.get_control_point(3-i));
187  }
188  }
189 
191  {
192  typedef eli::geom::curve::bezier<data__, 2> bezier_curve_type;
193  data_type eps(std::numeric_limits<data__>::epsilon());
194 
195  control_point_type cntrl_in[5];
196  typename bezier_curve_type::control_point_type bez_cntrl[5];
197  curve_type ebc;
198  bezier_curve_type bc;
199  typename curve_type::point_type eval_out, eval_ref;
200  typename curve_type::data_type t;
201 
202  // set control points and create curves
203  cntrl_in[0] << 2.0;
204  cntrl_in[1] << 1.5;
205  cntrl_in[2] << 0.0;
206  cntrl_in[3] << 1.0;
207  cntrl_in[4] << 0.5;
208  bez_cntrl[0] << 0, 2;
209  bez_cntrl[1] << 0.25, 1.5;
210  bez_cntrl[2] << 0.5, 0;
211  bez_cntrl[3] << 0.75, 1;
212  bez_cntrl[4] << 1, 0.5;
213 
214  ebc.resize(4);
215  bc.resize(4);
216  for (index_type i=0; i<5; ++i)
217  {
218  ebc.set_control_point(cntrl_in[i], i);
219  bc.set_control_point(bez_cntrl[i], i);
220  }
221 
222  // test evaluation at end points
223  t=0;
224  eval_out=ebc.f(t);
225  eval_ref=bc.f(t);
226  TEST_ASSERT(eval_out==eval_ref);
227  t=1;
228  eval_out=ebc.f(t);
229  eval_ref=bc.f(t);
230  TEST_ASSERT(eval_out==eval_ref);
231 
232  // test evaluation at interior point
233  t=static_cast<data__>(0.45);
234  eval_out=ebc.f(t);
235  eval_ref=bc.f(t);
236  TEST_ASSERT((eval_out-eval_ref).norm()<1.1*eps);
237  }
238 
240  {
241  typedef eli::geom::curve::bezier<data__, 2> bezier_curve_type;
242  data_type eps(std::numeric_limits<data__>::epsilon());
243  control_point_type cntrl_in[5];
244  typename bezier_curve_type::control_point_type bez_cntrl[5];
245  curve_type ebc;
246  bezier_curve_type bc;
247  typename curve_type::point_type eval_out, eval_ref;
248  typename curve_type::data_type t;
249 
250  // set control points and create curves
251  cntrl_in[0] << 2.0;
252  cntrl_in[1] << 1.5;
253  cntrl_in[2] << 0.0;
254  cntrl_in[3] << 1.0;
255  cntrl_in[4] << 0.5;
256  bez_cntrl[0] << 0, 2;
257  bez_cntrl[1] << 0.25, 1.5;
258  bez_cntrl[2] << 0.5, 0;
259  bez_cntrl[3] << 0.75, 1;
260  bez_cntrl[4] << 1, 0.5;
261 
262  ebc.resize(4);
263  bc.resize(4);
264  for (index_type i=0; i<5; ++i)
265  {
266  ebc.set_control_point(cntrl_in[i], i);
267  bc.set_control_point(bez_cntrl[i], i);
268  }
269 
270  // test 1st derivative at end points
271  t=0;
272  eval_out=ebc.fp(t);
273  eval_ref=bc.fp(t);
274  TEST_ASSERT(eval_out==eval_ref);
275  t=1;
276  eval_out=ebc.fp(t);
277  eval_ref=bc.fp(t);
278  TEST_ASSERT(eval_out==eval_ref);
279 
280  // test 1st derivative at interior point
281  t=static_cast<data__>(0.45);
282  eval_out=ebc.fp(t);
283  eval_ref=bc.fp(t);
284  if (typeid(data__)==typeid(float))
285  {
286  TEST_ASSERT((eval_out-eval_ref).norm()<3*eps);
287  }
288  else
289  {
290  TEST_ASSERT(eval_out==eval_ref);
291  }
292 
293  // test 2nd derivative at end points
294  t=0;
295  eval_out=ebc.fpp(t);
296  eval_ref=bc.fpp(t);
297  TEST_ASSERT(eval_out==eval_ref);
298  t=1;
299  eval_out=ebc.fpp(t);
300  eval_ref=bc.fpp(t);
301  TEST_ASSERT(eval_out==eval_ref);
302 
303  // test 2nd derivative at interior point
304  t=static_cast<data__>(0.45);
305  eval_out=ebc.fpp(t);
306  eval_ref=bc.fpp(t);
307  if (typeid(data__)==typeid(float))
308  {
309  TEST_ASSERT((eval_out-eval_ref).norm()<17*eps);
310  }
311  else
312  {
313  TEST_ASSERT(eval_out==eval_ref);
314  }
315 
316  // test 3rd derivative at end points
317  t=0;
318  eval_out=ebc.fppp(t);
319  eval_ref=bc.fppp(t);
320  TEST_ASSERT(eval_out==eval_ref);
321  t=1;
322  eval_out=ebc.fppp(t);
323  eval_ref=bc.fppp(t);
324  TEST_ASSERT(eval_out==eval_ref);
325 
326  // test 3rd derivative at interior point
327  t=static_cast<data__>(0.45);
328  eval_out=ebc.fppp(t);
329  eval_ref=bc.fppp(t);
330  TEST_ASSERT(eval_out==eval_ref);
331 
332  // test curvature at end points
333  data_type curv_out, curv_ref;
334  t=0;
335  eli::geom::curve::curvature(curv_out, ebc, t);
336  eli::geom::curve::curvature(curv_ref, bc, t);
337  TEST_ASSERT(curv_out==curv_ref);
338  t=1;
339  eli::geom::curve::curvature(curv_out, ebc, t);
340  eli::geom::curve::curvature(curv_ref, bc, t);
341  TEST_ASSERT(curv_out==curv_ref);
342 
343  // test curvature at interior point
344  t=static_cast<data__>(0.45);
345  eli::geom::curve::curvature(curv_out, ebc, t);
346  eli::geom::curve::curvature(curv_ref, bc, t);
347  if (typeid(data__)==typeid(float))
348  {
349  TEST_ASSERT((eval_out-eval_ref).norm()<3*eps);
350  }
351  else
352  {
353  TEST_ASSERT(curv_out==curv_ref);
354  }
355  }
356 
358  {
359  typedef eli::geom::curve::bezier<data__, 2> bezier_curve_type;
360  data_type eps(std::numeric_limits<data__>::epsilon());
361  control_point_type cntrl_in[5];
362  typename bezier_curve_type::control_point_type bez_cntrl[5];
363  curve_type ebc;
364  bezier_curve_type bc;
365  typename curve_type::point_type eval_out, eval_ref;
366  typename curve_type::data_type t, curv_out, curv_ref;
367 
368  // set control points and create curves
369  cntrl_in[0] << 2.0;
370  cntrl_in[1] << 1.5;
371  cntrl_in[2] << 0.0;
372  cntrl_in[3] << 1.0;
373  cntrl_in[4] << 0.5;
374  bez_cntrl[0] << 0, 2;
375  bez_cntrl[1] << 0.25, 1.5;
376  bez_cntrl[2] << 0.5, 0;
377  bez_cntrl[3] << 0.75, 1;
378  bez_cntrl[4] << 1, 0.5;
379 
380  ebc.resize(4);
381  bc.resize(4);
382  for (index_type i=0; i<5; ++i)
383  {
384  ebc.set_control_point(cntrl_in[i], i);
385  bc.set_control_point(bez_cntrl[i], i);
386  }
387 
388  ebc.degree_promote();
389  bc.degree_promote();
390 
391  // test to see if degree has increased
392  TEST_ASSERT(ebc.degree()==bc.degree());
393 
394  // test evaluation at end points
395  t=0;
396  eval_out=ebc.f(t);
397  eval_ref=bc.f(t);
398  TEST_ASSERT(eval_out==eval_ref);
399  t=1;
400  eval_out=ebc.f(t);
401  eval_ref=bc.f(t);
402  if (typeid(data_type)==typeid(double))
403  {
404  TEST_ASSERT((eval_out-eval_ref).norm()<5*eps);
405  }
406  else
407  {
408  TEST_ASSERT(eval_out==eval_ref);
409  }
410 
411  // test evaluation at interior point
412  t=static_cast<data__>(0.45);
413  eval_out=ebc.f(t);
414  eval_ref=bc.f(t);
415  TEST_ASSERT((eval_out-eval_ref).norm()<2.1*eps);
416 
417  // test 1st derivative at end points
418  t=0;
419  eval_out=ebc.fp(t);
420  eval_ref=bc.fp(t);
421  TEST_ASSERT(eval_out==eval_ref);
422  t=1;
423  eval_out=ebc.fp(t);
424  eval_ref=bc.fp(t);
425  TEST_ASSERT((eval_out-eval_ref).norm()<25*eps);
426 
427  // test 1st derivative at interior point
428  t=static_cast<data__>(0.45);
429  eval_out=ebc.fp(t);
430  eval_ref=bc.fp(t);
431  TEST_ASSERT((eval_out-eval_ref).norm()<4.1*eps);
432 
433  // test 2nd derivative at end points
434  t=0;
435  eval_out=ebc.fpp(t);
436  eval_ref=bc.fpp(t);
437  TEST_ASSERT(eval_out==eval_ref);
438  t=1;
439  eval_out=ebc.fpp(t);
440  eval_ref=bc.fpp(t);
441  TEST_ASSERT((eval_out-eval_ref).norm()<11*eps);
442 
443  // test 2nd derivative at interior point
444  t=static_cast<data__>(0.45);
445  eval_out=ebc.fpp(t);
446  eval_ref=bc.fpp(t);
447  TEST_ASSERT((eval_out-eval_ref).norm()<17*eps);
448 
449  // test 3rd derivative at end points
450  t=0;
451  eval_out=ebc.fppp(t);
452  eval_ref=bc.fppp(t);
453  TEST_ASSERT((eval_out-eval_ref).norm()<132*eps);
454  t=1;
455  eval_out=ebc.fppp(t);
456  eval_ref=bc.fppp(t);
457  TEST_ASSERT((eval_out-eval_ref).norm()<151*eps);
458 
459  // test 3rd derivative at interior point
460  t=static_cast<data__>(0.45);
461  eval_out=ebc.fppp(t);
462  eval_ref=bc.fppp(t);
463  TEST_ASSERT((eval_out-eval_ref).norm()<65*eps);
464 
465  // test curvature at end points
466  t=0;
467  eli::geom::curve::curvature(curv_out, ebc, t);
468  eli::geom::curve::curvature(curv_ref, bc, t);
469  TEST_ASSERT(curv_out==curv_ref);
470  t=1;
471  eli::geom::curve::curvature(curv_out, ebc, t);
472  eli::geom::curve::curvature(curv_ref, bc, t);
473  TEST_ASSERT(std::abs(curv_out-curv_ref)<48*eps);
474 
475  // test curvature at interior point
476  t=static_cast<data__>(0.45);
477  eli::geom::curve::curvature(curv_out, ebc, t);
478  eli::geom::curve::curvature(curv_ref, bc, t);
479  TEST_ASSERT(std::abs(curv_out-curv_ref)<10*eps);
480  }
481 
483  {
484  // no constraint
485  {
486  typedef eli::geom::curve::bezier<data__, 2> bezier_curve_type;
487  control_point_type cntrl_in[9];
488  typename bezier_curve_type::control_point_type bez_cntrl[9];
489  curve_type ebc;
490  bezier_curve_type bc;
491 
492  // set control points and create curves
493  cntrl_in[0] << 2.0;
494  cntrl_in[1] << 1.5;
495  cntrl_in[2] << 1.0;
496  cntrl_in[3] << 0.5;
497  cntrl_in[4] << 0.0;
498  cntrl_in[5] << -0.5;
499  cntrl_in[6] << -1.0;
500  cntrl_in[7] << 1.0;
501  cntrl_in[8] << 0.5;
502  bez_cntrl[0] << static_cast<data__>(0), 2.0;
503  bez_cntrl[1] << static_cast<data__>(0.125), 1.5;
504  bez_cntrl[2] << static_cast<data__>(0.25), 1.0;
505  bez_cntrl[3] << static_cast<data__>(0.375), 0.5;
506  bez_cntrl[4] << static_cast<data__>(0.5), 0.0;
507  bez_cntrl[5] << static_cast<data__>(0.625),-0.5;
508  bez_cntrl[6] << static_cast<data__>(0.75), -1.0;
509  bez_cntrl[7] << static_cast<data__>(0.875), 1.0;
510  bez_cntrl[8] << static_cast<data__>(1), 0.5;
511 
512  ebc.resize(8);
513  bc.resize(8);
514  for (index_type i=0; i<9; ++i)
515  {
516  ebc.set_control_point(cntrl_in[i], i);
517  bc.set_control_point(bez_cntrl[i], i);
518  }
519 
521  bc.degree_demote(eli::geom::general::NOT_CONNECTED);
522  for(index_type i=0; i<8; ++i)
523  {
524  if (typeid(data__)==typeid(float))
525  {
526  TEST_ASSERT((ebc.get_control_point(i).col(0)-bc.get_control_point(i).col(1)).norm()<36*std::numeric_limits<data__>::epsilon());
527  }
528  else
529  {
530  TEST_ASSERT(ebc.get_control_point(i).col(0)==bc.get_control_point(i).col(1));
531  }
532  }
533  }
534 
535  // C0 constraint
536  {
537  typedef eli::geom::curve::bezier<data__, 2> bezier_curve_type;
538  control_point_type cntrl_in[9];
539  typename bezier_curve_type::control_point_type bez_cntrl[9];
540  curve_type ebc;
541  bezier_curve_type bc;
542 
543  // set control points and create curves
544  cntrl_in[0] << 2.0;
545  cntrl_in[1] << 1.5;
546  cntrl_in[2] << 1.0;
547  cntrl_in[3] << 0.5;
548  cntrl_in[4] << 0.0;
549  cntrl_in[5] << -0.5;
550  cntrl_in[6] << -1.0;
551  cntrl_in[7] << 1.0;
552  cntrl_in[8] << 0.5;
553  bez_cntrl[0] << static_cast<data__>(0), 2.0;
554  bez_cntrl[1] << static_cast<data__>(0.125), 1.5;
555  bez_cntrl[2] << static_cast<data__>(0.25), 1.0;
556  bez_cntrl[3] << static_cast<data__>(0.375), 0.5;
557  bez_cntrl[4] << static_cast<data__>(0.5), 0.0;
558  bez_cntrl[5] << static_cast<data__>(0.625),-0.5;
559  bez_cntrl[6] << static_cast<data__>(0.75), -1.0;
560  bez_cntrl[7] << static_cast<data__>(0.875), 1.0;
561  bez_cntrl[8] << static_cast<data__>(1), 0.5;
562 
563  ebc.resize(8);
564  bc.resize(8);
565  for (index_type i=0; i<9; ++i)
566  {
567  ebc.set_control_point(cntrl_in[i], i);
568  bc.set_control_point(bez_cntrl[i], i);
569  }
570 
572  bc.degree_demote(eli::geom::general::C0);
573  for(index_type i=0; i<8; ++i)
574  {
575  TEST_ASSERT(ebc.get_control_point(i).col(0)==bc.get_control_point(i).col(1));
576  }
577  }
578 
579  // C1 constraint
580  {
581  typedef eli::geom::curve::bezier<data__, 2> bezier_curve_type;
582  control_point_type cntrl_in[9];
583  typename bezier_curve_type::control_point_type bez_cntrl[9];
584  curve_type ebc;
585  bezier_curve_type bc;
586 
587  // set control points and create curves
588  cntrl_in[0] << 2.0;
589  cntrl_in[1] << 1.5;
590  cntrl_in[2] << 1.0;
591  cntrl_in[3] << 0.5;
592  cntrl_in[4] << 0.0;
593  cntrl_in[5] << -0.5;
594  cntrl_in[6] << -1.0;
595  cntrl_in[7] << 1.0;
596  cntrl_in[8] << 0.5;
597  bez_cntrl[0] << static_cast<data__>(0), 2.0;
598  bez_cntrl[1] << static_cast<data__>(0.125), 1.5;
599  bez_cntrl[2] << static_cast<data__>(0.25), 1.0;
600  bez_cntrl[3] << static_cast<data__>(0.375), 0.5;
601  bez_cntrl[4] << static_cast<data__>(0.5), 0.0;
602  bez_cntrl[5] << static_cast<data__>(0.625),-0.5;
603  bez_cntrl[6] << static_cast<data__>(0.75), -1.0;
604  bez_cntrl[7] << static_cast<data__>(0.875), 1.0;
605  bez_cntrl[8] << static_cast<data__>(1), 0.5;
606 
607  ebc.resize(8);
608  bc.resize(8);
609  for (index_type i=0; i<9; ++i)
610  {
611  ebc.set_control_point(cntrl_in[i], i);
612  bc.set_control_point(bez_cntrl[i], i);
613  }
614 
616  bc.degree_demote(eli::geom::general::C1);
617  for(index_type i=0; i<8; ++i)
618  {
619  TEST_ASSERT(ebc.get_control_point(i).col(0)==bc.get_control_point(i).col(1));
620  }
621  }
622 
623  // C2 constraint
624  {
625  typedef eli::geom::curve::bezier<data__, 2> bezier_curve_type;
626  control_point_type cntrl_in[9];
627  typename bezier_curve_type::control_point_type bez_cntrl[9];
628  curve_type ebc;
629  bezier_curve_type bc;
630 
631  // set control points and create curves
632  cntrl_in[0] << 2.0;
633  cntrl_in[1] << 1.5;
634  cntrl_in[2] << 1.0;
635  cntrl_in[3] << 0.5;
636  cntrl_in[4] << 0.0;
637  cntrl_in[5] << -0.5;
638  cntrl_in[6] << -1.0;
639  cntrl_in[7] << 1.0;
640  cntrl_in[8] << 0.5;
641  bez_cntrl[0] << static_cast<data__>(0), 2.0;
642  bez_cntrl[1] << static_cast<data__>(0.125), 1.5;
643  bez_cntrl[2] << static_cast<data__>(0.25), 1.0;
644  bez_cntrl[3] << static_cast<data__>(0.375), 0.5;
645  bez_cntrl[4] << static_cast<data__>(0.5), 0.0;
646  bez_cntrl[5] << static_cast<data__>(0.625),-0.5;
647  bez_cntrl[6] << static_cast<data__>(0.75), -1.0;
648  bez_cntrl[7] << static_cast<data__>(0.875), 1.0;
649  bez_cntrl[8] << static_cast<data__>(1), 0.5;
650 
651  ebc.resize(8);
652  bc.resize(8);
653  for (index_type i=0; i<9; ++i)
654  {
655  ebc.set_control_point(cntrl_in[i], i);
656  bc.set_control_point(bez_cntrl[i], i);
657  }
658 
660  bc.degree_demote(eli::geom::general::C2);
661  for(index_type i=0; i<8; ++i)
662  {
663  TEST_ASSERT(ebc.get_control_point(i).col(0)==bc.get_control_point(i).col(1));
664  }
665  }
666  }
667 
668  void length_test()
669  {
670  data_type eps(std::numeric_limits<data__>::epsilon());
671  typedef eli::geom::curve::bezier<data__, 2> bezier_curve_type;
672  control_point_type cntrl_in[5];
673  typename bezier_curve_type::control_point_type bez_cntrl[5];
674  curve_type ebc;
675  bezier_curve_type bc;
676  typename curve_type::point_type eval_out, eval_ref;
677  typename curve_type::data_type length_cal, length_ref;
678 
679  // set control points and create curves
680  cntrl_in[0] << 2.0;
681  cntrl_in[1] << 1.5;
682  cntrl_in[2] << 0.0;
683  cntrl_in[3] << 1.0;
684  cntrl_in[4] << 0.5;
685  bez_cntrl[0] << 0, 2;
686  bez_cntrl[1] << 0.25, 1.5;
687  bez_cntrl[2] << 0.5, 0;
688  bez_cntrl[3] << 0.75, 1;
689  bez_cntrl[4] << 1, 0.5;
690 
691  ebc.resize(4);
692  bc.resize(4);
693  for (index_type i=0; i<5; ++i)
694  {
695  ebc.set_control_point(cntrl_in[i], i);
696  bc.set_control_point(bez_cntrl[i], i);
697  }
698 
699  // calculate the length of curve
700  data_type tol(std::sqrt(eps));
701  length(length_cal, ebc, tol);
702  length(length_ref, bc, tol);
703  TEST_ASSERT(length_cal==length_ref);
704 
705  // test computing some segment length
706  typename curve_type::data_type t0, t1;
707  t0 = static_cast<data__>(0.2);
708  t1 = static_cast<data__>(0.7);
709 
710  length(length_cal, ebc, t0, t1, tol);
711  length(length_ref, bc, t0, t1, tol);
712  TEST_ASSERT(length_cal==length_ref);
713  }
714 };
715 #endif
716 
Definition: continuity.hpp:26
point_type f(const data_type &t) const
Definition: explicit_bezier.hpp:100
Definition: continuity.hpp:28
curve_type::index_type index_type
Definition: explicit_bezier.hpp:42
curve_type::control_point_type control_point_type
Definition: explicit_bezier_curve_test_suite.hpp:35
curve_type::data_type data_type
Definition: explicit_bezier.hpp:39
void assignment_test()
Definition: explicit_bezier_curve_test_suite.hpp:127
point_type fpp(const data_type &t) const
Definition: explicit_bezier.hpp:114
void promotion_test()
Definition: explicit_bezier_curve_test_suite.hpp:357
Definition: explicit_bezier.hpp:32
void AddTests(const float &)
Definition: explicit_bezier_curve_test_suite.hpp:41
Definition: explicit_bezier_curve_test_suite.hpp:31
Definition: math.hpp:25
void reverse()
Definition: explicit_bezier.hpp:95
void demotion_test()
Definition: explicit_bezier_curve_test_suite.hpp:482
Definition: continuity.hpp:27
void degree_promote()
Definition: explicit_bezier.hpp:144
bool degree_demote(const geom::general::continuity &continuity_degree=geom::general::C0)
Definition: explicit_bezier.hpp:149
~explicit_bezier_curve_test_suite()
Definition: explicit_bezier_curve_test_suite.hpp:80
void derivative_test()
Definition: explicit_bezier_curve_test_suite.hpp:239
void AddTests(const double &)
Definition: explicit_bezier_curve_test_suite.hpp:52
void length_test()
Definition: explicit_bezier_curve_test_suite.hpp:668
eli::geom::curve::explicit_bezier< data__ > curve_type
Definition: explicit_bezier_curve_test_suite.hpp:34
curve_type::point_type point_type
Definition: explicit_bezier_curve_test_suite.hpp:36
void reverse_test()
Definition: explicit_bezier_curve_test_suite.hpp:166
curve_type::index_type index_type
Definition: explicit_bezier_curve_test_suite.hpp:38
void resize(const index_type &t_dim)
Definition: explicit_bezier.hpp:66
void curvature(typename curve__::data_type &rho, const curve__ &c, const typename curve__::data_type &t)
Definition: curvature.hpp:25
curve_type::point_type control_point_type
Definition: explicit_bezier.hpp:41
void evaluation_test()
Definition: explicit_bezier_curve_test_suite.hpp:190
void length(typename piecewise< curve__, data__, dim__, tol__ >::data_type &len, const piecewise< curve__, data__, dim__, tol__ > &pc, const typename piecewise< curve__, data__, dim__, tol__ >::data_type &tol)
Definition: length.hpp:43
void AddTests(const long double &)
Definition: explicit_bezier_curve_test_suite.hpp:63
explicit_bezier_curve_test_suite()
Definition: explicit_bezier_curve_test_suite.hpp:76
index_type degree() const
Definition: explicit_bezier.hpp:80
control_point_type get_control_point(const index_type &i) const
Definition: explicit_bezier.hpp:90
void octave_print(int figno, const std::vector< point_type, Eigen::aligned_allocator< point_type > > &pts, const curve_type &bez) const
Definition: explicit_bezier_curve_test_suite.hpp:85
point_type fppp(const data_type &t) const
Definition: explicit_bezier.hpp:121
point_type fp(const data_type &t) const
Definition: explicit_bezier.hpp:107
Eigen::Matrix< data_type, 1, 2 > point_type
Definition: explicit_bezier.hpp:40
void set_control_point(const control_point_type &cp_in, const index_type &i)
Definition: explicit_bezier.hpp:85
void create_circle(std::vector< point_type, Eigen::aligned_allocator< point_type > > &pts)
Definition: explicit_bezier_curve_test_suite.hpp:115
Definition: bezier.hpp:109
curve_type::data_type data_type
Definition: explicit_bezier_curve_test_suite.hpp:37
Definition: continuity.hpp:29