Repository navigation
Expand file tree
/
Copy pathsamsbrain.cpp
More file actions
61 lines (49 loc) · 1.52 KB
/
Copy pathsamsbrain.cpp
File metadata and controls
61 lines (49 loc) · 1.52 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
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <math.h>
using namespace std;
double degrees_to_radians (double deg) {
double rad = deg * (M_PI/180);
return rad;
}
double cot (double deg) {
if (deg == 0.0 || deg == 180.0) {
cout << "Error: Tangent of 0.0 and 180.0 degrees is zero.\nConsider adding a 0.01 to get results.\n";
exit(1);
}
double rad = degrees_to_radians(deg);
return 1/tan(rad);
}
int main() {
static double x1, x2;
static double z1, z2;
static double angle1, angle2;
cout << endl << "********** Sam's Brain **********" << endl;
cout << "You may enter numbers up to 3 decimals." << endl;
cout << "Angles MUST be exact. Read the angle on the left side." << endl;
cout << "Example: (123.4 / xxx.x)" << endl << endl;
cout << "Enter x1: ";
cin >> x1;
cout << endl;
cout << "Enter z1: ";
cin >> z1;
cout << endl;
cout << "Enter Angle 1: ";
cin >> angle1;
cout << endl;
cout << "Enter x2: ";
cin >> x2;
cout << endl;
cout << "Enter z2: ";
cin >> z2;
cout << endl;
cout << "Enter Angle 2: ";
cin >> angle2;
cout << endl;
double x = (z1 - z2 + cot(angle1) * x1 - cot(angle2) * x2) / (cot(angle1) - cot(angle2));
double z = -(cot(angle1)) * (x - x1) + z1;
cout << "Estimated x coordinate: " << x << endl;
cout << "Estimated z coordinate: " << z << endl;
cout << "Estimated x Nether coordinate: " << x / 8 << endl;
cout << "Estimated z Nether coordinate: " << z / 8 << endl;
return 0;
}