1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-01 04:20:27 +02:00

re-org vars

This commit is contained in:
Justin Lin
2022-05-15 10:11:16 +08:00
parent 22dfa7da2d
commit 63aab80116
7 changed files with 17 additions and 30 deletions

View File

@@ -12,8 +12,7 @@ function ptf_bend(size, point, radius, angle) =
let(
// ignored: size.y,
x = is_undef(point.z) ? 0 : point.z,
a_step = angle / size.x,
a = a_step * point.x,
a = angle / size.x * point.x,
r = radius + x
)
[r * cos(a), r * sin(a), point.y];

View File

@@ -11,8 +11,4 @@
function ptf_circle(size, point) =
let(p = point - size / 2)
p == [0, 0] ? p :
let(
n = max(abs(p.x), abs(p.y)),
r = n * 1.41421356237
)
[p.y, p.x] * (r / norm(p));
[p.y, p.x] * (max(abs(p.x), abs(p.y)) / norm(p) * 1.41421356237);

View File

@@ -12,8 +12,5 @@ use <ptf_rotate.scad>;
use <ptf_y_twist.scad>;
function ptf_ring(size, point, radius, angle = 360, twist = 0) =
let(
a_step = angle / size.y,
twisted = ptf_y_twist(size, point, twist)
)
ptf_rotate([radius + twisted.x, 0, twisted.z], a_step * twisted.y);
let(twisted = ptf_y_twist(size, point, twist))
ptf_rotate([radius + twisted.x, 0, twisted.z], angle / size.y * twisted.y);

View File

@@ -12,12 +12,10 @@ use <ptf_rotate.scad>;
function ptf_sphere(size, point, radius, angle = [180, 360]) =
let(
z = is_undef(point.z) ? 0 : point.z,
za = angle[0],
xa = angle[1],
za_step = za / size.y,
rza = za_step * point.y,
rzpt = (radius + z) * [cos(rza), sin(rza), 0],
rxpt = ptf_rotate(rzpt, [90 - xa / size.x * point.x, 90, 0])
z = is_undef(point.z) ? 0 : point.z,
rza = angle[0] / size.y * point.y
)
rxpt;
ptf_rotate(
(radius + z) * [cos(rza), sin(rza), 0],
[90 - angle[1] / size.x * point.x, 90, 0]
);

View File

@@ -16,10 +16,9 @@ function ptf_torus(size, point, radius, angle = [360, 360], twist = 0) =
r = radius[1] + (is_undef(point.z) ? 0 : point.z),
A = angle[0],
a = angle[1],
ya_step = a / size.x,
za_step = A / size.y,
twa_step = twist / size.y,
ya = 180 - point.x * ya_step + twa_step * point.y,
za = za_step * point.y
ya = 180 - point.x * a / size.x + twist / size.y * point.y
)
ptf_rotate([r * cos(ya) + R + r, 0, r * sin(ya)], za);
ptf_rotate(
[r * cos(ya) + R + r, 0, r * sin(ya)],
A / size.y * point.y
);

View File

@@ -13,7 +13,6 @@ use <ptf_rotate.scad>;
function ptf_x_twist(size, point, angle) =
let(
y_offset = size.y / 2,
a_step = angle / size.x,
y_centered = [point.x, point.y, is_undef(point.z) ? 0 : point.z] + [0, -y_offset, 0]
)
ptf_rotate(y_centered, [point.x * a_step, 0, 0]) + [0, y_offset, 0];
ptf_rotate(y_centered, [point.x * angle / size.x, 0, 0]) + [0, y_offset, 0];

View File

@@ -13,7 +13,6 @@ use <ptf_rotate.scad>;
function ptf_y_twist(size, point, angle) =
let(
x_offset = size.x / 2,
a_step = angle / size.y,
x_centered = [point.x, point.y, is_undef(point.z) ? 0 : point.z] + [-x_offset, 0, 0]
)
ptf_rotate(x_centered, [0, point.y * a_step, 0]) + [x_offset, 0, 0];
ptf_rotate(x_centered, [0, point.y * angle / size.y, 0]) + [x_offset, 0, 0];