diff --git a/README.md b/README.md index ff62c02c..c0bdf451 100644 --- a/README.md +++ b/README.md @@ -152,8 +152,8 @@ See [examples](examples). - [ptf/ptf_bend](https://openhome.cc/eGossip/OpenSCAD/lib2x-ptf_bend.html) - [ptf/ptf_ring](https://openhome.cc/eGossip/OpenSCAD/lib2x-ptf_ring.html) - [ptf/ptf_sphere](https://openhome.cc/eGossip/OpenSCAD/lib2x-ptf_sphere.html) - - ptf/ptf_torus - + - [ptf/ptf_torus](https://openhome.cc/eGossip/OpenSCAD/lib2x-ptf_torus.html) + ---- - Turtle diff --git a/docs/images/lib2x-ptf_torus-1.JPG b/docs/images/lib2x-ptf_torus-1.JPG new file mode 100644 index 00000000..6cac5837 Binary files /dev/null and b/docs/images/lib2x-ptf_torus-1.JPG differ diff --git a/docs/images/lib2x-ptf_torus-2.JPG b/docs/images/lib2x-ptf_torus-2.JPG new file mode 100644 index 00000000..54fef7d7 Binary files /dev/null and b/docs/images/lib2x-ptf_torus-2.JPG differ diff --git a/docs/lib2x-ptf_torus.md b/docs/lib2x-ptf_torus.md new file mode 100644 index 00000000..d78f1943 --- /dev/null +++ b/docs/lib2x-ptf_torus.md @@ -0,0 +1,47 @@ +# ptf_torus + +Transforms a point inside a rectangle to a point of a torus. It can create things such as [torus maze](https://github.com/JustinSDK/dotSCAD/blob/master/examples/maze/torus_maze.scad). + +![ptf_torus](images/lib2x-ptf_torus-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` : Torus `[R, r]`. +- `angle` : Torus `[A, a]`. +- `twist` : The number of degrees of through which the rectangle is twisted. + +## Examples + + use ; + use ; + + size = [20, 10]; + radius = [10, 5]; + angle = [180, 180]; + twist = 90; + + 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_torus(size, p, radius, angle, twist)]; + hull_polyline3d(twisted, thickness = .5); + } + + for(line = columns) { + twisted = [for(p = line) ptf_torus(size, p, radius, angle, twist)]; + hull_polyline3d(twisted, thickness = .5); + } + +![ptf_torus](images/lib2x-ptf_torus-2.JPG)