在初中时期, 我们就学会了使用尺规来完成一些复杂的几何图形的作图和相关计算.
而在我们生活中,很多时候也是讲3维世界刻画到2维空间来描述和进行相关的设计计算.
所以2维和3维的在我们生活中本身就是相互补充的关系.
openscad是一个3维的构建工具, 我们可以通过3D的简单模型来创建大多数复杂的3D模型. 但这样缺乏了2维空间的计算魅力. 当然 openscad 也不能落下.
接下来让我们来看看 openscad 怎么处理2维和3维的关系.
- 线性拉升 – linear_extrude
n = 500;
h = 10;
step = 360/n;
points = [ for (t=[0:step:359.999]) [16*pow(sin(t),3), 13*cos(t) - 5*cos(2*t) - 2*cos(3*t) - cos(4*t)]];
linear_extrude(height=h)
polygon(points);
– 旋转拉伸 – rotate_extrude
$fa = 1;
$fs = 0.4;
wheel_radius = 12;
tyre_diameter = 6;
rotate_extrude(angle=360) {
translate([wheel_radius - tyre_diameter/2, 0])
circle(d=tyre_diameter);
}
- 线性扭曲拉伸 – linear_extrude 参数加强版
$fa = 1;
$fs = 0.4;
linear_extrude(height=50,center=true,twist=120,scale=1.5)
scale([2,1,1])
circle(d=10);
官网给了一个比较挑战性的模型, 大家有兴趣可以试着建模 。.[^ o ^].
—
官方源码:
use <vehicle_parts.scad>
$fa = 1;
$fs = 0.4;
// model parameters
d1=30;
d2=20;
d3=20;
d4=10;
d5=20;
w1=15;
w2=45;
w3=25;
h=14;
track=40;
// distances to lengths
l1 = d1;
l2 = d1 + d2;
l3 = d1 + d2 + d3;
l4 = d1 + d2 + d3 + d4;
l5 = d1 + d2 + d3 + d4 + d5;
// right side points
p0 = [0, w1/2];
p1 = [l1, w1/2];
p2 = [l2, w2/2];
p3 = [l3, w2/2];
p4 = [l4, w3/2];
p5 = [l5, w3/2];
// left side points
p6 = [l5, -w3/2];
p7 = [l4, -w3/2];
p8 = [l3, -w2/2];
p9 = [l2, -w2/2];
p10 = [l1, -w1/2];
p11 = [0, -w1/2];
// all points
points = [p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11];
// extruded body profile
linear_extrude(height=h)
polygon(points);
// canopy
translate([d1+d2+d3/2,0,h])
resize([d2+d3+d4,w2/2,w2/2])
sphere(d=w2/2);
// axles
l_front_axle = d1/2;
l_rear_axle = d1 + d2 + d3 + d4 + d5/2;
half_track = track/2;
translate([l_front_axle,0,h/2])
axle(track=track);
translate([l_rear_axle,0,h/2])
axle(track=track);
// wheels
translate([l_front_axle,half_track,h/2])
simple_wheel(wheel_width=10);
translate([l_front_axle,-half_track,h/2])
simple_wheel(wheel_width=10);
translate([l_rear_axle,half_track,h/2])
simple_wheel(wheel_width=10);
translate([l_rear_axle,-half_track,h/2])
simple_wheel(wheel_width=10);
// spoiler
use <naca.scad>
module car_spoiler() {
rotate([90,0,0])
naca_wing(span=50,chord=20,t=0.12,n=500,center=true);
translate([0,10,-15])
naca_wing(span=15,chord=15,t=0.12,n=500);
translate([0,-10,-15])
naca_wing(span=15,chord=15,t=0.12,n=500);
}
translate([l4+d5/2,0,25])
car_spoiler();
参考:
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容