summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcomputeTrussCost.m16
-rwxr-xr-xtruss_solver.m13
-rwxr-xr-xweakestMember.m13
3 files changed, 25 insertions, 17 deletions
diff --git a/computeTrussCost.m b/computeTrussCost.m
index df7daad..e3fed5d 100755
--- a/computeTrussCost.m
+++ b/computeTrussCost.m
@@ -1,15 +1,5 @@
-function [ cost ] = computeTrussCost( C, X, Y )
+function [ cost ] = computeTrussCost( C, D )
cost = 0;
- [ j, m ] = size(C);
- cost = cost + 10*j;
- for i = 1:m
- memb = C(:,i);
- points = [X(memb == 1); Y(memb == 1)];
- d = dist(points(:,1), points(:,2));
- cost = cost + d;
- end
+ [ j, ~ ] = size(C);
+ cost = cost + 10*j + sum(D);
end
-
-function [ d ] = dist(p1, p2)
- d = sqrt((p1(1)-p2(1))^2+(p1(2)-p2(2))^2);
-end \ No newline at end of file
diff --git a/truss_solver.m b/truss_solver.m
index 4a7a1aa..50086f3 100755
--- a/truss_solver.m
+++ b/truss_solver.m
@@ -8,6 +8,13 @@ forces(abs(forces) < 0.00001) = 0;
[j, m] = size(C);
Ln = L(L~=0);
+
+D = memberDistances(C, X, Y);
+
+cost = computeTrussCost(C,D);
+weakest = weakestMember(D,forces);
+ml = maxLoad(forces,L,D,weakest);
+
for i = 1:length(Ln)
fprintf('Load: %.3f N\n', abs(Ln(i)));
@@ -21,7 +28,7 @@ for i = 1:length(forces)-m
fprintf('r%d: %.3f\n', i, forces(m+i));
end
-cost = computeTrussCost(C, X, Y);
fprintf('Cost of truss: $%d\n', round(cost));
-
-fprintf('Theoretical max load/cost ratio in N/$: %.4f\n', abs(sum(L))/cost); \ No newline at end of file
+fprintf('Theoretical max load is %.4f\n', ml);
+fprintf('Theoretical max load/cost ratio in N/$: %.4f\n', ml/cost);
+fprintf('First member to break is member %d\n', weakest); \ No newline at end of file
diff --git a/weakestMember.m b/weakestMember.m
index 60485c9..6b67d64 100755
--- a/weakestMember.m
+++ b/weakestMember.m
@@ -1,3 +1,14 @@
-function [ idx ] = weakestMember(C, X, Y, T)
+function [ idx ] = weakestMember(D, T)
+ unit = T(1:length(T)-3)/norm(T(1:length(T)-3));
+ resist = breaking(D);
+ p = unit ./ resist;
+ p(p > 0) = 0;
+ a = 1:length(D);
+ [~,i] = max(abs(p));
+ idx = a(i);
+end
+
+function [ F ] = breaking(L)
+ F = 369.9 ./ (abs(L) .^ 1.465);
end \ No newline at end of file