#include <iostream>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpImageCircle.h>
#include <visp3/core/vpMath.h>
#include <visp3/core/vpRect.h>
bool equal(const float &actualVal, const float &theoreticalVal)
{
return (std::abs(theoreticalVal - actualVal) < 1.f);
}
int main()
{
#ifdef ENABLE_VISP_NAMESPACE
#endif
const float OFFSET = 5.f;
const float WIDTH = 640.f;
const float HEIGHT = 480.f;
const float RADIUS = std::min<float>(WIDTH, HEIGHT) / 10.f;
vpRect roi(OFFSET, OFFSET, WIDTH, HEIGHT);
const float WIDTH_SWITCHED = HEIGHT;
const float HEIGHT_SWITCHED = WIDTH;
vpRect switchedRoI(OFFSET, OFFSET, WIDTH_SWITCHED, HEIGHT_SWITCHED);
bool hasSucceeded = true;
{
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 2.f * M_PI_FLOAT * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test no intersection." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
vpRect roiSquare(OFFSET, OFFSET, HEIGHT, HEIGHT);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 2.f * M_PI_FLOAT * HEIGHT / 2.f;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test circle touching borders of the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float uc = OFFSET + 24.f;
float vc = OFFSET + 100.f;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 4.f * M_PI_FLOAT * RADIUS /3.f;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test intersection left border, more than half a circle visible." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float uc = OFFSET - 24.f;
float vc = OFFSET + 100.f;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 2.f * M_PI_FLOAT * RADIUS /3.f;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test intersection left border, less than half a circle visible." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float uc = OFFSET + RADIUS;
float vc = OFFSET + 100.f;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 2.f * M_PI_FLOAT * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with circle touching the left border, all the circle is visible." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float uc = OFFSET - RADIUS;
float vc = OFFSET - 100.f;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 0.f;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with circle touching the left border, all the circle is hidden." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float uc = OFFSET + 616.f;
float vc = OFFSET + 100.f;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 4.f * M_PI_FLOAT * RADIUS /3.f;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test intersection right border, more than half a circle visible." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float uc = OFFSET + 664.f;
float vc = OFFSET + 100.f;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 2.f * M_PI_FLOAT * RADIUS /3.f;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test intersection right border, less than half a circle visible." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float uc = OFFSET + WIDTH - RADIUS;
float vc = OFFSET + 100.f;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 2.f * M_PI_FLOAT * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with circle touching the right border, all the circle is visible." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float uc = OFFSET + WIDTH + RADIUS;
float vc = OFFSET + 100.f;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 0.f;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with circle touching the right border, all the circle is hidden." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta = M_PI_FLOAT / 3.f;
float uc = OFFSET + 100.f;
float vc = OFFSET + RADIUS * sin(theta);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 5.f * M_PI_FLOAT * RADIUS /3.f;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test intersection top border, more than half a circle visible." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta = -2.f * M_PI_FLOAT/3.f;
float uc = OFFSET + 100.f;
float vc = OFFSET + RADIUS * std::sin(theta);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = M_PI_FLOAT * RADIUS /3.f;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test intersection top border, less than half a circle visible." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta = M_PI_2_FLOAT;
float uc = OFFSET + 100.f;
float vc = OFFSET + RADIUS * sin(theta);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 2.f * M_PI_FLOAT * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with circle touching the top border, all the circle is visible." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta = -M_PI_2_FLOAT;
float uc = OFFSET + 100.f;
float vc = OFFSET + RADIUS * sin(theta);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 0.f;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with circle touching the top border, all the circle is hidden." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta = -M_PI_FLOAT / 3.f;
float uc = OFFSET + 100.f;
float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 5.f * M_PI_FLOAT * RADIUS /3.f;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test intersection bottom border, more than half a circle visible." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta = M_PI_FLOAT / 3.f;
float uc = OFFSET + 100.f;
float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = M_PI_FLOAT * RADIUS /3.f;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test intersection bottom border, less than half a circle visible." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float uc = OFFSET + 100.f;
float vc = OFFSET + HEIGHT - RADIUS;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 2.f * M_PI_FLOAT * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with circle touching the bottom border, all the circle is visible." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float uc = OFFSET + 100.f;
float vc = OFFSET + HEIGHT + RADIUS;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 0.f;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with circle touching the bottom border, all the circle is hidden." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float uc = OFFSET;
float vc = OFFSET;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = M_PI_2_FLOAT * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top and the left border, crossing each axis once in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_v_min = M_PI_FLOAT / 4.f;
float uc = OFFSET - RADIUS * std::cos(theta_v_min);
float vc = OFFSET + RADIUS * std::sin(theta_v_min) + 1.f;
vc = std::max<float>(vc, OFFSET + RADIUS * std::sin(-theta_v_min) + 1.f);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = M_PI_2_FLOAT * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top and the left border but crossing only the left axis in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = -1.1f * M_PI_2_FLOAT;
float uc = OFFSET - RADIUS * std::cos(theta_u_top_min) + 1.f;
uc = std::max<float>(uc, OFFSET - RADIUS * std::cos(M_PI_FLOAT - theta_u_top_min) + 1.f);
float vc = OFFSET + RADIUS * std::sin(theta_u_top_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = 0.2f * M_PI_2_FLOAT * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top and the left border but crossing only the top axis in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = 5.f * M_PI_FLOAT / 8.f;
float theta_u_top_max = M_PI_FLOAT - theta_u_top_min;
float uc = OFFSET - RADIUS * std::cos(theta_u_top_min) + 1.f;
uc = std::max<float>(uc, OFFSET - RADIUS * std::cos(M_PI_FLOAT - theta_u_top_min) + 1.f);
float vc = OFFSET + RADIUS * std::sin(theta_u_top_min);
float theta_v_min = std::acos((OFFSET - uc)/RADIUS);
float theta_v_max = -theta_v_min;
if (theta_v_max < 0) {
float temp = theta_v_max;
theta_v_max = theta_v_min;
theta_v_min = temp;
}
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = ((theta_v_max - theta_u_top_min) + (theta_u_top_max - theta_v_min)) * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top and the left border crossing twice each axis ." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length = " << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = 2.f * M_PI_FLOAT / 3.f;
float theta_v_max = -M_PI_2_FLOAT;
float uc = OFFSET + WIDTH - RADIUS * std::cos(theta_v_max);
float vc = OFFSET + RADIUS * std::sin(theta_u_top_min);;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (M_PI_2_FLOAT + M_PI_FLOAT / 3.f) * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top and the right border, crossing each axis once in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_v_max = -7.f * M_PI_FLOAT / 8.f;
float theta_v_min = -theta_v_max;
float uc = OFFSET + WIDTH - RADIUS * std::cos(theta_v_max);
float vc = RADIUS * std::sin(std::acos((OFFSET + WIDTH - uc)/RADIUS)) + OFFSET + 1.f;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (2.f * M_PI_FLOAT - (theta_v_min - theta_v_max)) * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top and the right border, but crossing only the right border in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = -0.9f * M_PI_2_FLOAT;
float theta_u_top_max = M_PI_FLOAT - theta_u_top_min;
float vc = OFFSET + RADIUS * std::sin(theta_u_top_min);
float theta_v_min = std::asin((vc - OFFSET)/RADIUS) + 1.f;
float uc = OFFSET + WIDTH - RADIUS * std::cos(theta_v_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = std::abs(theta_u_top_min - theta_u_top_max) * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top and the right border, but crossing only the top border in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = 5.f * M_PI_FLOAT / 8.f;
float theta_u_top_max = M_PI_FLOAT - theta_u_top_min;
float uc = OFFSET + WIDTH - RADIUS * std::cos(theta_u_top_min) - 1.f;
uc = std::min<float>(uc, OFFSET + WIDTH - RADIUS * std::cos(M_PI_FLOAT - theta_u_top_min) - 1.f);
float vc = OFFSET + RADIUS * std::sin(theta_u_top_min);
float theta_v_min = std::acos((OFFSET + WIDTH - uc)/RADIUS);
float theta_v_max = -theta_v_min;
if (theta_v_min < 0) {
float temp = theta_v_min;
theta_v_min = theta_v_max;
theta_v_max = temp;
}
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (2.f * M_PI_FLOAT - ((theta_u_top_min - theta_u_top_max) + (theta_v_min - theta_v_max))) * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top and the left border crossing twice each axis ." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length = " << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_v_min = M_PI_2_FLOAT;
float theta_u_bot_max = -M_PI_FLOAT / 3.f;
float uc = OFFSET - RADIUS * std::cos(theta_v_min);
float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta_u_bot_max);;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (M_PI_2_FLOAT + M_PI_FLOAT / 3.f) * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the bottom and the left border, crossing each axis once in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_v_min = M_PI_4_FLOAT / 2.f;
float theta_v_max = -theta_v_min;
float uc = OFFSET - RADIUS * std::cos(theta_v_min);
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);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (2.f * theta_v_min) * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the bottom and the left border, but crossing only the left border in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_bot_min = 5.f * M_PI_4_FLOAT / 2.f;
float theta_u_bot_max = M_PI_FLOAT - theta_u_bot_min;
float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta_u_bot_min);
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);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (theta_u_bot_min - theta_u_bot_max) * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the bottom and the left border, but crossing only the bottom border in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_bot_min = -5.f * M_PI_FLOAT / 8.f;
float theta_u_bot_max = M_PI_FLOAT - theta_u_bot_min;
float theta_v_min = 7.f * M_PI_FLOAT / 8.f;
float theta_v_max = -theta_v_min;
float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta_u_bot_min);
float uc = OFFSET - RADIUS * std::cos(theta_v_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = ((theta_v_min - theta_u_bot_max) + (theta_u_bot_min - theta_v_max)) * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the bottom and the left border, crossing each axis twice in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_bot_min = -2.f * M_PI_FLOAT / 3.f;
float theta_v_min = M_PI_2_FLOAT;
float uc = OFFSET + WIDTH - RADIUS * std::cos(theta_v_min);
float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta_u_bot_min);;
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (M_PI_2_FLOAT + M_PI_FLOAT / 3.f) * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the bottom and the right border, crossing each axis once in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_v_min = 5.f * M_PI_FLOAT / 6.f;
float uc = OFFSET + WIDTH - RADIUS * std::cos(theta_v_min);
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);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (M_PI_FLOAT / 3.f) * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
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;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_bot_min = 4.f * M_PI_FLOAT / 6.f;
float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta_u_bot_min);
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);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (M_PI_FLOAT / 3.f) * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
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;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_bot_min = -7.f * M_PI_FLOAT / 8.f;
float theta_u_bot_max = M_PI_FLOAT - theta_u_bot_min;
float theta_v_max = -3.f * M_PI_FLOAT / 8.f;
float theta_v_min = -theta_v_max;
float vc = OFFSET + HEIGHT + RADIUS * std::sin(theta_u_bot_min);
float uc = OFFSET - RADIUS * std::cos(theta_v_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (2.f * M_PI_FLOAT - ((theta_v_min - theta_v_max) + (theta_u_bot_max - theta_u_bot_min))) * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the bottom and the right border, crossing each axis twice in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = 5.f * M_PI_FLOAT / 8.f;
float theta_u_top_max = 3.f * M_PI_FLOAT / 8.f;
float theta_v_min = 7.f * M_PI_FLOAT / 8.f;
float theta_v_max = -theta_v_min;
float theta_u_bottom_min = -5.f * M_PI_FLOAT / 8.f;
float theta_u_bottom_max = -3.f * M_PI_FLOAT / 8.f;
float vc = OFFSET + HEIGHT / 2.f;
float radius = -(OFFSET - vc)/ std::sin(theta_u_top_min);
float uc = OFFSET - radius * std::cos(theta_v_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
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;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top, bottom and the left border, crossing each axis twice in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_max = M_PI_FLOAT / 6.f;
float theta_u_top_min = M_PI_FLOAT - theta_u_top_max;
float theta_v_min = M_PI_FLOAT / 3.f;
float theta_u_bottom_max = -theta_u_top_max;
float radius = HEIGHT;
float vc = OFFSET + radius * std::sin(theta_u_top_min);
float uc = OFFSET - radius * std::cos(theta_v_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (theta_u_top_max - theta_u_bottom_max) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
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;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = 4.f * M_PI_FLOAT / 6.f;
float theta_u_top_max = M_PI_FLOAT - theta_u_top_min;
float theta_v_min = M_PI_FLOAT;
float theta_u_bottom_min = -theta_u_top_min;
float theta_u_bottom_max = -theta_u_top_max;
float radius = HEIGHT / (2.f * std::sin(theta_u_top_min));
float vc = OFFSET + radius * std::sin(theta_u_top_min);
float uc = OFFSET - radius * std::cos(theta_v_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (2.f * M_PI_FLOAT - ((theta_u_top_min - theta_u_top_max) + (theta_u_bottom_max - theta_u_bottom_min))) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
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;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = M_PI_2_FLOAT;
float theta_v_min = M_PI_4_FLOAT;
float theta_v_max = -theta_v_min;
float radius = HEIGHT / 2.f;
float vc = OFFSET + radius * std::sin(theta_u_top_min);
float uc = OFFSET - radius * std::cos(theta_v_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (theta_v_min - theta_v_max) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top, bottom and the left border, crossing only the left axis in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = M_PI_2_FLOAT;
float theta_v_min = 3.f * M_PI_4_FLOAT;
float theta_v_max = -theta_v_min;
float radius = HEIGHT / 2.f;
float vc = OFFSET + radius * std::sin(theta_u_top_min);
float uc = OFFSET - radius * std::cos(theta_v_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (theta_v_min - theta_v_max) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
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;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_max = 0.f;
float theta_u_bot_max = -M_PI_FLOAT / 3.f;
float theta_v_max = -M_PI_FLOAT / 6.f;
float radius = HEIGHT / (std::sin(theta_u_top_max) - std::sin(theta_u_bot_max));
float uc = OFFSET - radius * std::cos(theta_v_max);
float vc = OFFSET + radius * std::sin(theta_u_top_max);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (theta_u_top_max - theta_v_max) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
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;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_max = M_PI_FLOAT / 3.f;
float theta_u_bot_max = 0.f;
float theta_v_min = M_PI_FLOAT / 6.f;
float radius = HEIGHT / (std::sin(theta_u_top_max) - std::sin(theta_u_bot_max));
float uc = OFFSET - radius * std::cos(theta_v_min);
float vc = OFFSET + radius * std::sin(theta_u_top_max);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (theta_v_min - theta_u_bot_max) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
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;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = 5.f * M_PI_FLOAT / 8.f;
float theta_u_top_max = 3.f * M_PI_FLOAT / 8.f;
float theta_v_min = 1.f * M_PI_FLOAT / 8.f;
float theta_v_max = -theta_v_min;
float theta_u_bottom_min = -5.f * M_PI_FLOAT / 8.f;
float theta_u_bottom_max = -3.f * M_PI_FLOAT / 8.f;
float vc = OFFSET + HEIGHT / 2.f;
float radius = -(OFFSET - vc)/ std::sin(theta_u_top_min);
float uc = OFFSET + WIDTH - radius * std::cos(theta_v_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
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;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top, bottom and the right border, crossing each axis twice in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = 5.f * M_PI_FLOAT / 6.f;
float theta_v_min = 2.f * M_PI_FLOAT / 3.f;
float theta_u_bottom_min = -theta_u_top_min;
float radius = HEIGHT;
float vc = OFFSET + radius * std::sin(theta_u_top_min);
float uc = OFFSET + WIDTH - radius * std::cos(theta_v_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (2.f * M_PI_FLOAT - (theta_u_top_min - theta_u_bottom_min)) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
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;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = 4.f * M_PI_FLOAT / 6.f;
float theta_u_top_max = M_PI_FLOAT - theta_u_top_min;
float theta_v_min = 0;
float theta_u_bottom_min = -theta_u_top_min;
float theta_u_bottom_max = -theta_u_top_max;
float radius = HEIGHT / (2.f * std::sin(theta_u_top_min));
float vc = OFFSET + radius * std::sin(theta_u_top_min);
float uc = OFFSET + WIDTH - radius * std::cos(theta_v_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (2.f * M_PI_FLOAT - ((theta_u_top_min - theta_u_top_max) + (theta_u_bottom_max - theta_u_bottom_min))) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
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;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = M_PI_2_FLOAT;
float theta_v_min = 3.f * M_PI_4_FLOAT;
float theta_v_max = -theta_v_min;
float radius = HEIGHT / 2.f;
float vc = OFFSET + radius * std::sin(theta_u_top_min);
float uc = OFFSET + WIDTH - radius * std::cos(theta_v_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (2.f * M_PI_FLOAT - (theta_v_min - theta_v_max)) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top, bottom and the right border, crossing only the right axis in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = M_PI_2_FLOAT;
float theta_v_min = M_PI_4_FLOAT;
float theta_v_max = -theta_v_min;
float radius = HEIGHT / 2.f;
float vc = OFFSET + radius * std::sin(theta_u_top_min);
float uc = OFFSET + WIDTH - radius * std::cos(theta_v_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (2.f * M_PI_FLOAT - (theta_v_min - theta_v_max)) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
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;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = M_PI_FLOAT;
float theta_u_bot_min = -2.f * M_PI_FLOAT / 3.f;
float theta_v_max = -5.f * M_PI_FLOAT / 6.f;
float radius = HEIGHT / (std::sin(theta_u_top_min) - std::sin(theta_u_bot_min));
float uc = OFFSET + WIDTH - radius * std::cos(theta_v_max);
float vc = OFFSET + radius * std::sin(theta_u_top_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (2.f * M_PI_FLOAT - (theta_u_top_min - theta_v_max)) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
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;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = 2.f * M_PI_FLOAT / 3.f;
float theta_u_bot_min = M_PI_FLOAT;
float theta_v_min = 5.f * M_PI_FLOAT / 6.f;
float radius = HEIGHT / (std::sin(theta_u_top_min) - std::sin(theta_u_bot_min));
float uc = OFFSET + WIDTH - radius * std::cos(theta_v_min);
float vc = OFFSET + radius * std::sin(theta_u_top_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (theta_u_bot_min - theta_v_min) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
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;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_v_left_min = 7.f * M_PI_FLOAT / 8.f;
float theta_v_left_max = -theta_v_left_min;
float theta_v_right_min = M_PI_FLOAT / 8.f;
float theta_v_right_max = -theta_v_right_min;
float theta_u_top_min = 5.f * M_PI_FLOAT / 8.f;
float theta_u_top_max = M_PI_FLOAT - theta_u_top_min;
float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_min) - std::cos(theta_v_left_min));
float uc = OFFSET + WIDTH_SWITCHED - radius * std::cos(theta_v_right_min);
float vc = OFFSET + radius * std::sin(theta_u_top_min);
float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
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;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top, left and the right border, crossing each axis twice in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = -2.f * M_PI_FLOAT / 3.f;
float uc = OFFSET + WIDTH_SWITCHED/2.f;
float vc = OFFSET + RADIUS * std::sin(theta_u_top_min);
float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
float theoreticalValue = (M_PI_FLOAT/3.f) * RADIUS;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top, left and the right border, crossing only the top axis." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_v_left_max = -5.f * M_PI_FLOAT / 8.f;
float theta_v_right_max = -3.f *M_PI_FLOAT / 8.f;
float theta_u_top_min = -7.f * M_PI_FLOAT / 8.f;
float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_max) - std::cos(theta_v_left_max));
float uc = OFFSET - radius * std::cos(theta_v_left_max);
float vc = OFFSET + radius * std::sin(theta_u_top_min);
float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
float theoreticalValue = (theta_v_right_max - theta_v_left_max) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top, left and the right border, crossing only left right in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_max = -M_PI_FLOAT / 3.f;
float theta_v_right_max = 0.f;
float theta_v_left_max = -M_PI_2_FLOAT;
float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_max) - std::cos(theta_v_left_max));
float uc = OFFSET;
float vc = OFFSET + radius * std::sin(theta_u_top_max);
float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
float theoreticalValue = (theta_u_top_max - theta_v_left_max) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top, left and the right border, crossing only the top and left axes." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = -2.f * M_PI_FLOAT / 3.f;
float theta_v_left_max = M_PI_FLOAT;
float theta_v_right_max = -M_PI_2_FLOAT;
float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_max) - std::cos(theta_v_left_max));
float uc = OFFSET + WIDTH_SWITCHED;
float vc = OFFSET + radius * std::sin(theta_u_top_min);
float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
float theoreticalValue = (theta_v_right_max - theta_u_top_min) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top, left and the right border, crossing only the top and right axes." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_v_left_min = 7.f * M_PI_FLOAT / 8.f;
float theta_v_left_max = -theta_v_left_min;
float theta_v_right_min = M_PI_FLOAT / 8.f;
float theta_v_right_max = -theta_v_right_min;
float theta_u_bot_min = -5.f * M_PI_FLOAT / 8.f;
float theta_u_bot_max = -M_PI_FLOAT - theta_u_bot_min;
float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_min) - std::cos(theta_v_left_min));
float uc = OFFSET + WIDTH_SWITCHED - radius * std::cos(theta_v_right_min);
float vc = OFFSET + HEIGHT_SWITCHED + radius * std::sin(theta_u_bot_min);
float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
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;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the bottom, left and the right border, crossing each axis twice in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_bot_min = 2.f * M_PI_FLOAT / 3.f;
float theta_u_bot_max = M_PI_FLOAT - theta_u_bot_min;
float theta_v_left_min = 5.f * M_PI_FLOAT / 6.f;
float theta_v_right_min = M_PI_FLOAT / 6.f;
float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_min) - std::cos(theta_v_left_min));
float uc = OFFSET + WIDTH_SWITCHED - radius * std::cos(theta_v_right_min);
float vc = OFFSET + HEIGHT_SWITCHED + radius * std::sin(theta_u_bot_min);
float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
float theoreticalValue = ((theta_u_bot_min - theta_u_bot_max)) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the bottom, left and the right border, crossing only the bottom one in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_bot_min = 7.f * M_PI_FLOAT / 8.f;
float theta_v_left_min = 5.f * M_PI_FLOAT / 8.f;
float theta_v_right_min = 3.f * M_PI_FLOAT / 8.f;
float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_min) - std::cos(theta_v_left_min));
float uc = OFFSET + WIDTH_SWITCHED - radius * std::cos(theta_v_right_min);
float vc = OFFSET + HEIGHT_SWITCHED + radius * std::sin(theta_u_bot_min);
float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
float theoreticalValue = ((theta_v_left_min - theta_v_right_min)) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the bottom, left and the right border, crossing only the left and right in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_bot_max = M_PI_FLOAT / 3.f;
float theta_v_left_min = M_PI_2_FLOAT;
float theta_v_right_min = 0.f;
float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_min) - std::cos(theta_v_left_min));
float uc = OFFSET;
float vc = OFFSET + HEIGHT_SWITCHED + radius * std::sin(theta_u_bot_max);
float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
float theoreticalValue = ((theta_v_left_min - theta_u_bot_max)) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the bottom, left and the right border, crossing only the left and bottom in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_bot_min = 2.f * M_PI_FLOAT / 3.f;
float theta_v_right_min = M_PI_2_FLOAT;
float theta_v_left_min = M_PI_FLOAT;
float radius = WIDTH_SWITCHED / (std::cos(theta_v_right_min) - std::cos(theta_v_left_min));
float uc = OFFSET + WIDTH_SWITCHED;
float vc = OFFSET + HEIGHT_SWITCHED + radius * std::sin(theta_u_bot_min);
float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
float theoreticalValue = ((theta_u_bot_min - theta_v_right_min)) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the bottom, left and the right border, crossing only the right and bottom in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_u_top_min = 2.f * M_PI_FLOAT / 3.f;
float theta_u_top_max = M_PI_FLOAT / 3.f;
float theta_u_bottom_min = -2.f * M_PI_FLOAT / 3.f;
float theta_u_bottom_max = -M_PI_FLOAT / 3.f;
float uc = OFFSET + WIDTH / 2.f;
float vc = OFFSET + HEIGHT / 2.f;
float radius = -(OFFSET - vc)/ std::sin(theta_u_top_min);
float arcLengthCircle = circle.computeArcLengthInRoI(roi);
float theoreticalValue = (2.f * M_PI_FLOAT - ((theta_u_top_min - theta_u_top_max) + (theta_u_bottom_max - theta_u_bottom_min))) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top and bottom borders only, crossing each axis twice in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
float theta_v_left_min = 5.f * M_PI_FLOAT / 6.f;
float theta_v_left_max = -theta_v_left_min;
float theta_v_right_min = M_PI_FLOAT / 6.f;
float theta_v_right_max = -theta_v_right_min;
float uc = OFFSET + HEIGHT / 2.f;
float vc = OFFSET + WIDTH / 2.f;
float radius = (OFFSET - uc)/ std::cos(theta_v_left_min);
float arcLengthCircle = circle.computeArcLengthInRoI(switchedRoI);
float theoreticalValue = ((theta_v_left_min - theta_v_right_min) + (theta_v_right_max - theta_v_left_max)) * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the right and left borders only, crossing each axis twice in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
{
vpRect squareRoI(OFFSET, OFFSET, HEIGHT, HEIGHT);
float theta_v_left_min = 7.f * M_PI_FLOAT / 8.f;
float uc = OFFSET + HEIGHT / 2.f;
float vc = OFFSET + HEIGHT / 2.f;
float radius = (OFFSET - uc) / std::cos(theta_v_left_min);
float arcLengthCircle = circle.computeArcLengthInRoI(squareRoI);
float theoreticalValue = M_PI_FLOAT * radius;
bool isValueOK = equal(arcLengthCircle, theoreticalValue);
std::string statusTest;
if (isValueOK) {
statusTest = "SUCCESS";
}
else {
statusTest = "FAILED";
}
std::cout << "Test with intersections with the top and bottom borders only, crossing each axis twice in the RoI." << std::endl;
std::cout << "\tarc length =" << arcLengthCircle << std::endl;
std::cout << "\ttheoretical length =" << theoreticalValue << std::endl;
std::cout << "\ttest status = " << statusTest << std::endl;
hasSucceeded &= isValueOK;
}
if (hasSucceeded) {
std::cout << "testImageCircle overall result: SUCCESS" << std::endl;
return EXIT_SUCCESS;
}
std::cout << "testImageCircle overall result: FAILED" << std::endl;
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.