哈工大材料力学上机大作业文档格式.docx
《哈工大材料力学上机大作业文档格式.docx》由会员分享,可在线阅读,更多相关《哈工大材料力学上机大作业文档格式.docx(22页珍藏版)》请在冰豆网上搜索。
![哈工大材料力学上机大作业文档格式.docx](https://file1.bdocx.com/fileroot1/2023-1/22/aff2d101-9e06-46fd-8c8e-5c1f670913d9/aff2d101-9e06-46fd-8c8e-5c1f670913d91.gif)
二.计算
当绘制完某一图形后,点击“开始计算”按钮,即可计算出面积、静矩、形心坐标、惯性矩、惯性半径、惯性积、主惯性轴角度、主惯性矩、形心主惯性轴角度、形心主惯性矩等16个几何量。
欲重新开始,可点击“重置”按钮。
点击任意按钮后屏幕下方都会有相应的提示。
三.外部图形
首先将所需图形大小修改为500×
470,格式为jpg,命名为“截面”,并将其保存在程序根目录下,可载入外部图形以精确计算其各个量。
源程序:
注:
以下为form1的代码
PrivateXAsSingle,YAsSingle,XpAsSingle,YpAsSingle
PrivateNAsInteger,NumAsInteger,MAsInteger,missN(10000)AsInteger,jAsInteger,kAsInteger
PrivatestepXAsSingle,stepYAsSingle,StepAsSingle
PrivateP(1To30000,1To2)AsSingle,Q1AsSingle,Q2AsSingle
PrivateminXAsSingle,maxXAsSingle,minYAsSingle,maxYAsSingle
PrivaterunXAsSingle,runYAsSingle
PrivateX1AsSingle,Y1AsSingle,X2AsSingle,Y2AsSingle
PrivateLxAsSingle,LyAsSingle
PrivateLpoint(200)AsSingle,LpointmemoryAsSingle
PrivateNnAsInteger,RrAsSingle
PrivateXxAsSingle,YyAsSingle,TAsInteger,AngAsSingle
PrivateSxAsSingle,SyAsSingle,AxAsSingle,AyAsSingle
PrivateShapeCenterXAsSingle,ShapeCenterYAsSingle
PrivateIxAsSingle,IyAsSingle,IxCAsSingle,IyCAsSingle,IxyCAsSingle
PrivateRxAsSingle,RyAsSingle
PrivateIxyAsSingle,IyxAsSingle,LIxyAsSingle,LIyxAsSingle
PrivateAngleAsSingle
PrivateIminAsSingle,ImaxAsSingle
PrivateAngleCAsSingle
PrivateIcminAsSingle,IcmaxAsSingle
PrivateCanAsInteger
PrivateMsgAsInteger
PrivateMoveNAsLong,MoveMAsLong,DeciderAsInteger,ShapeAsInteger
PrivateAAsSingle,BAsSingle,CAsSingle,EAsSingle,FAsSingle
PrivateUsualAsInteger
PrivateSubPaintNnRr()
M=0:
N=1
Fori=0ToNn-1
Text1.Text=Xx+Rr*Cos(Ang*3.1415926535898/180+2*3.1415926535898/Nn*i)
Text2.Text=Yy+Rr*Sin(Ang*3.1415926535898/180+2*3.1415926535898/Nn*i)
Command1_Click
Next
EndSub
PrivateSubShorten(AAsSingle,BAsSingle,CAsSingle)
i=0
DoWhileA>
=10
A=A/10
i=i+1
Loop
B=Format(A,"
0.00"
)
C=i
PrivateSubCalculate()
ShapeCenterY=CLng(Sx/Ax)
ShapeCenterX=CLng(Sy/Ay)
IfIx=IyAndIxy>
0Then
Angle=-3.1415926535898/4
ElseIfIx=IyAndIxy<
Angle=3.1415926535898/4
ElseIfIx=IyAndIxy=0Then
Angle=0
Else
Angle=0.5*Atn(-2*Ixy/(Ix-Iy))
EndIf
Rx=Sqr(Ix/Ax)
Ry=Sqr(Iy/Ay)
Imin=(Ix+Iy)/2-Sqr((Ix-Iy)^2/4+Ixy^2)
Imax=(Ix+Iy)/2+Sqr((Ix-Iy)^2/4+Ixy^2)
IxC=Ix-ShapeCenterY^2*Ax
IyC=Iy-ShapeCenterX^2*Ay
IxyC=Ixy-ShapeCenterX*ShapeCenterY*Ax
Icmin=(IxC+IyC)/2-Sqr((IxC-IyC)^2/4+IxyC^2)
Icmax=(IxC+IyC)/2+Sqr((IxC-IyC)^2/4+IxyC^2)
IfIxC=IyCAndIxyC>
AngleC=-3.1415926535898/4
ElseIfIxC=IyCAndIxyC<
AngleC=3.1415926535898/4
ElseIfIxC=IyCAndIxyC=0Then
anflec=0
AngleC=0.5*Atn(-2*IxyC/(IxC-IyC))
PrivateSubOutput()
Picture1.Line(Sy/Ay+1000,6000-Sx/Ax)-(Sy/Ay+1000,6000),RGB(255,121,121)
Picture1.Line(Sy/Ay+1000,6000-Sx/Ax)-(1000,6000-Sx/Ax),RGB(255,121,121)
Label6.Left=Sy/Ay+100+1000:
Label6.Top=5775+20
Label6.Caption="
X="
&
ShapeCenterX
Label6.Visible=True
Label7.Left=1080:
Label7.Top=6000-(Sx/Ax-20)
Label7.Caption="
Y="
ShapeCenterY
Label7.Visible=True
Text3.Text=ShapeCenterX:
Text4.Text=ShapeCenterY
CallShorten(Ax,E,F)
Text5.Text=E&
"
×
"
10&
^"
F
CallShorten(Sx,E,F)
Text6.Text=E&
CallShorten(Sy,E,F)
Text7.Text=E&
CallShorten(Ix,E,F)
Text8.Text=E&
CallShorten(Iy,E,F)
Text9.Text=E&
Text10.Text=CLng(Rx*10)/10:
Text11.Text=CLng(Ry*10)/10
CallShorten(Ixy,E,F)
Text12.Text=E&
Text13.Text=Format(Angle*180/3.1415926535898,"
0.0"
CallShorten(Imin,E,F)
Text14.Text=E&
CallShorten(Imax,E,F)
Text15.Text=E&
Text16.Text=Format(AngleC*180/3.1415926535898,"
CallShorten(Icmin,E,F)
Text17.Text=E&
Text18.Text=Icmax
CallShorten(Icmax,E,F)
Text18.Text=E&
PrivateSubSort()
Fori=1Toj-2
Fork=i+1Toj-1
IfLpoint(k)<
Lpoint(i)Then
Lpointmemory=Lpoint(i)
Lpoint(i)=Lpoint(k)
Lpoint(k)=Lpointmemory
EndIf
Next
PrivateSubCloseLine()
Picture1.Circle(Q1+1000,6000-Q2),90,RGB(255,255,255)
Label1.Caption="
输入第"
N+1&
点坐标:
P(N,1)=Q1:
P(N,2)=Q2
Picture1.Line(P(N-1,1)+1000,6000-P(N-1,2))-(Q1+1000,6000-Q2),RGB(0,0,255)
missN(Num)=N
M=0
N=N+1
Num=Num+1
Decider=0
Label21.Caption="
点击计算“截面的几何量”按钮开始计算,或单击下一点以绘制下一图形的起点"
PrivateSubGetstepXstepY()
minY=P(1,2)
Fori=2ToN-1
IfP(i,2)<
minYThen
minY=P(i,2)
Else
maxY=P(1,2)
IfP(i,2)>
maxYThen
maxY=P(i,2)
stepY=(maxY-minY)/Step
minX=P(1,1)
IfP(i,1)<
minXThen
minX=P(i,1)
maxX=P(1,1)
IfP(i,1)>
maxXThen
maxX=P(i,1)
stepX=(maxX-minX)/Step
PrivateSubGetLxLIxy()
j=1:
Lx=0:
LIxy=0
Fori=1ToN-1
Can=0
Fork=1ToNum-1
Ifi=missN(k)Then
Can=1
IfCan=0Then
If(P(i,2)-runY)*(P(i+1,2)-runY)=0Then
runY=runY+stepY/1000
If(P(i,2)-runY)*(P(i+1,2)-runY)<
X1=P(i,1):
Y1=P(i,2):
X2=P(i+1,1):
Y2=P(i+1,2)
Lpoint(j)=X1+(X2-X1)*(runY-Y1)/(Y2-Y1)
j=j+1
Can=0
CallSort
Fori=1Toj-1Step2
Lx=Lx+Lpoint(i+1)-Lpoint(i)
LIxy=LIxy+0.5*(Lpoint(i+1)^2-Lpoint(i)^2)
PrivateSubPaintX()
Fori=1Toj-2Step2
Picture1.Line(Lpoint(i)+1000,6000-runY)-(Lpoint(i+1)+1000,6000-(runY+stepY)),RGB(255,113,116),BF
PrivateSubGetAxSxIx()
Ax=Ax+Lx*stepY
Sx=Sx+(runY+0.5*stepY)*(Lx*stepY)
Ix=Ix+(runY+0.5*stepY)^2*(Lx*stepY)
Ixy=Ixy+(runY+0.5*stepY)*(LIxy*stepY)
PrivateSubGetLyLIyx()
Ly=0:
LIyx=0
If(P(i,1)-runX)*(P(i+1,1)-runX)=0Then
runX=runX+stepX/1000
If(P(i,1)-runX)*(P(i+1,1)-runX)<
Lpoint(j)=Y1+(Y2-Y1)*(runX-X1)/(X2-X1)
Ly=Ly+Lpoint(i+1)-Lpoint(i)
LIyx=LIyx+0.5*(Lpoint(i+1)^2-Lpoint(i)^2)
PrivateSubPaintY()
Picture1.Line(runX+1000,6000-Lpoint(i))-(runX+stepX+1000,6000-Lpoint(i+1)),RGB(118,89,255),BF
PrivateSubGetAySyIy()
Ay=Ay+Ly*stepX
Sy=Sy+(runX+0.5*stepX)*(Ly*stepX)
Iy=Iy+(runX+0.5*stepX)^2*(Ly*stepX)
Iyx=Iyx+(runX+0.5*stepX)*(LIyx*stepX)
PrivateSubCommand1_Click()'
画线
Text1.Text=CLng(Text1.Text*10)/10:
Text2.Text=CLng(Text2.Text*10)/10
Xp=Text1.Text:
Yp=Text2.Text
X=Xp:
Y=Yp
P(N,1)=X:
P(N,2)=Y
IfM=0Then
Q1=X:
Q2=Y
Picture1.PSet(Q1+1000,6000-Q2),RGB(0,0,255)
Picture1.Circle(Q1+1000,6000-Q2),90,RGB(180,255,180)
IfShape=0Then
Decider=0
Decider=1
ElseIfM<
>
Picture1.Line(P(N-1,1)+1000,6000-P(N-1,2))-(P(N,1)+1000,6000-P(N,2)),RGB(0,0,255)
M=1
Command2.Enabled=False
Command4.Enabled=False
Command5.Enabled=False
Command9.Enabled=False
点击以输入下一个点的坐标.或点击当前图形起点(淡绿色圆圈内)以封闭图形"
PrivateSubCommand10_Click()
Nn=Text19.Text
Rr=Text20.Text
Xx=Text22.Text
Yy=Text23.Text
Ang=Text21.Text
CallPaintNnRr
CallCloseLine
Command2_Click
Command10.Enabled=False
PrivateSubCommand2_Click()
N=N-1
CallGetstepXstepY
runX=minX:
runY=minY
Ax=0:
Sx=0:
Ix=0
DoWhilerunY<
maxY
CallGetLxLIxy'
Lx为与x轴平行的L
CallPaintX
CallGetAxSxIx
runY=runY+stepY
Ay=0:
Sy=0:
Iy=0
DoWhilerunX<
maxX
CallGetLyLIyx
CallPaintY
CallGetAySyIy
runX=runX+stepX
CallCalculate
CallOutput
Command1.Enabled=False
单击“重置程序”按钮以初始化程序"
Form1.Width=9750
PrivateSubCommand3_Click()
Form_Activate
PrivateSubCommand4_Click()
Shape=0
进入直线模式"
IfT=1Then
Frame6.Visible=False
T=0
Command1.Enabled=True
PrivateSubCommand5_Click()
Shape=1
进入曲线模式"
Command