我正在尝试在 openscad 中创建一个风扇管道,将管道从圆形扁平化为椭圆形。有没有办法在openscad中做到这一点?如果没有,是否有任何其他编程方式来生成这种类型的 3d 模型?
谢谢丹尼斯
假设“椭圆”是指椭圆,则以下创建一个从圆形到椭圆的实心锥形:
Delta=0.01;
module connector (height,radius,eccentricity) {
hull() {
linear_extrude(height=Delta)
circle(r=radius);
translate([0,0,height - Delta])
linear_extrude(height=Delta)
scale([1,eccentricity])
circle(r=radius);
}
}
connector(20,6,0.6);
你可以通过减去一个较小的版本来制作管子:
module tube(height, radius, eccentricity=1, thickness) {
difference() {
connector(height,radius,eccentricity);
translate([0,0,-(Delta+thickness)])
connector(height + 2* (Delta +thickness) ,radius-thickness, eccentricity);
}
}
tube(20,8,0.6,2);
但壁厚不会均匀。要制作统一的墙,请使用 minkowski 添加墙:
module tube(height, radius, eccentricity=1, thickness) {
difference() {
minkowski() {
connector(height,radius,eccentricity);
cylinder(height=height,r=thickness);
}
translate([0,0,-(Delta+thickness)])
connector(height + 2* (Delta +thickness) ,radius, eccentricity);
}
}
tube(20,8,0.6,2);
还有另一种方法是使用 linear_extrude() 的“scale”参数。它通过该值在拉伸高度上缩放 2D 形状。比例可以是标量或向量“ (文档)。使用带有 x 和 y 比例因子的向量,您可以获得所需的修改:
d = 2; // height of ellipsoid, diameter of bottom circle
t = 0.25; // wall thickness
w = 4; // width of ellipsoid
l = 10; // length of extrusion
module ellipsoid(diameter, width, height) {
linear_extrude(height = height, scale = [width/diameter,1]) circle(d = diameter);
}
difference() {
ellipsoid(d,w,l);
ellipsoid(d-2*t,w-2*t,l);
}
我喜欢 Chris Wallace 的回答,但 Minkwoski 中有一个错误,应该是h=Delta
。
module tube(height, radius, eccentricity=1, thickness) {
difference() {
minkowski() {
connector(height,radius,eccentricity);
cylinder(h=Delta,r=thickness);
}
translate([0,0,-(Delta+thickness)])
connector(height + 2* (Delta +thickness) ,radius, eccentricity);
}
}
tube(20,8,0.6,2);
我不知道直接做的方法,但我可以想象用一系列堆叠的切片来近似它。
从一个圆圈开始,当您将切片添加到堆栈中时,有一个循环将比例因子从圆形平滑地更改为椭圆形。这会给你一个阶梯状的表面。如果这是用于 3D 打印应用程序,如果您使切片厚度与层高相同,您甚至可能不会注意到。