mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-12 09:44:16 +02:00
add tri_subdivide
This commit is contained in:
19
src/experimental/tri_subdivide.scad
Normal file
19
src/experimental/tri_subdivide.scad
Normal file
@@ -0,0 +1,19 @@
|
||||
function _tri_subdivide(points) =
|
||||
let(
|
||||
p0 = points[0],
|
||||
p1 = points[1],
|
||||
p2 = points[2],
|
||||
m0 = (p0 + p1) / 2,
|
||||
m1 = (p1 + p2) / 2,
|
||||
m2 = (p2 + p0) / 2
|
||||
)
|
||||
[
|
||||
[p0, m0, m2],
|
||||
[m0, p1, m1],
|
||||
[m1, p2, m2],
|
||||
[m0, m1, m2]
|
||||
];
|
||||
|
||||
function tri_subdivide(points, n = 1) =
|
||||
n == 1 ? _tri_subdivide(points) :
|
||||
[for(tri = tri_subdivide(points, n - 1)) each _tri_subdivide(tri)];
|
Reference in New Issue
Block a user