diff --git a/README.md b/README.md index 8f4c1b7c..b746bc00 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ See [examples](examples). - [ptf/ptf_y_twist](https://openhome.cc/eGossip/OpenSCAD/lib2x-ptf_y_twist.html) - [ptf/ptf_circle](https://openhome.cc/eGossip/OpenSCAD/lib2x-ptf_circle.html) - [ptf/ptf_bend](https://openhome.cc/eGossip/OpenSCAD/lib2x-ptf_bend.html) - - ptf/ptf_ring + - [ptf/ptf_ring](https://openhome.cc/eGossip/OpenSCAD/lib2x-ptf_ring.html) - ptf/ptf_sphere - ptf/ptf_torus diff --git a/docs/images/lib2x-ptf_ring-1.JPG b/docs/images/lib2x-ptf_ring-1.JPG new file mode 100644 index 00000000..18708259 Binary files /dev/null and b/docs/images/lib2x-ptf_ring-1.JPG differ diff --git a/docs/images/lib2x-ptf_ring-2.JPG b/docs/images/lib2x-ptf_ring-2.JPG new file mode 100644 index 00000000..7183212a Binary files /dev/null and b/docs/images/lib2x-ptf_ring-2.JPG differ diff --git a/docs/lib2x-ptf_ring.md b/docs/lib2x-ptf_ring.md new file mode 100644 index 00000000..6836dfdf --- /dev/null +++ b/docs/lib2x-ptf_ring.md @@ -0,0 +1,45 @@ +# ptf_ring + +Transforms a point inside a rectangle to a point of a ring. It can create things such as [tiled_line_mobius](https://github.com/JustinSDK/dotSCAD/blob/master/examples/tiled_line_mobius.scad). + +![ptf_ring](images/lib2x-ptf_ring-1.JPG) + +**Since:** 2.3 + +## Parameters + +- `size` : 2 value array `[x, y]`, rectangle with dimensions `x` and `y`. +- `point` : The point to be transformed. +- `radius` : The radius of the ring. +- `angle` : The central angle of the arc. +- `twist` : The number of degrees of through which the rectangle is twisted. + +## Examples + + use ; + use ; + + size = [20, 10]; + radius = 5; + + rows = [ + for(y = [0:size[1]]) + [for(x = [0:size[0]]) [x, y]] + ]; + + columns = [ + for(x = [0:size[0]]) + [for(y = [0:size[1]]) [x, y]] + ]; + + for(line = rows) { + twisted = [for(p = line) ptf_ring(size, p, radius, 360, 180)]; + hull_polyline3d(twisted, thickness = .5); + } + + for(line = columns) { + twisted = [for(p = line) ptf_ring(size, p, radius, 360, 180)]; + hull_polyline3d(twisted, thickness = .5); + } + +![ptf_ring](images/lib2x-ptf_ring-2.JPG) diff --git a/docs/lib2x-ptf_x_twist.md b/docs/lib2x-ptf_x_twist.md index b9bad24b..4d2feecc 100644 --- a/docs/lib2x-ptf_x_twist.md +++ b/docs/lib2x-ptf_x_twist.md @@ -39,4 +39,4 @@ Twist a point along the x-axis. You can use it to create something such as a [tw hull_polyline3d(twisted, thickness = .1); } -![ptf_x_twist](images/lib2x-ptf_x_twist-1.JPG) +![ptf_x_twist](images/lib2x-ptf_x_twist-2.JPG) diff --git a/src/ptf/ptf_ring.scad b/src/ptf/ptf_ring.scad index d76c7fd8..742decad 100644 --- a/src/ptf/ptf_ring.scad +++ b/src/ptf/ptf_ring.scad @@ -1,13 +1,16 @@ +/** +* ptf_ring.scad +* +* @copyright Justin Lin, 2020 +* @license https://opensource.org/licenses/lgpl-3.0.html +* +* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-ptf_ring.html +* +**/ + use ; use ; -/* - size: The size of a rectangle. - point: A point in the rectangle. - radius: ring radius. - angle: arc angle. - twist: The number of degrees of through which the rectangle is twisted. -*/ function ptf_ring(size, point, radius, angle = 360, twist = 0) = let( yleng = size[1],