[994d6d]: inst / ocframe / PlotDiagrams.m  Maximize  Restore  History

Download this file

199 lines (183 with data), 6.5 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
 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
## Copyright (C) 2010 Johan Beke
##
## This software is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or (at
## your option) any later version.
##
## This software is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this software; see the file COPYING. If not, see
## <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} {} PlotDiagrams (@var{joints}, @var{members}, @var{dist}, @var{point}, @var{MemF}, @var{diagram}, @var{divisions}, @var{scale})
##
## This function plots the internal forces for all members. The force to be plotted can be selected with @var{diagram}
## which will be "M", "S" or "N" for the moment, shear or normal forces.
##
## Input parameters are similar as with SolveFrame and PlotFrame.
## @end deftypefn
function PlotDiagrams(joints,members,dist,point,MemF,diagram,divisions,scale)
%during development some errors occured on windows: http://wiki.octave.org/wiki.pl?OctaveForWindows see oct2mat and plot package
%% scaling goes wrong when there al members have end moment 0
if (nargin < 6)
usage("PlotDiagrams(joints,members,dist,point,MemF,diagram,scale) use the help command for more information");
end
if (nargin<7)
divisions=20;
end
if (diagram=="M")
if (nargin<8)
scale=2/max(max(abs(MemF(:,[3,6]))));
end
%plot frame first
newplot();
clf();
hold off;
set (gca(), "dataaspectratio", [1,1,1]);
hold on;
for i=1:rows(members)
Near=members(i,1); %near joint
Far=members(i,2); %far joint
%make line from near to far joint
line([joints(Near,1),joints(Far,1)],[joints(Near,2),joints(Far,2)],"color","blue");
end
%plot coord numbers
for i=1:rows(joints)
text(joints(i,1),joints(i,2),int2str(i)); %'color','blue'
hold on;
end
%plot member numbers
for i=1:rows(members)
text((joints(members(i,1),1)+joints(members(i,2),1))/2,(joints(members(i,1),2)+joints(members(i,2),2))/2,int2str(i),'color','blue');
end
for i=1:rows(members)
[x,M]=MSNForces(joints,members,dist,point,MemF,i,divisions);
%finding maximum and minimum
[M_max,x_max]=max(M);
[M_min,x_min]=min(M);
%scale example scale factor: 2/max moment
M=M.*scale; % moment curve consistent with deformation
Near=members(i,1);
Far=members(i,2);
%transformation to real member position!
L=sqrt((joints(Near,1)-joints(Far,1))^2+(joints(Near,2)-joints(Far,2))^2);
l=(joints(Far,1)-joints(Near,1))/L;
m=(joints(Far,2)-joints(Near,2))/L;
T=[l,m;-m,l]';
for i=1:columns(x)
temp=T*[x(i);M(i)]; %rotation
x(i)=temp(1)+joints(Near,1); %displacement x and y
M(i)=temp(2)+joints(Near,2);
end
plot(x,M,'r-');
%plot max and min
text(x(x_max),M(x_max),num2str(M_max,'%g'),'color','red');
text(x(x_min),M(x_min),num2str(M_min,'%g'),'color','red');
end
end
if (diagram=="S")
if (nargin<8)
scale=2/max(max(abs(MemF(:,[2,5]))));
end
%plot frame first
newplot();
clf();
hold off;
set (gca(), "dataaspectratio", [1,1,1]);
hold on;
for i=1:rows(members)
Near=members(i,1); %near joint
Far=members(i,2); %far joint
%make line from near to far joint
line([joints(Near,1),joints(Far,1)],[joints(Near,2),joints(Far,2)],"color","blue");
end
%plot coord numbers
for i=1:rows(joints)
text(joints(i,1),joints(i,2),int2str(i)); %'color','blue'
hold on;
end
%plot member numbers
for i=1:rows(members)
text((joints(members(i,1),1)+joints(members(i,2),1))/2,(joints(members(i,1),2)+joints(members(i,2),2))/2,int2str(i),'color','blue');
end
for i=1:rows(members)
[x,M,S]=MSNForces(joints,members,dist,point,MemF,i,divisions);
%finding maximum and minimum
[S_max,x_max]=max(S);
[S_min,x_min]=min(S);
%scale example scale factor: 2/max moment
S=S.*scale;
Near=members(i,1);
Far=members(i,2);
%transformation to real member position!
L=sqrt((joints(Near,1)-joints(Far,1))^2+(joints(Near,2)-joints(Far,2))^2);
l=(joints(Far,1)-joints(Near,1))/L;
m=(joints(Far,2)-joints(Near,2))/L;
T=[l,m;-m,l]';
for i=1:columns(x)
temp=T*[x(i);S(i)];
x(i)=temp(1)+joints(Near,1);
S(i)=temp(2)+joints(Near,2);
end
plot(x,S,'r-');
%plot max and min
text(x(x_max),S(x_max),num2str(S_max,'%g'),'color','red');
text(x(x_min),S(x_min),num2str(S_min,'%g'),'color','red');
end
end
if (diagram=="N")
if (nargin<8)
scale=2/max(max(abs(MemF(:,[1,4]))));
end
%plot frame first
newplot();
clf();
hold off;
set (gca(), "dataaspectratio", [1,1,1]);
hold on;
for i=1:rows(members)
Near=members(i,1); %near joint
Far=members(i,2); %far joint
%make line from near to far joint
line([joints(Near,1),joints(Far,1)],[joints(Near,2),joints(Far,2)],"color","blue");
end
%plot coord numbers
for i=1:rows(joints)
text(joints(i,1),joints(i,2),int2str(i)); %'color','blue'
hold on;
end
%plot member numbers
for i=1:rows(members)
text((joints(members(i,1),1)+joints(members(i,2),1))/2,(joints(members(i,1),2)+joints(members(i,2),2))/2,int2str(i),'color','blue');
end
for i=1:rows(members)
[x,M,S,N]=MSNForces(joints,members,dist,point,MemF,i,divisions);
%finding maximum and minimum
[N_max,x_max]=max(N);
[N_min,x_min]=min(N);
%scale example scale factor: 2/max moment
N=N.*scale;
Near=members(i,1);
Far=members(i,2);
%transformation to real member position!
L=sqrt((joints(Near,1)-joints(Far,1))^2+(joints(Near,2)-joints(Far,2))^2);
l=(joints(Far,1)-joints(Near,1))/L;
m=(joints(Far,2)-joints(Near,2))/L;
T=[l,m;-m,l]';
for i=1:columns(x)
temp=T*[x(i);N(i)];
x(i)=temp(1)+joints(Near,1);
N(i)=temp(2)+joints(Near,2);
end
plot(x,N,'r-');
%plot max and min
text(x(x_max),N(x_max),num2str(N_max,'%g'),'color','red');
text(x(x_min),N(x_min),num2str(N_min,'%g'),'color','red');
end
end
end

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks