-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc.h
50 lines (46 loc) · 940 Bytes
/
misc.h
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
49
50
#include <string>
#include <vector>
#include <iostream>
#include <cmath>
#pragma once
using namespace std;
void printvecflt(vector<float> vecflt)
{
cout << "{ ";
for (float f : vecflt)
{
cout << f << ", ";
}
cout << " }" << endl;
}
void printvecint(vector<int> vecint)
{
cout << "{ ";
for (int i : vecint)
{
cout << i << ", ";
}
cout << " }" << endl;
}
float distance_points(vector<int> point1, vector<int> point2)
{
return sqrt(pow(abs(float(point2[1]) - float(point1[1])), 2) + pow(abs(float(point2[0]) - float(point2[1])), 2));
}
int compare_distance(vector<int> point1, vector<vector<int>> trianglepoints)
{
// chosen point, 3 triangle points
vector<float> distances;
for (int i = 0; i < distances.size(); i++)
{
distances.push_back(distance_points(point1, trianglepoints[i]));
}
int biggest;
for (int i = 1; i < 3; i++)
{
if (distances[i - 1] < distances[i])
{
biggest = i;
}
}
return biggest;
}