236 Introduction to C++ Programming and Graphics
Problems
7.6.1. Modify the codegraph2danmto display (a) a traveling square wave,
and (b) a traveling triangular wave.
7.6.2. Write a code that animates a rolling wheel containing seven rotating
spokes. The wheel should be rolling, not idly spinning.
7.7 Three-dimensional interactive graph Contents xi
In the most ambitious project, we build a code that plots a group of three-
dimensional lines in thexyzspace. The code will employ two ancillary func-
tions that use basicVoglecommands to move the cursor and draw straight
segments:
- Functiondrawplot3dprepares the three-dimensional graph.
- Functionplot3dtranstransforms the graph by rotating the axes and
zooming in and out. In addition, it offers an option for printing and
resetting the plotting parameters.
We discuss these two functions individually and then illustrate their use in a
plotting code.
Function drawplot3d
The implementation of the functiondrawplot3dis:
/*------------------------
drawplot3d
Draw a three-dimensional plot with axes
-------------------------*/
#include<fstream>
#include<iostream>
#include<iomanip>
#include<cmath>
#include "VOGLE/voglec++.h"
#include "plot3dglobals.h"
using namespace std;
void drawplot3d ()
{
//--- Prepare: