Plot 3D curves example.
#include <iostream>
#include <visp3/core/vpConfig.h>
#include <visp3/gui/vpPlot.h>
int main ()
{
#if defined(VISP_HAVE_DISPLAY)
try {
plot.
setLegend(0,0,
"y^2+z^2=1 and y(0) = 1");
plot.
setLegend(0,1,
"y^2+z^2=1 and y(0) = -1");
double x = 0;
double y = 1;
double z = 0 ;
double dx = 0.08;
double dy = 0.04;
double zsign = 1.0;
unsigned long iter = 0;
std::cout << "Hit CTRL-C to or right mouse button to exit..." << std::endl;
bool end = false;
while( !end ) {
if (iter < 300) {
if (fabs(y) < 1.0)
z = sqrt(1.0-y*y);
else z = 0;
end = true;
end = true;
x += dx;
if (fabs(y) >= 1.0 )
dy = -dy;
y += dy;
if (fabs(y) >= 1.0 )
zsign = -zsign;
}
else {
end = true;
end = true;
}
iter ++;
}
return 0;
}
std::cout << "Catch an exception: " << e << std::endl;
return 1;
}
#else
std::cout << "Plot functionalities are not avalaible since no display is available." << std::endl;
#endif
}