Plot 3D curves example.
#include <iostream>
#include <visp/vpConfig.h>
#include <visp/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 exit...";
while(1) {
if (iter < 300) {
if (fabs(y) < 1.0)
z = sqrt(1.0-y*y);
else z = 0;
plot.
plot(0,0, x, y,z*zsign);
plot.
plot(0,1, x, -y,-z*zsign);
x += dx;
if (fabs(y) >= 1.0 )
dy = -dy;
y += dy;
if (fabs(y) >= 1.0 )
zsign = -zsign;
}
else {
plot.
plot(0,0, x, y,z*zsign);
plot.
plot(0,1, x, -y,-z*zsign);
}
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
}