-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathNode.m
152 lines (135 loc) · 4.85 KB
/
Node.m
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
classdef Node
%Node Class is used for Truss2D.m
properties
x
y
noDirectNode
DirectNode
DirectNodeLength
DirectNodeAngle
DirectNodeZone
DirectNodeLayer
DirectNodeSectionIndex
DirectNodeSectionPriority
noOutNode
OutNode
OutNodeLength
OutNodeAngle
OutNodeZone
OutNodeLayer
OutNodeIndeLayer
OutNodeSectionIsUsed
OutNodeSectionIndex
OutNodeSectionPriority
noSection
noEachSection
noIndeEachSection
layerZone
indeLayerZone
end
methods
function obj = Node(x,y,noSection)
obj.noDirectNode = 0;
obj.DirectNode = 0;
obj.noOutNode = 0;
obj.OutNode = 0;
obj.x = x;
obj.y = y;
obj.noSection = noSection;
obj.noEachSection = zeros(1,noSection);
obj.noIndeEachSection = zeros(1,noSection);
obj.layerZone=zeros(noSection,1);
obj.indeLayerZone=zeros(noSection,1);
end
function obj = AddDirectNode(obj,index,x,y)
global PRB;
isExist = 0;
for i=1:obj.noDirectNode
if obj.DirectNode(i)==index
isExist = 1;
end
end
tLength = norm([(obj.x-x) (obj.y-y)]);
if isExist == 0 && tLength < PRB.dv.lengthMax;
now = obj.noDirectNode + 1;
obj.noDirectNode = now;
obj.DirectNode(now) = index;
obj.DirectNodeLength(now) = tLength;
angle = getAngle([obj.x obj.y],[x y]);
zone=ceil(angle*obj.noSection/360);
obj.DirectNodeAngle(now) = angle;
obj.DirectNodeZone(now) = zone;
obj.noEachSection(zone) = obj.noEachSection(zone)+1;
obj.layerZone(zone,obj.noEachSection(zone))=obj.DirectNodeLength(now);
end
end
function obj = AddOutNode(obj,index,x,y)
global PRB;
isExist = 0;
for i=1:obj.noOutNode
if obj.OutNode(i)==index
isExist = 1;
end
end
tLength = norm([(obj.x-x) (obj.y-y)]);
if isExist == 0
for i=1:obj.noDirectNode
if obj.DirectNode(i)==index
isExist = 1;
end
end
if isExist == 0 && tLength < PRB.dv.lengthMax;
now = obj.noOutNode + 1;
obj.noOutNode = now;
obj.OutNode(now) = index;
obj.OutNodeLength(now) = tLength;
angle = getAngle([obj.x obj.y],[x y]);
zone=ceil(angle*obj.noSection/360);
obj.OutNodeAngle(now) = angle;
obj.OutNodeZone(now) = zone;
obj.noEachSection(zone) = obj.noEachSection(zone)+1;
obj.layerZone(zone,obj.noEachSection(zone))=obj.OutNodeLength(now);
obj.noIndeEachSection(zone) = obj.noIndeEachSection(zone)+1;
obj.indeLayerZone(zone,obj.noIndeEachSection(zone))=obj.OutNodeLength(now);
end
end
end
function obj = SpectDirectNode(obj,DirectNodeIndex,crossSectionIndex,crossSectionPriority)
obj.DirectNodeSectionIndex(DirectNodeIndex) = crossSectionIndex;
obj.DirectNodeSectionPriority(DirectNodeIndex) = crossSectionPriority;
end
function obj = SpectOutNode(obj,OutNodeIndex,crossSectionIndex,crossSectionPriority,isIndeUsed)
obj.OutNodeSectionIndex(OutNodeIndex) = crossSectionIndex;
obj.OutNodeSectionPriority(OutNodeIndex) = crossSectionPriority;
obj.OutNodeSectionIsUsed(OutNodeIndex) = isIndeUsed;
end
function output = isHave(self,index)
output = 0;
for i=1:self.noDirectNode
if self.DirectNode(i)==index
output = 1;
end
end
end
end
end
function [angle]=getAngle(node1,node2)
tX=node2(1)-node1(1);
tY=node2(2)-node1(2);
if node1(1)<node2(1)&&node1(2)<node2(2)
%#1
angle=90-radtodeg(cart2pol(tX,tY));
elseif node1(1)<=node2(1)&&node1(2)>=node2(2)
%#2
angle=90-radtodeg(cart2pol(tX,tY));
elseif node1(1)>node2(1)&&node1(2)>node2(2)
%#3
angle=90-radtodeg(cart2pol(tX,tY));
else
%#4
angle=450-radtodeg(cart2pol(tX,tY));
end
if isnan(angle)
angle=360;
end
end