手动构建六角环面
Manually building Hexagonal Torus
我有兴趣使用点网格构建六角环面吗?
我认为我可以从一个二维多边形开始,然后迭代360次(1度分辨率)来构建一个完整的实体。
这是最好的方法吗?我真正想要的是在其跨度上构建具有可变横截面几何形状的翼型。
你在建造某物吗?像 NACA 机翼? https://en.wikipedia.org/wiki/NACA_airfoil
有一些 OpenSCAD 设计适合四处游荡的人,例如参见https://www.thingiverse.com/thing:898554
以您的方式 您可以使用 polyhedron()
来做到这一点。按定义的顺序为每个配置文件添加适当数量的点到向量“点”,通过第二个向量“面”中的点的索引定义面,并将两个向量设置为 polyhedron()
中的参数,参见 documentation.您可以通过每个轮廓的点数和轮廓之间的距离(圆环中的扇区)来控制表面质量。
这里是一个示例代码:
// parameter:
r1 = 20; // radius of torus
r2 = 4; // radius of polygon/ thickness of torus
s = 360; // sections per 360 deg
p = 6; // points on polygon
a = 30; // angle of the first point on Polygon
// points on cross-section
// angle = 360*i/p + startangle, x = r2*cos(angle), y = 0, z = r2*sin(angle)
function cs_point(i) = [r1 + r2*cos(360*i/p + a), 0, r2*sin(360*i/p + a)];
// returns to the index in the points - vector the section number and the number of the point on this section
function point_index(i) = [floor(i/p), i - p*floor(i/p)];
// returns the points x-, y-, z-coordinates by rotatating the corresponding point from crossection around the z-axis
function iterate_cs(i) = [cs[point_index(i)[1]][0]*cos(360*floor(i/p)/s), cs[point_index(i)[1]][0]*sin(360*floor(i/p)/s), cs[point_index(i)[1]][2]];
// for every point find neighbour points to build faces, ( + p: point on the next cross-section), points ordered clockwise
// to connect point on last section to corresponding points on first section
function item_add1(i) = i >= (s - 1)*p ? -(s)*p : 0;
// to connect last point on section to first points on the same and the next section
function item_add2(i) = i - p*floor(i/p) >= p-1 ? -p : 0;
// build faces
function find_neighbours1(i) = [i, i + 1 + item_add2(i), i + 1 + item_add2(i) + p + item_add1(i)];
function find_neighbours2(i) = [i, i + 1 + + item_add2(i) + p + item_add1(i), i + p + item_add1(i)];
cs = [for (i = [0:p-1]) cs_point(i)];
points = [for (i = [0:s*p - 1]) iterate_cs(i)];
faces1 = [for (i = [0:s*p - 1]) find_neighbours1(i)];
faces2 = [for (i = [0:s*p - 1]) find_neighbours2(i)];
faces = concat(faces1, faces2);
polyhedron(points = points, faces = faces);
这里是结果:
自openscad 2015-03起,人脸可以有3个以上的点,前提是人脸的所有点都在同一平面上。所以在这种情况下,面部也可以一步构建。
我有兴趣使用点网格构建六角环面吗?
我认为我可以从一个二维多边形开始,然后迭代360次(1度分辨率)来构建一个完整的实体。
这是最好的方法吗?我真正想要的是在其跨度上构建具有可变横截面几何形状的翼型。
你在建造某物吗?像 NACA 机翼? https://en.wikipedia.org/wiki/NACA_airfoil
有一些 OpenSCAD 设计适合四处游荡的人,例如参见https://www.thingiverse.com/thing:898554
以您的方式 您可以使用 polyhedron()
来做到这一点。按定义的顺序为每个配置文件添加适当数量的点到向量“点”,通过第二个向量“面”中的点的索引定义面,并将两个向量设置为 polyhedron()
中的参数,参见 documentation.您可以通过每个轮廓的点数和轮廓之间的距离(圆环中的扇区)来控制表面质量。
这里是一个示例代码:
// parameter:
r1 = 20; // radius of torus
r2 = 4; // radius of polygon/ thickness of torus
s = 360; // sections per 360 deg
p = 6; // points on polygon
a = 30; // angle of the first point on Polygon
// points on cross-section
// angle = 360*i/p + startangle, x = r2*cos(angle), y = 0, z = r2*sin(angle)
function cs_point(i) = [r1 + r2*cos(360*i/p + a), 0, r2*sin(360*i/p + a)];
// returns to the index in the points - vector the section number and the number of the point on this section
function point_index(i) = [floor(i/p), i - p*floor(i/p)];
// returns the points x-, y-, z-coordinates by rotatating the corresponding point from crossection around the z-axis
function iterate_cs(i) = [cs[point_index(i)[1]][0]*cos(360*floor(i/p)/s), cs[point_index(i)[1]][0]*sin(360*floor(i/p)/s), cs[point_index(i)[1]][2]];
// for every point find neighbour points to build faces, ( + p: point on the next cross-section), points ordered clockwise
// to connect point on last section to corresponding points on first section
function item_add1(i) = i >= (s - 1)*p ? -(s)*p : 0;
// to connect last point on section to first points on the same and the next section
function item_add2(i) = i - p*floor(i/p) >= p-1 ? -p : 0;
// build faces
function find_neighbours1(i) = [i, i + 1 + item_add2(i), i + 1 + item_add2(i) + p + item_add1(i)];
function find_neighbours2(i) = [i, i + 1 + + item_add2(i) + p + item_add1(i), i + p + item_add1(i)];
cs = [for (i = [0:p-1]) cs_point(i)];
points = [for (i = [0:s*p - 1]) iterate_cs(i)];
faces1 = [for (i = [0:s*p - 1]) find_neighbours1(i)];
faces2 = [for (i = [0:s*p - 1]) find_neighbours2(i)];
faces = concat(faces1, faces2);
polyhedron(points = points, faces = faces);
这里是结果:
自openscad 2015-03起,人脸可以有3个以上的点,前提是人脸的所有点都在同一平面上。所以在这种情况下,面部也可以一步构建。