-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.cpp
More file actions
63 lines (53 loc) · 1.21 KB
/
Copy pathnode.cpp
File metadata and controls
63 lines (53 loc) · 1.21 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
#include "node.h"
#include <QtCore/qmath.h>
#include <QPoint>
#include <QDebug>
Node::Node()
{
}
void Node::setNNodes(int n)
{
this->nNodes = n;
assignCoordinates();
}
void Node::setNodes(Node n)
{
this->nodeList = n.nodeList;
this->nodemap = n.nodemap;
this->nNodes = n.nNodes;
}
QPoint Node::getNode(int nodeIndex)
{
return(this->nodemap[nodeIndex]);
}
void Node::assignCoordinates()
{
//get radius of bounding circle
double radius;
int r;
radius = (2*32*nNodes)/(2*3.14159);
if (radius >= 100)
{
r = (int)radius;
}
else
{
r = 100;
}
//calculate angle at which the nodes lie
double angle;
angle = 360.0 / nNodes;
qDebug() << "Calculated Step angle = " << angle;
//Center QPoint
QPoint center(0,0);
int xCod, yCod;
double theta;
for (int i = 0, theta = 0.0; i < nNodes; i++, theta += angle)
{
xCod = (int) (qSin(0.0174532925 * theta) * radius);
yCod = (int) (qCos(0.0174532925 * theta) * radius);
this->nodeList.push_back(QPoint(xCod, yCod));
this->nodemap.insert(i,QPoint(xCod, yCod));
qDebug() << "Coordinates for " << i << ": " << xCod << ", " << yCod;
}
}