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