From 22ca453b43256626179e4f7d41eb23cc7bd45fff Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Tue, 24 Mar 2020 17:45:30 +0800 Subject: [PATCH] add ptf_circle to preview --- README.md | 1 + examples/maze/noisy_circle_maze.scad | 6 +++--- src/experimental/note.md | 1 + src/{experimental => ptf}/ptf_circle.scad | 5 +++-- 4 files changed, 8 insertions(+), 5 deletions(-) rename src/{experimental => ptf}/ptf_circle.scad (51%) diff --git a/README.md b/README.md index 7f6b5c8e..53058670 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,7 @@ See [examples](examples). - ptf/ptf_rotate - ptf/ptf_x_twist - ptf/ptf_y_twist + - ptf/ptf_circle - ptf/ptf_bend - ptf/ptf_ring - ptf/ptf_sphere diff --git a/examples/maze/noisy_circle_maze.scad b/examples/maze/noisy_circle_maze.scad index c7551a5e..ba22d587 100644 --- a/examples/maze/noisy_circle_maze.scad +++ b/examples/maze/noisy_circle_maze.scad @@ -16,15 +16,15 @@ module noisy_circle_maze(start, r_blocks, block_width, wall_thickness, origin_of walls = mz_walls(blocks, double_r_blocks, double_r_blocks, block_width); half_width = width / 2; - offset = is_undef(origin_offset) ? [-half_width, -half_width] : origin_offset; + rect_size = is_undef(origin_offset) ? [width, width] : [width, width] - origin_offset * 2; noisy_f = is_undef(noisy_factor) ? 1 : noisy_factor; seed = rand(0, 256); for(wall = walls) { for(i = [0:len(wall) - 2]) { - p0 = ptf_circle(wall[i], offset); - p1 = ptf_circle(wall[i + 1], offset); + p0 = ptf_circle(rect_size, wall[i]); + p1 = ptf_circle(rect_size, wall[i + 1]); pn00 = pnoise2(p0[0], p0[1], seed) * noisy_f; pn01 = pnoise2(p0[0] + seed, p0[1] + seed, seed) * noisy_f; pn10 = pnoise2(p1[0], p1[1], seed) * noisy_f; diff --git a/src/experimental/note.md b/src/experimental/note.md index ad5b4092..71ef8603 100644 --- a/src/experimental/note.md +++ b/src/experimental/note.md @@ -32,6 +32,7 @@ Preview - `ptf/ptf_rotate` - `ptf/ptf_x_twist` - `ptf/ptf_y_twist` +- `ptf/ptf_circle` - `ptf/ptf_bend` - `ptf/ptf_ring` - `ptf/ptf_sphere` diff --git a/src/experimental/ptf_circle.scad b/src/ptf/ptf_circle.scad similarity index 51% rename from src/experimental/ptf_circle.scad rename to src/ptf/ptf_circle.scad index a5469cfb..55960940 100644 --- a/src/experimental/ptf_circle.scad +++ b/src/ptf/ptf_circle.scad @@ -1,6 +1,7 @@ -function ptf_circle(point, offset) = +function ptf_circle(size, point) = let( - p = [point[0] + offset[1], point[1] + offset[0]], + p_offset = -size / 2, + p = [point[0] + p_offset[1], point[1] + p_offset[0]], n = max(abs(p[0]), abs(p[1])), r = n * 1.414, a = atan2(p[0], p[1])