Last active
October 11, 2019 17:56
-
-
Save matteing/a4d07322a646f75e7096f43b9e0ebcde to your computer and use it in GitHub Desktop.
lab #6 - prettyplots-functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Nombre: Sergio Mattei, Michael Terrefortes, Andres Rosner | |
ID: 801183252, 801189110, 801147305 | |
Class/Seccion: CCOM 3033 SEC 001 | |
Nombre de archivo: main.cpp | |
Descripción: This has all of the pretty plots with functions and using passing by reference. | |
*/ | |
#include<iostream> | |
#include "xyplotwindow.h" | |
#include <QApplication> | |
using namespace std; | |
//********************************************************** | |
// This function is to illustrate the difference between * | |
// pass by value and pass by reference * | |
//********************************************************** | |
void illustration(int paramValue, int ¶mRef) | |
{ | |
paramValue=1; | |
paramRef=1; | |
cout << endl << "The content of paramValue is: " << paramValue << endl | |
<< "The content of paramRef is: " << paramRef << endl; | |
} | |
//************************************ | |
// Functions circle * | |
//************************************ | |
void circle(double, double &, double &); | |
void circle(double, double &, double &, double); | |
void circle(double p, double &xCoord, double &yCoord) | |
{ | |
xCoord = 5 * cos(p); | |
yCoord = 5 * sin(p); | |
} | |
//Overloaded Funcion circle | |
void circle(double p, double &xCoord, double &yCoord, double r) | |
{ | |
xCoord = r * cos(p); | |
yCoord = r * sin(p); | |
} | |
//************************************ | |
// Function butterfly * | |
//************************************ | |
void butterfly(double t, double &xCoord, double &yCoord) | |
{ | |
xCoord = 5 * cos(t) * (pow(sin(1.2 * t), 2) + pow(cos(6 * t), 3)); | |
yCoord = 10 * sin(t) * (pow(sin(1.2 * t), 2) + pow(cos(6 * t), 3)); | |
} | |
//*************** | |
// Function main * | |
//*************** | |
int main(int argc, char *argv[]) | |
{ | |
QApplication a(argc, argv); | |
XYPlotWindow wCircleR5; | |
XYPlotWindow wCircle; | |
XYPlotWindow wButterfly; | |
double r = 15.0; | |
double y = 0.00; | |
double x = 0.00; | |
double increment = 0.01; | |
int argValue=0, argRef=0; | |
// invoke the function illustration to view the contents of variables by value and by reference | |
illustration(argValue,argRef); | |
cout << endl << "The content of argValue is: " << argValue << endl | |
<< "The content of argRef is: " << argRef << endl; | |
// repeat for several values of the angle t | |
for (double t = 0; t < 16*M_PI; t = t + increment) | |
{ | |
// invoke circle with the angle t and reference variables x, y as arguments | |
circle(t,x,y); | |
// add the point (x,y) to the graph of the circle | |
wCircleR5.AddPointToGraph(x,y); | |
// invoke circle with the radius r, the angle t and reference variables x, y as arguments | |
circle(t,x,y, r); | |
// add the point (x,y) to the graph of the circle | |
wCircle.AddPointToGraph(x, y); | |
// invoke butterfly with the angle t and reference variables x, y as arguments | |
butterfly(t,x,y); | |
// add the point (x,y) to the graph of the butterfly | |
wButterfly.AddPointToGraph(x, y); | |
} | |
// After all the points have been added, plot and show the graphs | |
// YOUR CODE HERE | |
wCircleR5.Plot(); | |
wCircleR5.show(); | |
wCircle.Plot(); | |
wCircle.show(); | |
wButterfly.Plot(); | |
wButterfly.show(); | |
return a.exec(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment