-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmath.cpp
51 lines (43 loc) · 1.14 KB
/
math.cpp
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
#include "iostream"
#include "cmath"
#include "Point.h"
#include "zPoint.h"
double length(Point A, Point B);
int main()
{
Point testPoint = Point(1, 2);
std::cout << testPoint << std::endl;
Point otherPoint = Point(3, 4);
std::cout << otherPoint << std::endl;
std::cout << (round(length(testPoint, otherPoint)*100))/100 << std::endl;
std::cout << "Test ==" << std::endl;
if (testPoint == otherPoint)
{
std::cout << "The Points are equal (incorrect)" << std::endl;
}
else
{
std::cout << "The Points are not equal (correct)" << std::endl;
}
std::cout << "Test !=" << std::endl;
if (testPoint != otherPoint)
{
std::cout << "The Points aren't equal (correct)" << std::endl;
}
else
{
std::cout << "The Points are equal (incorrect)" << std::endl;
}
std::cout << "Test +=" << std::endl;
testPoint += otherPoint;
std::cout << testPoint << std::endl;
std::cout << "Test 3d Points" << std::endl;
zPoint newTest = zPoint(1, 1, 1);
}
double length(Point A, Point B)
{
double newX = A.get_x() + B.get_x();
double newY = A.get_y() + B.get_y();
return sqrt(pow(newX, 2.0) +
pow(newY, 2.0));
}