38 #include <visp3/core/vpConfig.h>
39 #include <visp3/core/vpImageCircle.h>
40 #include <visp3/core/vpMath.h>
41 #include <visp3/core/vpRect.h>
43 bool equal(
const float &actualVal,
const float &theoreticalVal)
46 return (std::abs(theoreticalVal - actualVal) < 1.f);
51 #ifdef ENABLE_VISP_NAMESPACE
54 const float OFFSET = 5.f;
55 const float WIDTH = 640.f;
56 const float HEIGHT = 480.f;
57 const float RADIUS = std::min<float>(WIDTH, HEIGHT) / 10.f;
58 vpRect roi(OFFSET, OFFSET, WIDTH, HEIGHT);
59 const float WIDTH_SWITCHED = HEIGHT;
60 const float HEIGHT_SWITCHED = WIDTH;
61 vpRect switchedRoI(OFFSET, OFFSET, WIDTH_SWITCHED, HEIGHT_SWITCHED);
62 bool hasSucceeded =
true;
67 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
68 float theoreticalValue = 2.f * M_PI_FLOAT * RADIUS;
69 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
70 std::string statusTest;
72 statusTest =
"SUCCESS";
75 statusTest =
"FAILED";
77 std::cout <<
"Test no intersection." << std::endl;
78 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
79 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
80 std::cout <<
"\ttest status = " << statusTest << std::endl;
82 hasSucceeded &= isValueOK;
87 vpRect roiSquare(OFFSET, OFFSET, HEIGHT, HEIGHT);
89 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
90 float theoreticalValue = 2.f * M_PI_FLOAT * HEIGHT / 2.f;
91 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
92 std::string statusTest;
94 statusTest =
"SUCCESS";
97 statusTest =
"FAILED";
99 std::cout <<
"Test circle touching borders of the RoI." << std::endl;
100 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
101 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
102 std::cout <<
"\ttest status = " << statusTest << std::endl;
104 hasSucceeded &= isValueOK;
111 float uc = OFFSET + 24.f;
112 float vc = OFFSET + 100.f;
114 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
115 float theoreticalValue = 4.f * M_PI_FLOAT * RADIUS /3.f;
116 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
117 std::string statusTest;
119 statusTest =
"SUCCESS";
122 statusTest =
"FAILED";
124 std::cout <<
"Test intersection left border, more than half a circle visible." << std::endl;
125 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
126 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
127 std::cout <<
"\ttest status = " << statusTest << std::endl;
129 hasSucceeded &= isValueOK;
136 float uc = OFFSET - 24.f;
137 float vc = OFFSET + 100.f;
139 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
140 float theoreticalValue = 2.f * M_PI_FLOAT * RADIUS /3.f;
141 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
142 std::string statusTest;
144 statusTest =
"SUCCESS";
147 statusTest =
"FAILED";
149 std::cout <<
"Test intersection left border, less than half a circle visible." << std::endl;
150 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
151 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
152 std::cout <<
"\ttest status = " << statusTest << std::endl;
154 hasSucceeded &= isValueOK;
161 float uc = OFFSET + RADIUS;
162 float vc = OFFSET + 100.f;
164 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
165 float theoreticalValue = 2.f * M_PI_FLOAT * RADIUS;
166 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
167 std::string statusTest;
169 statusTest =
"SUCCESS";
172 statusTest =
"FAILED";
174 std::cout <<
"Test with circle touching the left border, all the circle is visible." << std::endl;
175 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
176 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
177 std::cout <<
"\ttest status = " << statusTest << std::endl;
179 hasSucceeded &= isValueOK;
186 float uc = OFFSET - RADIUS;
187 float vc = OFFSET - 100.f;
189 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
190 float theoreticalValue = 0.f;
191 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
192 std::string statusTest;
194 statusTest =
"SUCCESS";
197 statusTest =
"FAILED";
199 std::cout <<
"Test with circle touching the left border, all the circle is hidden." << std::endl;
200 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
201 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
202 std::cout <<
"\ttest status = " << statusTest << std::endl;
204 hasSucceeded &= isValueOK;
211 float uc = OFFSET + 616.f;
212 float vc = OFFSET + 100.f;
214 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
215 float theoreticalValue = 4.f * M_PI_FLOAT * RADIUS /3.f;
216 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
217 std::string statusTest;
219 statusTest =
"SUCCESS";
222 statusTest =
"FAILED";
224 std::cout <<
"Test intersection right border, more than half a circle visible." << std::endl;
225 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
226 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
227 std::cout <<
"\ttest status = " << statusTest << std::endl;
229 hasSucceeded &= isValueOK;
236 float uc = OFFSET + 664.f;
237 float vc = OFFSET + 100.f;
239 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
240 float theoreticalValue = 2.f * M_PI_FLOAT * RADIUS /3.f;
241 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
242 std::string statusTest;
244 statusTest =
"SUCCESS";
247 statusTest =
"FAILED";
249 std::cout <<
"Test intersection right border, less than half a circle visible." << std::endl;
250 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
251 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
252 std::cout <<
"\ttest status = " << statusTest << std::endl;
254 hasSucceeded &= isValueOK;
261 float uc = OFFSET + WIDTH - RADIUS;
262 float vc = OFFSET + 100.f;
264 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
265 float theoreticalValue = 2.f * M_PI_FLOAT * RADIUS;
266 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
267 std::string statusTest;
269 statusTest =
"SUCCESS";
272 statusTest =
"FAILED";
274 std::cout <<
"Test with circle touching the right border, all the circle is visible." << std::endl;
275 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
276 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
277 std::cout <<
"\ttest status = " << statusTest << std::endl;
279 hasSucceeded &= isValueOK;
286 float uc = OFFSET + WIDTH + RADIUS;
287 float vc = OFFSET + 100.f;
289 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
290 float theoreticalValue = 0.f;
291 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
292 std::string statusTest;
294 statusTest =
"SUCCESS";
297 statusTest =
"FAILED";
299 std::cout <<
"Test with circle touching the right border, all the circle is hidden." << std::endl;
300 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
301 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
302 std::cout <<
"\ttest status = " << statusTest << std::endl;
304 hasSucceeded &= isValueOK;
311 float theta = M_PI_FLOAT / 3.f;
312 float uc = OFFSET + 100.f;
313 float vc = OFFSET + RADIUS * sin(theta);
315 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
316 float theoreticalValue = 5.f * M_PI_FLOAT * RADIUS /3.f;
317 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
318 std::string statusTest;
320 statusTest =
"SUCCESS";
323 statusTest =
"FAILED";
325 std::cout <<
"Test intersection top border, more than half a circle visible." << std::endl;
326 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
327 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
328 std::cout <<
"\ttest status = " << statusTest << std::endl;
330 hasSucceeded &= isValueOK;
337 float theta = -2.f * M_PI_FLOAT/3.f;
338 float uc = OFFSET + 100.f;
339 float vc = OFFSET + RADIUS * std::sin(theta);
341 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
342 float theoreticalValue = M_PI_FLOAT * RADIUS /3.f;
343 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
344 std::string statusTest;
346 statusTest =
"SUCCESS";
349 statusTest =
"FAILED";
351 std::cout <<
"Test intersection top border, less than half a circle visible." << std::endl;
352 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
353 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
354 std::cout <<
"\ttest status = " << statusTest << std::endl;
356 hasSucceeded &= isValueOK;
363 float theta = M_PI_2_FLOAT;
364 float uc = OFFSET + 100.f;
365 float vc = OFFSET + RADIUS * sin(theta);
367 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
368 float theoreticalValue = 2.f * M_PI_FLOAT * RADIUS;
369 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
370 std::string statusTest;
372 statusTest =
"SUCCESS";
375 statusTest =
"FAILED";
377 std::cout <<
"Test with circle touching the top border, all the circle is visible." << std::endl;
378 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
379 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
380 std::cout <<
"\ttest status = " << statusTest << std::endl;
382 hasSucceeded &= isValueOK;
389 float theta = -M_PI_2_FLOAT;
390 float uc = OFFSET + 100.f;
391 float vc = OFFSET + RADIUS * sin(theta);
393 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
394 float theoreticalValue = 0.f;
395 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
396 std::string statusTest;
398 statusTest =
"SUCCESS";
401 statusTest =
"FAILED";
403 std::cout <<
"Test with circle touching the top border, all the circle is hidden." << std::endl;
404 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
405 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
406 std::cout <<
"\ttest status = " << statusTest << std::endl;
408 hasSucceeded &= isValueOK;
415 float theta = -M_PI_FLOAT / 3.f;
416 float uc = OFFSET + 100.f;
417 float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta);
419 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
420 float theoreticalValue = 5.f * M_PI_FLOAT * RADIUS /3.f;
421 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
422 std::string statusTest;
424 statusTest =
"SUCCESS";
427 statusTest =
"FAILED";
429 std::cout <<
"Test intersection bottom border, more than half a circle visible." << std::endl;
430 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
431 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
432 std::cout <<
"\ttest status = " << statusTest << std::endl;
434 hasSucceeded &= isValueOK;
441 float theta = M_PI_FLOAT / 3.f;
442 float uc = OFFSET + 100.f;
443 float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta);
445 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
446 float theoreticalValue = M_PI_FLOAT * RADIUS /3.f;
447 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
448 std::string statusTest;
450 statusTest =
"SUCCESS";
453 statusTest =
"FAILED";
455 std::cout <<
"Test intersection bottom border, less than half a circle visible." << std::endl;
456 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
457 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
458 std::cout <<
"\ttest status = " << statusTest << std::endl;
460 hasSucceeded &= isValueOK;
466 float uc = OFFSET + 100.f;
467 float vc = OFFSET + HEIGHT - RADIUS;
469 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
470 float theoreticalValue = 2.f * M_PI_FLOAT * RADIUS;
471 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
472 std::string statusTest;
474 statusTest =
"SUCCESS";
477 statusTest =
"FAILED";
479 std::cout <<
"Test with circle touching the bottom border, all the circle is visible." << std::endl;
480 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
481 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
482 std::cout <<
"\ttest status = " << statusTest << std::endl;
484 hasSucceeded &= isValueOK;
490 float uc = OFFSET + 100.f;
491 float vc = OFFSET + HEIGHT + RADIUS;
493 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
494 float theoreticalValue = 0.f;
495 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
496 std::string statusTest;
498 statusTest =
"SUCCESS";
501 statusTest =
"FAILED";
503 std::cout <<
"Test with circle touching the bottom border, all the circle is hidden." << std::endl;
504 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
505 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
506 std::cout <<
"\ttest status = " << statusTest << std::endl;
508 hasSucceeded &= isValueOK;
520 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
521 float theoreticalValue = M_PI_2_FLOAT * RADIUS;
522 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
523 std::string statusTest;
525 statusTest =
"SUCCESS";
528 statusTest =
"FAILED";
530 std::cout <<
"Test with intersections with the top and the left border, crossing each axis once in the RoI." << std::endl;
531 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
532 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
533 std::cout <<
"\ttest status = " << statusTest << std::endl;
535 hasSucceeded &= isValueOK;
547 float theta_v_min = M_PI_FLOAT / 4.f;
548 float uc = OFFSET - RADIUS * std::cos(theta_v_min);
549 float vc = OFFSET + RADIUS * std::sin(theta_v_min) + 1.f;
550 vc = std::max<float>(vc, OFFSET + RADIUS * std::sin(-theta_v_min) + 1.f);
552 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
553 float theoreticalValue = M_PI_2_FLOAT * RADIUS;
554 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
555 std::string statusTest;
557 statusTest =
"SUCCESS";
560 statusTest =
"FAILED";
562 std::cout <<
"Test with intersections with the top and the left border but crossing only the left axis in the RoI." << std::endl;
563 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
564 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
565 std::cout <<
"\ttest status = " << statusTest << std::endl;
567 hasSucceeded &= isValueOK;
581 float theta_u_top_min = -1.1f * M_PI_2_FLOAT;
582 float uc = OFFSET - RADIUS * std::cos(theta_u_top_min) + 1.f;
583 uc = std::max<float>(uc, OFFSET - RADIUS * std::cos(M_PI_FLOAT - theta_u_top_min) + 1.f);
584 float vc = OFFSET + RADIUS * std::sin(theta_u_top_min);
586 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
587 float theoreticalValue = 0.2f * M_PI_2_FLOAT * RADIUS;
588 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
589 std::string statusTest;
591 statusTest =
"SUCCESS";
594 statusTest =
"FAILED";
596 std::cout <<
"Test with intersections with the top and the left border but crossing only the top axis in the RoI." << std::endl;
597 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
598 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
599 std::cout <<
"\ttest status = " << statusTest << std::endl;
601 hasSucceeded &= isValueOK;
617 float theta_u_top_min = 5.f * M_PI_FLOAT / 8.f;
618 float theta_u_top_max = M_PI_FLOAT - theta_u_top_min;
619 float uc = OFFSET - RADIUS * std::cos(theta_u_top_min) + 1.f;
620 uc = std::max<float>(uc, OFFSET - RADIUS * std::cos(M_PI_FLOAT - theta_u_top_min) + 1.f);
621 float vc = OFFSET + RADIUS * std::sin(theta_u_top_min);
622 float theta_v_min = std::acos((OFFSET - uc)/RADIUS);
624 float theta_v_max = -theta_v_min;
625 if (theta_v_max < 0) {
626 float temp = theta_v_max;
627 theta_v_max = theta_v_min;
631 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
632 float theoreticalValue = ((theta_v_max - theta_u_top_min) + (theta_u_top_max - theta_v_min)) * RADIUS;
633 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
634 std::string statusTest;
636 statusTest =
"SUCCESS";
639 statusTest =
"FAILED";
641 std::cout <<
"Test with intersections with the top and the left border crossing twice each axis ." << std::endl;
642 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
643 std::cout <<
"\ttheoretical length = " << theoreticalValue << std::endl;
644 std::cout <<
"\ttest status = " << statusTest << std::endl;
646 hasSucceeded &= isValueOK;
660 float theta_u_top_min = 2.f * M_PI_FLOAT / 3.f;
661 float theta_v_max = -M_PI_2_FLOAT;
662 float uc = OFFSET + WIDTH - RADIUS * std::cos(theta_v_max);
663 float vc = OFFSET + RADIUS * std::sin(theta_u_top_min);;
665 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
666 float theoreticalValue = (M_PI_2_FLOAT + M_PI_FLOAT / 3.f) * RADIUS;
667 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
668 std::string statusTest;
670 statusTest =
"SUCCESS";
673 statusTest =
"FAILED";
675 std::cout <<
"Test with intersections with the top and the right border, crossing each axis once in the RoI." << std::endl;
676 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
677 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
678 std::cout <<
"\ttest status = " << statusTest << std::endl;
680 hasSucceeded &= isValueOK;
695 float theta_v_max = -7.f * M_PI_FLOAT / 8.f;
696 float theta_v_min = -theta_v_max;
697 float uc = OFFSET + WIDTH - RADIUS * std::cos(theta_v_max);
698 float vc = RADIUS * std::sin(std::acos((OFFSET + WIDTH - uc)/RADIUS)) + OFFSET + 1.f;
700 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
701 float theoreticalValue = (2.f * M_PI_FLOAT - (theta_v_min - theta_v_max)) * RADIUS;
702 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
703 std::string statusTest;
705 statusTest =
"SUCCESS";
708 statusTest =
"FAILED";
710 std::cout <<
"Test with intersections with the top and the right border, but crossing only the right border in the RoI." << std::endl;
711 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
712 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
713 std::cout <<
"\ttest status = " << statusTest << std::endl;
715 hasSucceeded &= isValueOK;
730 float theta_u_top_min = -0.9f * M_PI_2_FLOAT;
731 float theta_u_top_max = M_PI_FLOAT - theta_u_top_min;
733 float vc = OFFSET + RADIUS * std::sin(theta_u_top_min);
734 float theta_v_min = std::asin((vc - OFFSET)/RADIUS) + 1.f;
735 float uc = OFFSET + WIDTH - RADIUS * std::cos(theta_v_min);
737 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
738 float theoreticalValue = std::abs(theta_u_top_min - theta_u_top_max) * RADIUS;
739 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
740 std::string statusTest;
742 statusTest =
"SUCCESS";
745 statusTest =
"FAILED";
747 std::cout <<
"Test with intersections with the top and the right border, but crossing only the top border in the RoI." << std::endl;
748 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
749 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
750 std::cout <<
"\ttest status = " << statusTest << std::endl;
752 hasSucceeded &= isValueOK;
768 float theta_u_top_min = 5.f * M_PI_FLOAT / 8.f;
769 float theta_u_top_max = M_PI_FLOAT - theta_u_top_min;
770 float uc = OFFSET + WIDTH - RADIUS * std::cos(theta_u_top_min) - 1.f;
771 uc = std::min<float>(uc, OFFSET + WIDTH - RADIUS * std::cos(M_PI_FLOAT - theta_u_top_min) - 1.f);
772 float vc = OFFSET + RADIUS * std::sin(theta_u_top_min);
773 float theta_v_min = std::acos((OFFSET + WIDTH - uc)/RADIUS);
775 float theta_v_max = -theta_v_min;
776 if (theta_v_min < 0) {
777 float temp = theta_v_min;
778 theta_v_min = theta_v_max;
782 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
783 float theoreticalValue = (2.f * M_PI_FLOAT - ((theta_u_top_min - theta_u_top_max) + (theta_v_min - theta_v_max))) * RADIUS;
784 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
785 std::string statusTest;
787 statusTest =
"SUCCESS";
790 statusTest =
"FAILED";
792 std::cout <<
"Test with intersections with the top and the left border crossing twice each axis ." << std::endl;
793 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
794 std::cout <<
"\ttheoretical length = " << theoreticalValue << std::endl;
795 std::cout <<
"\ttest status = " << statusTest << std::endl;
797 hasSucceeded &= isValueOK;
811 float theta_v_min = M_PI_2_FLOAT;
812 float theta_u_bot_max = -M_PI_FLOAT / 3.f;
813 float uc = OFFSET - RADIUS * std::cos(theta_v_min);
814 float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta_u_bot_max);;
816 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
817 float theoreticalValue = (M_PI_2_FLOAT + M_PI_FLOAT / 3.f) * RADIUS;
818 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
819 std::string statusTest;
821 statusTest =
"SUCCESS";
824 statusTest =
"FAILED";
826 std::cout <<
"Test with intersections with the bottom and the left border, crossing each axis once in the RoI." << std::endl;
827 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
828 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
829 std::cout <<
"\ttest status = " << statusTest << std::endl;
831 hasSucceeded &= isValueOK;
847 float theta_v_min = M_PI_4_FLOAT / 2.f;
848 float theta_v_max = -theta_v_min;
849 float uc = OFFSET - RADIUS * std::cos(theta_v_min);
850 float vc = std::min<float>(OFFSET + HEIGHT + RADIUS * std::sin(theta_v_min) - 1.f, OFFSET + HEIGHT + RADIUS * std::sin(theta_v_max) - 1.f);
852 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
853 float theoreticalValue = (2.f * theta_v_min) * RADIUS;
854 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
855 std::string statusTest;
857 statusTest =
"SUCCESS";
860 statusTest =
"FAILED";
862 std::cout <<
"Test with intersections with the bottom and the left border, but crossing only the left border in the RoI." << std::endl;
863 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
864 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
865 std::cout <<
"\ttest status = " << statusTest << std::endl;
867 hasSucceeded &= isValueOK;
883 float theta_u_bot_min = 5.f * M_PI_4_FLOAT / 2.f;
884 float theta_u_bot_max = M_PI_FLOAT - theta_u_bot_min;
885 float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta_u_bot_min);
886 float uc = std::max<float>(OFFSET - RADIUS * std::cos(theta_u_bot_min) + 1.f, OFFSET - RADIUS * std::cos(theta_u_bot_max) + 1.f);
888 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
889 float theoreticalValue = (theta_u_bot_min - theta_u_bot_max) * RADIUS;
890 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
891 std::string statusTest;
893 statusTest =
"SUCCESS";
896 statusTest =
"FAILED";
898 std::cout <<
"Test with intersections with the bottom and the left border, but crossing only the bottom border in the RoI." << std::endl;
899 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
900 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
901 std::cout <<
"\ttest status = " << statusTest << std::endl;
903 hasSucceeded &= isValueOK;
919 float theta_u_bot_min = -5.f * M_PI_FLOAT / 8.f;
920 float theta_u_bot_max = M_PI_FLOAT - theta_u_bot_min;
922 float theta_v_min = 7.f * M_PI_FLOAT / 8.f;
923 float theta_v_max = -theta_v_min;
924 float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta_u_bot_min);
925 float uc = OFFSET - RADIUS * std::cos(theta_v_min);
927 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
928 float theoreticalValue = ((theta_v_min - theta_u_bot_max) + (theta_u_bot_min - theta_v_max)) * RADIUS;
929 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
930 std::string statusTest;
932 statusTest =
"SUCCESS";
935 statusTest =
"FAILED";
937 std::cout <<
"Test with intersections with the bottom and the left border, crossing each axis twice in the RoI." << std::endl;
938 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
939 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
940 std::cout <<
"\ttest status = " << statusTest << std::endl;
942 hasSucceeded &= isValueOK;
956 float theta_u_bot_min = -2.f * M_PI_FLOAT / 3.f;
957 float theta_v_min = M_PI_2_FLOAT;
958 float uc = OFFSET + WIDTH - RADIUS * std::cos(theta_v_min);
959 float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta_u_bot_min);;
961 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
962 float theoreticalValue = (M_PI_2_FLOAT + M_PI_FLOAT / 3.f) * RADIUS;
963 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
964 std::string statusTest;
966 statusTest =
"SUCCESS";
969 statusTest =
"FAILED";
971 std::cout <<
"Test with intersections with the bottom and the right border, crossing each axis once in the RoI." << std::endl;
972 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
973 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
974 std::cout <<
"\ttest status = " << statusTest << std::endl;
976 hasSucceeded &= isValueOK;
991 float theta_v_min = 5.f * M_PI_FLOAT / 6.f;
992 float uc = OFFSET + WIDTH - RADIUS * std::cos(theta_v_min);
993 float vc = std::min<float>(OFFSET + HEIGHT + RADIUS * std::sin(theta_v_min) - 1.f, OFFSET + HEIGHT + RADIUS * std::sin(-theta_v_min) - 1.f);
995 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
996 float theoreticalValue = (M_PI_FLOAT / 3.f) * RADIUS;
997 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
998 std::string statusTest;
1000 statusTest =
"SUCCESS";
1003 statusTest =
"FAILED";
1005 std::cout <<
"Test with intersections with the bottom and the right border, crossing only the right axis in the RoI in the RoI." << std::endl;
1006 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1007 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1008 std::cout <<
"\ttest status = " << statusTest << std::endl;
1010 hasSucceeded &= isValueOK;
1025 float theta_u_bot_min = 4.f * M_PI_FLOAT / 6.f;
1026 float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta_u_bot_min);
1027 float uc = std::min<float>(OFFSET + WIDTH - RADIUS * std::cos(theta_u_bot_min) - 1.f, OFFSET + WIDTH - RADIUS * std::cos(M_PI_FLOAT -theta_u_bot_min) - 1.f);
1029 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1030 float theoreticalValue = (M_PI_FLOAT / 3.f) * RADIUS;
1031 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1032 std::string statusTest;
1034 statusTest =
"SUCCESS";
1037 statusTest =
"FAILED";
1039 std::cout <<
"Test with intersections with the bottom and the right border, crossing only the bottom axis in the RoI in the RoI." << std::endl;
1040 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1041 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1042 std::cout <<
"\ttest status = " << statusTest << std::endl;
1044 hasSucceeded &= isValueOK;
1060 float theta_u_bot_min = -7.f * M_PI_FLOAT / 8.f;
1061 float theta_u_bot_max = M_PI_FLOAT - theta_u_bot_min;
1063 float theta_v_max = -3.f * M_PI_FLOAT / 8.f;
1064 float theta_v_min = -theta_v_max;
1065 float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta_u_bot_min);
1066 float uc = OFFSET - RADIUS * std::cos(theta_v_min);
1068 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1069 float theoreticalValue = (2.f * M_PI_FLOAT - ((theta_v_min - theta_v_max) + (theta_u_bot_max - theta_u_bot_min))) * RADIUS;
1070 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1071 std::string statusTest;
1073 statusTest =
"SUCCESS";
1076 statusTest =
"FAILED";
1078 std::cout <<
"Test with intersections with the bottom and the right border, crossing each axis twice in the RoI." << std::endl;
1079 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1080 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1081 std::cout <<
"\ttest status = " << statusTest << std::endl;
1083 hasSucceeded &= isValueOK;
1098 float theta_u_top_min = 5.f * M_PI_FLOAT / 8.f;
1099 float theta_u_top_max = 3.f * M_PI_FLOAT / 8.f;
1100 float theta_v_min = 7.f * M_PI_FLOAT / 8.f;
1101 float theta_v_max = -theta_v_min;
1102 float theta_u_bottom_min = -5.f * M_PI_FLOAT / 8.f;
1103 float theta_u_bottom_max = -3.f * M_PI_FLOAT / 8.f;
1104 float vc = OFFSET + HEIGHT / 2.f;
1105 float radius = -(OFFSET - vc)/ std::sin(theta_u_top_min);
1106 float uc = OFFSET - radius * std::cos(theta_v_min);
1108 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1109 float theoreticalValue = ((theta_v_min - theta_u_top_min) + (theta_u_top_max - theta_u_bottom_max) + (theta_u_bottom_min - theta_v_max)) * radius;
1110 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1111 std::string statusTest;
1113 statusTest =
"SUCCESS";
1116 statusTest =
"FAILED";
1118 std::cout <<
"Test with intersections with the top, bottom and the left border, crossing each axis twice in the RoI." << std::endl;
1119 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1120 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1121 std::cout <<
"\ttest status = " << statusTest << std::endl;
1123 hasSucceeded &= isValueOK;
1138 float theta_u_top_max = M_PI_FLOAT / 6.f;
1139 float theta_u_top_min = M_PI_FLOAT - theta_u_top_max;
1140 float theta_v_min = M_PI_FLOAT / 3.f;
1141 float theta_u_bottom_max = -theta_u_top_max;
1142 float radius = HEIGHT;
1143 float vc = OFFSET + radius * std::sin(theta_u_top_min);
1144 float uc = OFFSET - radius * std::cos(theta_v_min);
1146 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1147 float theoreticalValue = (theta_u_top_max - theta_u_bottom_max) * radius;
1148 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1149 std::string statusTest;
1151 statusTest =
"SUCCESS";
1154 statusTest =
"FAILED";
1156 std::cout <<
"Test with intersections with the top, bottom and the left border, crossing only the top and bottom axes in the RoI." << std::endl;
1157 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1158 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1159 std::cout <<
"\ttest status = " << statusTest << std::endl;
1161 hasSucceeded &= isValueOK;
1176 float theta_u_top_min = 4.f * M_PI_FLOAT / 6.f;
1177 float theta_u_top_max = M_PI_FLOAT - theta_u_top_min;
1178 float theta_v_min = M_PI_FLOAT;
1179 float theta_u_bottom_min = -theta_u_top_min;
1180 float theta_u_bottom_max = -theta_u_top_max;
1181 float radius = HEIGHT / (2.f * std::sin(theta_u_top_min));
1182 float vc = OFFSET + radius * std::sin(theta_u_top_min);
1183 float uc = OFFSET - radius * std::cos(theta_v_min);
1185 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1186 float theoreticalValue = (2.f * M_PI_FLOAT - ((theta_u_top_min - theta_u_top_max) + (theta_u_bottom_max - theta_u_bottom_min))) * radius;
1187 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1188 std::string statusTest;
1190 statusTest =
"SUCCESS";
1193 statusTest =
"FAILED";
1195 std::cout <<
"Test with intersections with the top, bottom and the left border, crossing the top and bottom axes and touching the left axis in the RoI." << std::endl;
1196 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1197 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1198 std::cout <<
"\ttest status = " << statusTest << std::endl;
1200 hasSucceeded &= isValueOK;
1215 float theta_u_top_min = M_PI_2_FLOAT;
1216 float theta_v_min = M_PI_4_FLOAT;
1217 float theta_v_max = -theta_v_min;
1218 float radius = HEIGHT / 2.f;
1219 float vc = OFFSET + radius * std::sin(theta_u_top_min);
1220 float uc = OFFSET - radius * std::cos(theta_v_min);
1222 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1223 float theoreticalValue = (theta_v_min - theta_v_max) * radius;
1224 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1225 std::string statusTest;
1227 statusTest =
"SUCCESS";
1230 statusTest =
"FAILED";
1232 std::cout <<
"Test with intersections with the top, bottom and the left border, crossing only the left axis in the RoI." << std::endl;
1233 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1234 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1235 std::cout <<
"\ttest status = " << statusTest << std::endl;
1237 hasSucceeded &= isValueOK;
1252 float theta_u_top_min = M_PI_2_FLOAT;
1253 float theta_v_min = 3.f * M_PI_4_FLOAT;
1254 float theta_v_max = -theta_v_min;
1255 float radius = HEIGHT / 2.f;
1256 float vc = OFFSET + radius * std::sin(theta_u_top_min);
1257 float uc = OFFSET - radius * std::cos(theta_v_min);
1259 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1260 float theoreticalValue = (theta_v_min - theta_v_max) * radius;
1261 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1262 std::string statusTest;
1264 statusTest =
"SUCCESS";
1267 statusTest =
"FAILED";
1269 std::cout <<
"Test with intersections with the top, bottom and the left border, crossing the left axis and touching the two others in the RoI." << std::endl;
1270 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1271 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1272 std::cout <<
"\ttest status = " << statusTest << std::endl;
1274 hasSucceeded &= isValueOK;
1289 float theta_u_top_max = 0.f;
1290 float theta_u_bot_max = -M_PI_FLOAT / 3.f;
1291 float theta_v_max = -M_PI_FLOAT / 6.f;
1292 float radius = HEIGHT / (std::sin(theta_u_top_max) - std::sin(theta_u_bot_max));
1293 float uc = OFFSET - radius * std::cos(theta_v_max);
1294 float vc = OFFSET + radius * std::sin(theta_u_top_max);
1296 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1297 float theoreticalValue = (theta_u_top_max - theta_v_max) * radius;
1298 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1299 std::string statusTest;
1301 statusTest =
"SUCCESS";
1304 statusTest =
"FAILED";
1306 std::cout <<
"Test with intersections with the top, bottom and the left border, crossing only the top and left axes once in the RoI." << std::endl;
1307 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1308 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1309 std::cout <<
"\ttest status = " << statusTest << std::endl;
1311 hasSucceeded &= isValueOK;
1326 float theta_u_top_max = M_PI_FLOAT / 3.f;
1327 float theta_u_bot_max = 0.f;
1328 float theta_v_min = M_PI_FLOAT / 6.f;
1329 float radius = HEIGHT / (std::sin(theta_u_top_max) - std::sin(theta_u_bot_max));
1330 float uc = OFFSET - radius * std::cos(theta_v_min);
1331 float vc = OFFSET + radius * std::sin(theta_u_top_max);
1333 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1334 float theoreticalValue = (theta_v_min - theta_u_bot_max) * radius;
1335 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1336 std::string statusTest;
1338 statusTest =
"SUCCESS";
1341 statusTest =
"FAILED";
1343 std::cout <<
"Test with intersections with the top, bottom and the left border, crossing the bottom and left axis once in the RoI." << std::endl;
1344 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1345 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1346 std::cout <<
"\ttest status = " << statusTest << std::endl;
1348 hasSucceeded &= isValueOK;
1363 float theta_u_top_min = 5.f * M_PI_FLOAT / 8.f;
1364 float theta_u_top_max = 3.f * M_PI_FLOAT / 8.f;
1365 float theta_v_min = 1.f * M_PI_FLOAT / 8.f;
1366 float theta_v_max = -theta_v_min;
1367 float theta_u_bottom_min = -5.f * M_PI_FLOAT / 8.f;
1368 float theta_u_bottom_max = -3.f * M_PI_FLOAT / 8.f;
1369 float vc = OFFSET + HEIGHT / 2.f;
1370 float radius = -(OFFSET - vc)/ std::sin(theta_u_top_min);
1371 float uc = OFFSET + WIDTH - radius * std::cos(theta_v_min);
1373 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1374 float theoreticalValue = (2.f * M_PI_FLOAT - ((theta_u_top_min - theta_u_top_max) + (theta_v_min - theta_v_max) + (theta_u_bottom_max - theta_u_bottom_min))) * radius;
1375 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1376 std::string statusTest;
1378 statusTest =
"SUCCESS";
1381 statusTest =
"FAILED";
1383 std::cout <<
"Test with intersections with the top, bottom and the right border, crossing each axis twice in the RoI." << std::endl;
1384 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1385 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1386 std::cout <<
"\ttest status = " << statusTest << std::endl;
1388 hasSucceeded &= isValueOK;
1403 float theta_u_top_min = 5.f * M_PI_FLOAT / 6.f;
1404 float theta_v_min = 2.f * M_PI_FLOAT / 3.f;
1405 float theta_u_bottom_min = -theta_u_top_min;
1406 float radius = HEIGHT;
1407 float vc = OFFSET + radius * std::sin(theta_u_top_min);
1408 float uc = OFFSET + WIDTH - radius * std::cos(theta_v_min);
1410 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1411 float theoreticalValue = (2.f * M_PI_FLOAT - (theta_u_top_min - theta_u_bottom_min)) * radius;
1412 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1413 std::string statusTest;
1415 statusTest =
"SUCCESS";
1418 statusTest =
"FAILED";
1420 std::cout <<
"Test with intersections with the top, bottom and the right border, crossing only the top and bottom axes in the RoI." << std::endl;
1421 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1422 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1423 std::cout <<
"\ttest status = " << statusTest << std::endl;
1425 hasSucceeded &= isValueOK;
1440 float theta_u_top_min = 4.f * M_PI_FLOAT / 6.f;
1441 float theta_u_top_max = M_PI_FLOAT - theta_u_top_min;
1442 float theta_v_min = 0;
1443 float theta_u_bottom_min = -theta_u_top_min;
1444 float theta_u_bottom_max = -theta_u_top_max;
1445 float radius = HEIGHT / (2.f * std::sin(theta_u_top_min));
1446 float vc = OFFSET + radius * std::sin(theta_u_top_min);
1447 float uc = OFFSET + WIDTH - radius * std::cos(theta_v_min);
1449 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1450 float theoreticalValue = (2.f * M_PI_FLOAT - ((theta_u_top_min - theta_u_top_max) + (theta_u_bottom_max - theta_u_bottom_min))) * radius;
1451 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1452 std::string statusTest;
1454 statusTest =
"SUCCESS";
1457 statusTest =
"FAILED";
1459 std::cout <<
"Test with intersections with the top, bottom and the right border, crossing the top and bottom axes and touching the right axis in the RoI." << std::endl;
1460 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1461 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1462 std::cout <<
"\ttest status = " << statusTest << std::endl;
1464 hasSucceeded &= isValueOK;
1479 float theta_u_top_min = M_PI_2_FLOAT;
1480 float theta_v_min = 3.f * M_PI_4_FLOAT;
1481 float theta_v_max = -theta_v_min;
1482 float radius = HEIGHT / 2.f;
1483 float vc = OFFSET + radius * std::sin(theta_u_top_min);
1484 float uc = OFFSET + WIDTH - radius * std::cos(theta_v_min);
1486 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1487 float theoreticalValue = (2.f * M_PI_FLOAT - (theta_v_min - theta_v_max)) * radius;
1488 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1489 std::string statusTest;
1491 statusTest =
"SUCCESS";
1494 statusTest =
"FAILED";
1496 std::cout <<
"Test with intersections with the top, bottom and the right border, crossing only the right axis in the RoI." << std::endl;
1497 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1498 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1499 std::cout <<
"\ttest status = " << statusTest << std::endl;
1501 hasSucceeded &= isValueOK;
1516 float theta_u_top_min = M_PI_2_FLOAT;
1517 float theta_v_min = M_PI_4_FLOAT;
1518 float theta_v_max = -theta_v_min;
1519 float radius = HEIGHT / 2.f;
1520 float vc = OFFSET + radius * std::sin(theta_u_top_min);
1521 float uc = OFFSET + WIDTH - radius * std::cos(theta_v_min);
1523 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1524 float theoreticalValue = (2.f * M_PI_FLOAT - (theta_v_min - theta_v_max)) * radius;
1525 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1526 std::string statusTest;
1528 statusTest =
"SUCCESS";
1531 statusTest =
"FAILED";
1533 std::cout <<
"Test with intersections with the top, bottom and the right border, crossing the right axis and touching the two others in the RoI." << std::endl;
1534 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1535 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1536 std::cout <<
"\ttest status = " << statusTest << std::endl;
1538 hasSucceeded &= isValueOK;
1553 float theta_u_top_min = M_PI_FLOAT;
1554 float theta_u_bot_min = -2.f * M_PI_FLOAT / 3.f;
1555 float theta_v_max = -5.f * M_PI_FLOAT / 6.f;
1556 float radius = HEIGHT / (std::sin(theta_u_top_min) - std::sin(theta_u_bot_min));
1557 float uc = OFFSET + WIDTH - radius * std::cos(theta_v_max);
1558 float vc = OFFSET + radius * std::sin(theta_u_top_min);
1560 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1561 float theoreticalValue = (2.f * M_PI_FLOAT - (theta_u_top_min - theta_v_max)) * radius;
1562 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1563 std::string statusTest;
1565 statusTest =
"SUCCESS";
1568 statusTest =
"FAILED";
1570 std::cout <<
"Test with intersections with the top, bottom and the right border, crossing the top and right axis once in the RoI." << std::endl;
1571 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1572 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1573 std::cout <<
"\ttest status = " << statusTest << std::endl;
1575 hasSucceeded &= isValueOK;
1590 float theta_u_top_min = 2.f * M_PI_FLOAT / 3.f;
1591 float theta_u_bot_min = M_PI_FLOAT;
1592 float theta_v_min = 5.f * M_PI_FLOAT / 6.f;
1593 float radius = HEIGHT / (std::sin(theta_u_top_min) - std::sin(theta_u_bot_min));
1594 float uc = OFFSET + WIDTH - radius * std::cos(theta_v_min);
1595 float vc = OFFSET + radius * std::sin(theta_u_top_min);
1597 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
1598 float theoreticalValue = (theta_u_bot_min - theta_v_min) * radius;
1599 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1600 std::string statusTest;
1602 statusTest =
"SUCCESS";
1605 statusTest =
"FAILED";
1607 std::cout <<
"Test with intersections with the top, bottom and the right border, crossing the bottom and right axis once in the RoI." << std::endl;
1608 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1609 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1610 std::cout <<
"\ttest status = " << statusTest << std::endl;
1612 hasSucceeded &= isValueOK;
1629 float theta_v_left_min = 7.f * M_PI_FLOAT / 8.f;
1630 float theta_v_left_max = -theta_v_left_min;
1631 float theta_v_right_min = M_PI_FLOAT / 8.f;
1632 float theta_v_right_max = -theta_v_right_min;
1633 float theta_u_top_min = 5.f * M_PI_FLOAT / 8.f;
1634 float theta_u_top_max = M_PI_FLOAT - theta_u_top_min;
1635 float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_min) - std::cos(theta_v_left_min));
1636 float uc = OFFSET + WIDTH_SWITCHED - radius * std::cos(theta_v_right_min);
1637 float vc = OFFSET + radius * std::sin(theta_u_top_min);
1639 float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
1640 float theoreticalValue = ((theta_v_left_min - theta_u_top_min) + (theta_u_top_max - theta_v_right_min) + (theta_v_right_max - theta_v_left_max)) * radius;
1641 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1642 std::string statusTest;
1644 statusTest =
"SUCCESS";
1647 statusTest =
"FAILED";
1649 std::cout <<
"Test with intersections with the top, left and the right border, crossing each axis twice in the RoI." << std::endl;
1650 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1651 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1652 std::cout <<
"\ttest status = " << statusTest << std::endl;
1654 hasSucceeded &= isValueOK;
1670 float theta_u_top_min = -2.f * M_PI_FLOAT / 3.f;
1671 float uc = OFFSET + WIDTH_SWITCHED/2.f;
1672 float vc = OFFSET + RADIUS * std::sin(theta_u_top_min);
1674 float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
1675 float theoreticalValue = (M_PI_FLOAT/3.f) * RADIUS;
1676 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1677 std::string statusTest;
1679 statusTest =
"SUCCESS";
1682 statusTest =
"FAILED";
1684 std::cout <<
"Test with intersections with the top, left and the right border, crossing only the top axis." << std::endl;
1685 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1686 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1687 std::cout <<
"\ttest status = " << statusTest << std::endl;
1689 hasSucceeded &= isValueOK;
1706 float theta_v_left_max = -5.f * M_PI_FLOAT / 8.f;
1707 float theta_v_right_max = -3.f *M_PI_FLOAT / 8.f;
1708 float theta_u_top_min = -7.f * M_PI_FLOAT / 8.f;
1709 float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_max) - std::cos(theta_v_left_max));
1710 float uc = OFFSET - radius * std::cos(theta_v_left_max);
1711 float vc = OFFSET + radius * std::sin(theta_u_top_min);
1713 float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
1714 float theoreticalValue = (theta_v_right_max - theta_v_left_max) * radius;
1715 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1716 std::string statusTest;
1718 statusTest =
"SUCCESS";
1721 statusTest =
"FAILED";
1723 std::cout <<
"Test with intersections with the top, left and the right border, crossing only left right in the RoI." << std::endl;
1724 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1725 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1726 std::cout <<
"\ttest status = " << statusTest << std::endl;
1728 hasSucceeded &= isValueOK;
1745 float theta_u_top_max = -M_PI_FLOAT / 3.f;
1746 float theta_v_right_max = 0.f;
1747 float theta_v_left_max = -M_PI_2_FLOAT;
1748 float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_max) - std::cos(theta_v_left_max));
1750 float vc = OFFSET + radius * std::sin(theta_u_top_max);
1752 float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
1753 float theoreticalValue = (theta_u_top_max - theta_v_left_max) * radius;
1754 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1755 std::string statusTest;
1757 statusTest =
"SUCCESS";
1760 statusTest =
"FAILED";
1762 std::cout <<
"Test with intersections with the top, left and the right border, crossing only the top and left axes." << std::endl;
1763 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1764 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1765 std::cout <<
"\ttest status = " << statusTest << std::endl;
1767 hasSucceeded &= isValueOK;
1784 float theta_u_top_min = -2.f * M_PI_FLOAT / 3.f;
1785 float theta_v_left_max = M_PI_FLOAT;
1786 float theta_v_right_max = -M_PI_2_FLOAT;
1787 float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_max) - std::cos(theta_v_left_max));
1788 float uc = OFFSET + WIDTH_SWITCHED;
1789 float vc = OFFSET + radius * std::sin(theta_u_top_min);
1791 float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
1792 float theoreticalValue = (theta_v_right_max - theta_u_top_min) * radius;
1793 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1794 std::string statusTest;
1796 statusTest =
"SUCCESS";
1799 statusTest =
"FAILED";
1801 std::cout <<
"Test with intersections with the top, left and the right border, crossing only the top and right axes." << std::endl;
1802 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1803 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1804 std::cout <<
"\ttest status = " << statusTest << std::endl;
1806 hasSucceeded &= isValueOK;
1823 float theta_v_left_min = 7.f * M_PI_FLOAT / 8.f;
1824 float theta_v_left_max = -theta_v_left_min;
1825 float theta_v_right_min = M_PI_FLOAT / 8.f;
1826 float theta_v_right_max = -theta_v_right_min;
1827 float theta_u_bot_min = -5.f * M_PI_FLOAT / 8.f;
1828 float theta_u_bot_max = -M_PI_FLOAT - theta_u_bot_min;
1829 float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_min) - std::cos(theta_v_left_min));
1830 float uc = OFFSET + WIDTH_SWITCHED - radius * std::cos(theta_v_right_min);
1831 float vc = OFFSET + HEIGHT_SWITCHED + radius * std::sin(theta_u_bot_min);
1833 float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
1834 float theoreticalValue = ((theta_v_left_min - theta_v_right_min) + (theta_v_right_max - theta_u_bot_max) + (theta_u_bot_min - theta_v_left_max)) * radius;
1835 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1836 std::string statusTest;
1838 statusTest =
"SUCCESS";
1841 statusTest =
"FAILED";
1843 std::cout <<
"Test with intersections with the bottom, left and the right border, crossing each axis twice in the RoI." << std::endl;
1844 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1845 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1846 std::cout <<
"\ttest status = " << statusTest << std::endl;
1848 hasSucceeded &= isValueOK;
1864 float theta_u_bot_min = 2.f * M_PI_FLOAT / 3.f;
1865 float theta_u_bot_max = M_PI_FLOAT - theta_u_bot_min;
1866 float theta_v_left_min = 5.f * M_PI_FLOAT / 6.f;
1867 float theta_v_right_min = M_PI_FLOAT / 6.f;
1868 float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_min) - std::cos(theta_v_left_min));
1869 float uc = OFFSET + WIDTH_SWITCHED - radius * std::cos(theta_v_right_min);
1870 float vc = OFFSET + HEIGHT_SWITCHED + radius * std::sin(theta_u_bot_min);
1872 float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
1873 float theoreticalValue = ((theta_u_bot_min - theta_u_bot_max)) * radius;
1874 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1875 std::string statusTest;
1877 statusTest =
"SUCCESS";
1880 statusTest =
"FAILED";
1882 std::cout <<
"Test with intersections with the bottom, left and the right border, crossing only the bottom one in the RoI." << std::endl;
1883 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1884 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1885 std::cout <<
"\ttest status = " << statusTest << std::endl;
1887 hasSucceeded &= isValueOK;
1903 float theta_u_bot_min = 7.f * M_PI_FLOAT / 8.f;
1904 float theta_v_left_min = 5.f * M_PI_FLOAT / 8.f;
1905 float theta_v_right_min = 3.f * M_PI_FLOAT / 8.f;
1906 float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_min) - std::cos(theta_v_left_min));
1907 float uc = OFFSET + WIDTH_SWITCHED - radius * std::cos(theta_v_right_min);
1908 float vc = OFFSET + HEIGHT_SWITCHED + radius * std::sin(theta_u_bot_min);
1910 float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
1911 float theoreticalValue = ((theta_v_left_min - theta_v_right_min)) * radius;
1912 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1913 std::string statusTest;
1915 statusTest =
"SUCCESS";
1918 statusTest =
"FAILED";
1920 std::cout <<
"Test with intersections with the bottom, left and the right border, crossing only the left and right in the RoI." << std::endl;
1921 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1922 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1923 std::cout <<
"\ttest status = " << statusTest << std::endl;
1925 hasSucceeded &= isValueOK;
1941 float theta_u_bot_max = M_PI_FLOAT / 3.f;
1942 float theta_v_left_min = M_PI_2_FLOAT;
1943 float theta_v_right_min = 0.f;
1944 float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_min) - std::cos(theta_v_left_min));
1946 float vc = OFFSET + HEIGHT_SWITCHED + radius * std::sin(theta_u_bot_max);
1948 float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
1949 float theoreticalValue = ((theta_v_left_min - theta_u_bot_max)) * radius;
1950 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1951 std::string statusTest;
1953 statusTest =
"SUCCESS";
1956 statusTest =
"FAILED";
1958 std::cout <<
"Test with intersections with the bottom, left and the right border, crossing only the left and bottom in the RoI." << std::endl;
1959 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1960 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1961 std::cout <<
"\ttest status = " << statusTest << std::endl;
1963 hasSucceeded &= isValueOK;
1979 float theta_u_bot_min = 2.f * M_PI_FLOAT / 3.f;
1980 float theta_v_right_min = M_PI_2_FLOAT;
1981 float theta_v_left_min = M_PI_FLOAT;
1982 float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_min) - std::cos(theta_v_left_min));
1983 float uc = OFFSET + WIDTH_SWITCHED;
1984 float vc = OFFSET + HEIGHT_SWITCHED + radius * std::sin(theta_u_bot_min);
1986 float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
1987 float theoreticalValue = ((theta_u_bot_min - theta_v_right_min)) * radius;
1988 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
1989 std::string statusTest;
1991 statusTest =
"SUCCESS";
1994 statusTest =
"FAILED";
1996 std::cout <<
"Test with intersections with the bottom, left and the right border, crossing only the right and bottom in the RoI." << std::endl;
1997 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
1998 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
1999 std::cout <<
"\ttest status = " << statusTest << std::endl;
2001 hasSucceeded &= isValueOK;
2013 float theta_u_top_min = 2.f * M_PI_FLOAT / 3.f;
2014 float theta_u_top_max = M_PI_FLOAT / 3.f;
2015 float theta_u_bottom_min = -2.f * M_PI_FLOAT / 3.f;
2016 float theta_u_bottom_max = -M_PI_FLOAT / 3.f;
2017 float uc = OFFSET + WIDTH / 2.f;
2018 float vc = OFFSET + HEIGHT / 2.f;
2019 float radius = -(OFFSET - vc)/ std::sin(theta_u_top_min);
2022 float arcLengthCircle = circle.computeArcLengthInRoI(roi);
2023 float theoreticalValue = (2.f * M_PI_FLOAT - ((theta_u_top_min - theta_u_top_max) + (theta_u_bottom_max - theta_u_bottom_min))) * radius;
2024 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
2025 std::string statusTest;
2027 statusTest =
"SUCCESS";
2030 statusTest =
"FAILED";
2032 std::cout <<
"Test with intersections with the top and bottom borders only, crossing each axis twice in the RoI." << std::endl;
2033 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
2034 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
2035 std::cout <<
"\ttest status = " << statusTest << std::endl;
2037 hasSucceeded &= isValueOK;
2049 float theta_v_left_min = 5.f * M_PI_FLOAT / 6.f;
2050 float theta_v_left_max = -theta_v_left_min;
2051 float theta_v_right_min = M_PI_FLOAT / 6.f;
2052 float theta_v_right_max = -theta_v_right_min;
2053 float uc = OFFSET + HEIGHT / 2.f;
2054 float vc = OFFSET + WIDTH / 2.f;
2055 float radius = (OFFSET - uc)/ std::cos(theta_v_left_min);
2058 float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
2059 float theoreticalValue = ((theta_v_left_min - theta_v_right_min) + (theta_v_right_max - theta_v_left_max)) * radius;
2060 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
2061 std::string statusTest;
2063 statusTest =
"SUCCESS";
2066 statusTest =
"FAILED";
2068 std::cout <<
"Test with intersections with the right and left borders only, crossing each axis twice in the RoI." << std::endl;
2069 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
2070 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
2071 std::cout <<
"\ttest status = " << statusTest << std::endl;
2073 hasSucceeded &= isValueOK;
2080 vpRect squareRoI(OFFSET, OFFSET, HEIGHT, HEIGHT);
2081 float theta_v_left_min = 7.f * M_PI_FLOAT / 8.f;
2082 float uc = OFFSET + HEIGHT / 2.f;
2083 float vc = OFFSET + HEIGHT / 2.f;
2084 float radius = (OFFSET - uc) / std::cos(theta_v_left_min);
2087 float arcLengthCircle = circle.computeArcLengthInRoI(squareRoI);
2088 float theoreticalValue = M_PI_FLOAT * radius;
2089 bool isValueOK = equal(arcLengthCircle, theoreticalValue);
2090 std::string statusTest;
2092 statusTest =
"SUCCESS";
2095 statusTest =
"FAILED";
2097 std::cout <<
"Test with intersections with the top and bottom borders only, crossing each axis twice in the RoI." << std::endl;
2098 std::cout <<
"\tarc length =" << arcLengthCircle << std::endl;
2099 std::cout <<
"\ttheoretical length =" << theoreticalValue << std::endl;
2100 std::cout <<
"\ttest status = " << statusTest << std::endl;
2102 hasSucceeded &= isValueOK;
2106 std::cout <<
"testImageCircle overall result: SUCCESS" << std::endl;
2107 return EXIT_SUCCESS;
2110 std::cout <<
"testImageCircle overall result: FAILED" << std::endl;
2111 return EXIT_FAILURE;
Class that defines a 2D circle in an image.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static float getAngleBetweenMinPiAndPi(const float &theta)
Defines a rectangle in the plane.