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 EXIT_SUCCESS;
std::cout << "Catch an exception: " << e << std::endl;
return EXIT_FAILURE;
}
#else
std::cout << "Plot functionalities are not avalaible since no display is "
"available."
<< std::endl;
return EXIT_SUCCESS;
#endif
}
static const vpColor green
error that can be emitted by ViSP classes.
This class enables real time drawing of 2D or 3D graphics. An instance of the class open a window whi...
void initGraph(unsigned int graphNum, unsigned int curveNbr)
void setUnitY(unsigned int graphNum, const std::string &unity)
void setLegend(unsigned int graphNum, unsigned int curveNum, const std::string &legend)
void plot(unsigned int graphNum, unsigned int curveNum, double x, double y)
void setUnitX(unsigned int graphNum, const std::string &unitx)
void setColor(unsigned int graphNum, unsigned int curveNum, vpColor color)
void setUnitZ(unsigned int graphNum, const std::string &unitz)
void setTitle(unsigned int graphNum, const std::string &title)