Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.cpp
More file actions
Latest commit
83 lines (71 loc) · 1.18 KB
/
Copy pathnode.cpp
File metadata and controls
83 lines (71 loc) · 1.18 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include"node.h"
Node::Node()
{
}
Node::Node(double xVal, double yVal)
{
x = xVal;
y = yVal;
}
Node::~Node()
{
}
doubleNode::getX()
{
return x;
}
doubleNode::getY()
{
return y;
}
doubleNode::getAngle()
{
return angle;
}
voidNode::calcAngle()
{
if (y == 0)
{
if (x > 0)
{
angle = 5;
}
elseif (x == 0)
{
angle = 0;
}
else
{
angle = 0;
}
}
else
{
if (x > 0)
{
angle = y / x;
}
else
{ //X is negative, we'll make it positive and larger than the rest
angle = ((x / y) * -1) + 1000; //so we know it's in the 2nd quadrant when we sort by angle
}
}
}
bool Node::operator<(Node& thatNode) const
{//For sorting, based on the Y values
return (angle < thatNode.getAngle());
}
voidNode::setX(double xVal)
{
x = xVal;
}
voidNode::setY(double yVal)
{
y = yVal;
}
voidNode::adjustCoords(double xPos, double yPos)
{
//The node for 0,0 has been chosen, now we have to adjust all the other nodes to align with its previous coords
x = x - xPos;
y = y - yPos;
}