curve - 如何在 OpenSCAD 中制作曲面片(立方体)?
问题描述
我怎样才能弯曲一张纸(立方体)?我想控制弯曲/曲线的角度。
例如
立方体([50,50,2]);
解决方案
您可以rotate_extrude()
使用参数角度的矩形。这需要 openscad 版本 2016.xx 或更高版本,请参阅文档。需要安装开发快照,见下载openscad
$fn= 360;
width = 10; // width of rectangle
height = 2; // height of rectangle
r = 50; // radius of the curve
a = 30; // angle of the curve
rotate_extrude(angle = a) translate([r, 0, 0]) square(size = [height, width], center = true);
看起来像这样:
曲线由半径和角度定义。我认为在此草图中使用其他尺寸(例如长度或 dh)更现实
并计算半径和角度
$fn= 360;
w = 10; // width of rectangle
h = 2; // height of rectangle
l = 25; // length of chord of the curve
dh = 2; // delta height of the curve
module curve(width, height, length, dh) {
// calculate radius and angle
r = ((length/2)*(length/2) - dh*dh)/(2*dh);
a = asin((length/2)/r);
rotate_extrude(angle = a) translate([r, 0, 0]) square(size = [height, width], center = true);
}
curve(w, h, l, dh);
编辑 30.09.2019:考虑 Cfreitas 的评论,另外将生成的形状移动到原点,因此可以在坐标轴上看到尺寸
$fn= 360;
w = 10; // width of rectangle
h = 2; // height of rectangle
l = 30; // length of chord of the curve
dh = 4; // delta height of the curve
module curve(width, height, length, dh) {
r = (pow(length/2, 2) + pow(dh, 2))/(2*dh);
a = 2*asin((length/2)/r);
translate([-(r -dh), 0, -width/2]) rotate([0, 0, -a/2]) rotate_extrude(angle = a) translate([r, 0, 0]) square(size = [height, width], center = true);
}
curve(w, h, l, dh);
结果:
编辑 19.09.2020:最后一次编辑中有一个错字:在第一个“翻译”中,应使用本地“宽度”而不是“w”。在上面的代码中更正了它。
推荐阅读
- flutter - Flutter windows:获取flutter app的win32窗口句柄
- javascript - 为什么javascript代码改变了innerText,而页面却没有?
- php - Redis 失败导致 Laravel 5.6 中的登录和注册问题
- javascript - 具有可折叠属性的 d3 中的强制有向图
- reactjs - 如何在反应中更新导航栏
- android - 如何从 Kotlin 中的适配器调用片段的函数?
- arrays - 如何在谷歌表格中的复选框之间求和?
- swift - 用 Swift 大写首字母格式化俄语日期
- c - 出现错误:C 中的“变量...在其自己的初始化中使用时未初始化”
- ios - 阴影层在表格视图单元格中超出范围