220 Introduction to C++ Programming and Graphics
/*----------------
plot2dsimpleplot a line
-----------------*/#include<cmath>
#include "VOGLE/voglec++.h"
#include "drawmarker2d.h"
#include "drawline2d.h"using namespace std;int main()
{//--- Define the data :const int n=512;
float xd[n], yd[n];for (int i=0; i<n; i++)
{
xd[i]=-0.3+4.0*(i-1.0)/n;
yd[i]=0.5+0.3*sin(35.0*xd[i])*exp(xd[i]);
}//--- Set plotting limits:float xmin=0.0; float xmax=1.0;
float ymin=0.0; float ymax=1.0;// Set plotting margins:float xmarg = 0.2*(xmax-xmin);
float ymarg = 0.2*(ymax-ymin);//--- Launch the graphics:prefposition (500,100);
prefsize (500,500);
char device[]="X11"; // initialize on the screen
vinit(device);ortho2 (xmin-xmarg,xmax+xmarg,ymin-ymarg,ymax+ymarg);
color (YELLOW); // yellow background
clear();//--- Draw markers at the data points: