看原文吧!
//Information:
//created by : 胡海彬 E_mail:sxhuhaibin@sohu.com
//概要:闭合端部弹簧,用方程曲线建立曲线,然后用管体建模,修改变量值,可改变弹簧的形状.
//变量:Active_coils为中间螺旋匝数
//Wire_dia为弹簧线径
//Dir为螺旋旋转方向
//Free_length为弹簧自由长度
//OD为弹簧外直径
//Total_coils为螺旋总匝数.
//注意:分三段建立曲线,第一段用t,xt1,yt1,zt1建立,第二段用t,xt,yt,zt建立,第三段用t,xt2,yt2,zt2建立.
//另外,管体的Out dimmeter为Wire_dia.
Active_coils=5
Wire_dia=6
Dir=1
Free_length=120
OD=50
Total_coils=7
Closed_height=Wire_dia+0.2
angle_offset=(Total_coils-trnc(Total_coils))*360
angle_offset_init=(Total_coils-Active_coils)/2*360
height=Free_length-Wire_dia-Closed_height*2
pitch=height/Active_coils
exp=(pitch/Closed_height*(Total_coils-Active_coils)/2)
radius=(OD-Wire_dia)/2
t=1
xt=cos(Dir*360*Active_coils*t+angle_offset_init)*radius
xt1=cos(Dir*360*(Total_coils-Active_coils)/2*t)*radius
xt2=cos(-Dir*360*(Total_coils-Active_coils)/2*t+angle_offset)*radius
yt=sin(Dir*360*Active_coils*t+angle_offset_init)*radius
yt1=sin(Dir*360*(Total_coils-Active_coils)/2*t)*radius
yt2=sin(-Dir*360*(Total_coils-Active_coils)/2*t+angle_offset)*radius
zt=t*height+Closed_height+Wire_dia/2
zt1=(t^(exp)*Closed_height)+Wire_dia/2
zt2=(-t^(exp)*Closed_height)+height+Closed_height*2+Wire_dia/2 |