forked from Donut-the-1st/Truss-Solver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodeThiccnessFinder.m
46 lines (44 loc) · 1.99 KB
/
nodeThiccnessFinder.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
function [trussGraphOut] = nodeThiccnessFinder(trussGraph)
%nodeThiccnessFinder does stuff to find what balt to use
% https://scryfall.com/card/sok/84/one-with-nothing
[compressionTable, tensionTable, ~, ~] = generateTrussTables();
% % Old nodeThiccnessFinder Benchmark: 0.449s per call
% for i = 1:length(trussGraph.Nodes.NodeID)
% nodesICareAboutRightNow = trussGraph.Edges(any(trussGraph.Edges.EndNodes == i, 2),:);
% trussGraph.Nodes.("Joint Thickness")(i) = 0;
% for j = 1:length(nodesICareAboutRightNow.("Member Length"))
% if nodesICareAboutRightNow.("Force in member")(j) <= 0
% trussGraph.Nodes.("Joint Thickness")(i) =...
% trussGraph.Nodes.("Joint Thickness")(i) +...
% compressionTable.("Joint Thickness")(...
% contains(compressionTable.("Member Type"),nodesICareAboutRightNow.("Beam type"){j}));
% else
% trussGraph.Nodes.("Joint Thickness")(i) =...
% trussGraph.Nodes.("Joint Thickness")(i) +...
% tensionTable.("Joint Thickness")(...
% contains(tensionTable.("Member Type"),nodesICareAboutRightNow.("Beam type"){j}));
% end
% end
% end
% trussGraphOut = trussGraph;
% New nodeThiccnessFinder
edges = trussGraph.Edges;
numNodes = trussGraph.numnodes;
nodeThiccness = zeros(numNodes,1);
for i = 1:numNodes
edgesTemp = edges(any(edges.EndNodes == i, 2),:)
curNodeThicc = 0;
for j = 1:height(edgesTemp)
if edgesTemp.("Force in member")(j) <= 0
curNodeThicc = curNodeThicc + compressionTable.("Joint Thickness")...
(contains(compressionTable.("Member Type"),edgesTemp.("Beam type"){j}));
else
curNodeThicc = curNodeThicc + tensionTable.("Joint Thickness")...
(contains(tensionTable.("Member Type"),edgesTemp.("Beam type"){j}));
end
end
nodeThiccness(i) = curNodeThicc;
end
trussGraph.Nodes.("Joint Thickness") = nodeThiccness;
trussGraphOut = trussGraph;
end