-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
51 lines (46 loc) · 1.24 KB
/
main.cpp
File metadata and controls
51 lines (46 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include<fstream>
#include<iomanip>
#include <vector>
#include "ConvexHull.h"
int main (int argc, char * const argv[]) {
ofstream outfile;
ifstream infile;
string inputfilename;
double pta, ptb; double ptc;
Point p1;
vector<Point> InputPoints;
int npts; int nd;
cout << "Number of dimensions?" << endl;
cin >> nd;
cout << "Generate how many points?" << endl;
cin >> npts;
//outfile.open("/Users/Williams/Software/C/Tasks/Task2/IO/input.txt");
outfile.open("HullInput.txt");
for (int i=0; i < npts; i++) {
if(nd ==2) {
pta = ((double) rand() / (RAND_MAX))*10.0;
ptb = ((double) rand() / (RAND_MAX))*10.0;
Point p1(pta,ptb);
p1.output(&outfile,2);
InputPoints.push_back(p1);
} else {
pta = ((double) rand() / (RAND_MAX))*10.0;
ptb = ((double) rand() / (RAND_MAX))*10.0;
ptc = ((double) rand() / (RAND_MAX))*10.0;
Point p1(pta,ptb,ptc);
p1.output(&outfile,3);
InputPoints.push_back(p1);
}
}
outfile.close();
//construct hull
ConvexHull test_new(nd);
test_new.wrap(InputPoints);
//output file
//outfile.open("/Users/Williams/Software/C/Tasks/Task2/IO/output.txt");
outfile.open("HullOutput.txt");
test_new.outputpoints(&outfile);
outfile.close();
return 0;
}