mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-13 18:24:28 +02:00
refactored
This commit is contained in:
1
src/__private__/__triangles_radial.scad
Normal file
1
src/__private__/__triangles_radial.scad
Normal file
@@ -0,0 +1 @@
|
||||
function __triangles_radial(shape_pts) = [for(i = [1:len(shape_pts) - 2]) [0, i, i + 1]];
|
@@ -11,6 +11,8 @@
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__triangles_radial.scad>;
|
||||
|
||||
module polysections(sections, triangles = "RADIAL") {
|
||||
module tri_sections(tri1, tri2) {
|
||||
polyhedron(
|
||||
@@ -28,14 +30,9 @@ module polysections(sections, triangles = "RADIAL") {
|
||||
i == len(vector) ? [] :
|
||||
concat(vector[i], flat(vector, i + 1));
|
||||
|
||||
leng_section = len(sections[0]);
|
||||
|
||||
function radial_tris() = [
|
||||
for(i = [1:leng_section - 2]) [0, i, i + 1]
|
||||
];
|
||||
|
||||
function hollow_tris() =
|
||||
let(
|
||||
leng_section = len(sections[0]),
|
||||
inner_i_begin = leng_section / 2,
|
||||
pair_idxes = [for(i = [0:inner_i_begin - 1])
|
||||
let(n = inner_i_begin + i + 1)
|
||||
@@ -48,7 +45,7 @@ module polysections(sections, triangles = "RADIAL") {
|
||||
|
||||
) flat(pair_idxes);
|
||||
|
||||
function tris() = triangles == "RADIAL" ? radial_tris() :
|
||||
function tris() = triangles == "RADIAL" ? __triangles_radial(sections[0]) :
|
||||
(triangles == "HOLLOW" ? hollow_tris() : triangles);
|
||||
|
||||
module two_sections(section1, section2) {
|
||||
|
@@ -13,6 +13,7 @@
|
||||
**/
|
||||
|
||||
include <__private__/__frags.scad>;
|
||||
include <__private__/__triangles_radial.scad>;
|
||||
|
||||
function shape_ellipse(axes) =
|
||||
let(
|
||||
@@ -22,7 +23,7 @@ function shape_ellipse(axes) =
|
||||
for(a = [0:step_a:360 - step_a])
|
||||
[axes[0] * cos(a), axes[1] * sin(a)]
|
||||
],
|
||||
triangles = [for(i = [1:len(shape_pts) - 2]) [0, i, i + 1]]
|
||||
triangles = __triangles_radial(shape_pts)
|
||||
)
|
||||
[
|
||||
shape_pts,
|
||||
|
@@ -13,6 +13,7 @@
|
||||
**/
|
||||
|
||||
include <__private__/__frags.scad>;
|
||||
include <__private__/__triangles_radial.scad>;
|
||||
|
||||
function shape_pie(radius, angles) =
|
||||
let(
|
||||
@@ -32,7 +33,7 @@ function shape_pie(radius, angles) =
|
||||
],
|
||||
[edge_r_end * [cos(angles[1]), sin(angles[1])]]
|
||||
),
|
||||
triangles = [for(i = [1:len(shape_pts) - 2]) [0, i, i + 1]]
|
||||
triangles = __triangles_radial(shape_pts)
|
||||
)
|
||||
[
|
||||
shape_pts,
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__frags.scad>;
|
||||
include <__private__/__triangles_radial.scad>;
|
||||
|
||||
function shape_square(size, corner_r = 0) =
|
||||
let(
|
||||
@@ -37,7 +38,7 @@ function shape_square(size, corner_r = 0) =
|
||||
[[-half_w, -half_y], [half_w, -half_y]],
|
||||
[for(a = [270 + step_a:step_a:360 - step_a]) [corner_r * cos(a) + half_w, corner_r * sin(a) - half_h]]
|
||||
),
|
||||
triangles = [for(i = [1:len(shape_pts) - 2]) [0, i, i + 1]]
|
||||
triangles = __triangles_radial(shape_pts)
|
||||
)
|
||||
[
|
||||
shape_pts,
|
||||
|
Reference in New Issue
Block a user