Programming and Graphics

(Kiana) #1

246 Introduction to C++ Programming and Graphics


cout << "Device cannot support double-buffering" << endl;
exit(1);
}

//--- Generate data:

np[1] = 33;
np[2] = 49;

for(int i=1;i<=nc;i++)
{
for(int j=1;j<=np[i];j++)
{
float phase = (j-1)*2*pi/(np[i]-1);
if(i==1)
{
xd[i][j]=0.5+0.6*cos(phase)*sin(phase);
yd[i][j]=0.5+0.2*cos(phase);
zd[i][j]=0.2*sin(phase);
}
else if(i==2)
{
xd[i][j]=0.3*cos(phase);
yd[i][j]=0.4+0.2*cos(phase)*cos(phase);
zd[i][j]=0.3*sin(phase);
}
}
}

//--- Plot:

drawplot3d();
plot3dtrans();

//--- Interactive:

cout << "Press q to quit" << endl;
cout <<"ptoprint a postscript file" << endl;
cout <<"rtoreset" << endl;
cout << "Place cursor at the center of the graphics window" << endl;
cout << "and then click and move the:" << endl;
cout << " left-mouse button to rotate left-right" << endl;
cout << " right-mouse button to rotate up-down" << endl;
cout << " both buttons to zoom" << endl;

//--- Wait for the keyboard:

char kbd = char(getkey());
Free download pdf