mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 22:28:16 +01:00
refactored
This commit is contained in:
parent
5ebf3e18e4
commit
89a7c5fbbc
@ -1,7 +1,7 @@
|
||||
function __half_trapezium(radius, h, round_r) =
|
||||
let(
|
||||
is_vt = __is_vector(radius),
|
||||
r1 = is_vt ? radius[0] : radiusm,
|
||||
r1 = is_vt ? radius[0] : radius,
|
||||
r2 = is_vt ? radius[1] : radius,
|
||||
frags = __frags(round_r),
|
||||
b_ang = atan2(h, r1 - r2),
|
||||
|
14
src/__private__/__trapezium.scad
Normal file
14
src/__private__/__trapezium.scad
Normal file
@ -0,0 +1,14 @@
|
||||
function __trapezium(radius, h, round_r) =
|
||||
let(
|
||||
r_half_trapezium = __half_trapezium(radius, h, round_r),
|
||||
to = len(r_half_trapezium) - 1,
|
||||
l_half_trapezium = [
|
||||
for(i = [0:to])
|
||||
let(pt = r_half_trapezium[to - i])
|
||||
[-pt[0], pt[1]]
|
||||
]
|
||||
)
|
||||
concat(
|
||||
r_half_trapezium,
|
||||
l_half_trapezium
|
||||
);
|
@ -15,33 +15,17 @@
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__frags.scad>;
|
||||
include <__private__/__pie_for_rounding.scad>;
|
||||
include <__private__/__half_trapezium.scad>;
|
||||
include <__private__/__trapezium.scad>;
|
||||
|
||||
function shape_square(size, corner_r = 0) =
|
||||
let(
|
||||
corner_frags = __frags(corner_r) / 4,
|
||||
x = __is_vector(size) ? size[0] : size,
|
||||
y = __is_vector(size) ? size[1] : size,
|
||||
half_x = x / 2,
|
||||
half_y = y / 2,
|
||||
half_w = half_x - corner_r,
|
||||
half_h = half_y - corner_r,
|
||||
right_side = [
|
||||
for(pt = __pie_for_rounding(corner_r, -90, 0, corner_frags))
|
||||
[pt[0] + half_w - corner_r, pt[1] - half_h + corner_r]
|
||||
],
|
||||
top_side = [
|
||||
for(pt = __pie_for_rounding(corner_r, 0, 90, corner_frags))
|
||||
[pt[0] + half_w - corner_r, pt[1] + half_h - corner_r]
|
||||
],
|
||||
left_side = [
|
||||
for(pt = __pie_for_rounding(corner_r, 90, 180, corner_frags))
|
||||
[pt[0] - half_w + corner_r, pt[1] + half_h - corner_r]
|
||||
],
|
||||
bottom_side = [
|
||||
for(pt = __pie_for_rounding(corner_r, 180, 270, corner_frags))
|
||||
[pt[0] - half_w + corner_r, pt[1] - half_h + corner_r]
|
||||
],
|
||||
shape_pts = concat(
|
||||
right_side, top_side, left_side, bottom_side
|
||||
)
|
||||
) shape_pts;
|
||||
y = __is_vector(size) ? size[1] : size
|
||||
)
|
||||
__trapezium(
|
||||
radius = x,
|
||||
h = y,
|
||||
round_r = corner_r
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user