-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.cpp
77 lines (64 loc) · 1.06 KB
/
Node.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
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
/*
* Node.cpp
*
* Created on: Oct 3, 2012
* Author: jmonk
*/
#include "Node.h"
#include <string.h>
Node::Node(float x, float y, float z, float* data, int dataSize) {
this->x = x;
this->y = y;
this->z = z;
if (dataSize > 0) {
this->dataLength = dataSize;
this->datas = new float[dataSize];
for (int i = 0; i < dataSize; i++) {
if (data != NULL) {
this->datas[i] = data[i];
} else {
this->datas[i] = 0;
}
}
}
}
Node::~Node() {
delete[] this->datas;
}
float Node::getX() {
return x;
}
float Node::getY() {
return y;
}
float Node::getZ() {
return z;
}
void Node::move(float x, float y, float z) {
this->x += x;
this->y += y;
this->z += z;
}
void Node::setX(float newX) {
this->x = newX;
}
void Node::setY(float newY) {
this->y = newY;
}
void Node::setZ(float newZ) {
this->z = newZ;
}
float* Node::getData() {
return datas;
}
float Node::getData(int index) {
if (index < dataLength) {
return datas[index];
}
return -1;
}
void Node::setData(int index, float value) {
if (index < dataLength) {
datas[index] = value;
}
}