Compare commits
121 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
81e4f45f89 | ||
|
46ffc7601d | ||
|
31dba8711d | ||
|
ad983b8670 | ||
|
0d35fc2023 | ||
|
6851464068 | ||
|
b9d93bac84 | ||
|
645d0946c1 | ||
|
844c6e7d9b | ||
|
5597fa0ce1 | ||
|
64eaa6d7e1 | ||
|
840fc0eac5 | ||
|
98bac0bdff | ||
|
8f747f2e75 | ||
|
4e3016859c | ||
|
7c38ea2009 | ||
|
ce4d11cf52 | ||
|
b4e4f60902 | ||
|
feb0e351b6 | ||
|
e670ad6b9d | ||
|
bf1cc23f0f | ||
|
fa966bdde8 | ||
|
db8792fc4e | ||
|
7d5e18ff8c | ||
|
8722f971ba | ||
|
6c0a0bdfb0 | ||
|
156e15bc99 | ||
|
b2a521a11f | ||
|
597551e24a | ||
|
bf9a23d5c5 | ||
|
cbf59ce0b4 | ||
|
fafa551959 | ||
|
63dcbe259d | ||
|
4ea52e328e | ||
|
1a92c27b28 | ||
|
a3e2077b46 | ||
|
afa0e99fe5 | ||
|
09016a31cd | ||
|
ec102fbdee | ||
|
106695b988 | ||
|
ee31927015 | ||
|
e60c451033 | ||
|
53b7d7a628 | ||
|
77b3c4c9db | ||
|
bc7f57813b | ||
|
ad4a992c9d | ||
|
f8f7adbb45 | ||
|
f690952f1f | ||
|
ac209d6125 | ||
|
5d394d8738 | ||
|
b3ffb9ab72 | ||
|
665fb09864 | ||
|
f33d6c5671 | ||
|
f985e13231 | ||
|
7b1a683c74 | ||
|
ff8d36336e | ||
|
49be3b9b9f | ||
|
e13abc57ce | ||
|
6fbe42ba8f | ||
|
48e52fa48b | ||
|
0dbe93d16b | ||
|
bdaa05823c | ||
|
035e1fa1b4 | ||
|
33b3d6de67 | ||
|
305c2f9ee4 | ||
|
0958207e53 | ||
|
ed16cc3289 | ||
|
9c57a539b2 | ||
|
d09926285a | ||
|
a767e2240c | ||
|
f42a51d896 | ||
|
af7e39a97e | ||
|
0c45a94038 | ||
|
46777fa403 | ||
|
118ee961ee | ||
|
57ed5a8901 | ||
|
4fe79dc568 | ||
|
3603b92258 | ||
|
502dcdde9b | ||
|
daa281bb70 | ||
|
35132b603f | ||
|
ce14b4fec7 | ||
|
9e26bd35ec | ||
|
70db05592b | ||
|
b9bf11ebe9 | ||
|
32e582554c | ||
|
5972c4f551 | ||
|
f215f27f9f | ||
|
69f43afe46 | ||
|
8ada3785be | ||
|
42cc92e9b4 | ||
|
2354f9aeaa | ||
|
8385bbb145 | ||
|
f6c03d239f | ||
|
3e285fc1e8 | ||
|
66e1001ba4 | ||
|
4579614ddb | ||
|
e1bf720acb | ||
|
db004887d5 | ||
|
d746ff3078 | ||
|
fece5c2bde | ||
|
fad69acb2a | ||
|
f60d1558ce | ||
|
8e96639d5a | ||
|
7ec08a7603 | ||
|
47997a5cbd | ||
|
aee4e7b68a | ||
|
ce6ef4c039 | ||
|
07074ee47c | ||
|
a3535ee529 | ||
|
691274cb07 | ||
|
022269a13b | ||
|
92f4e12a9a | ||
|
79f49b9262 | ||
|
7d45b16691 | ||
|
cca77c3c65 | ||
|
a8063a2be2 | ||
|
d6aae5fdf6 | ||
|
07ed786ea1 | ||
|
87f5a89cbb | ||
|
29e387cdcf |
19
README.md
@@ -1,8 +1,8 @@
|
||||
# dotSCAD
|
||||
# dotSCAD 1.2
|
||||
|
||||
> Helpful modules and functions when playing OpenSCAD.
|
||||
> Helpful modules and functions when playing OpenSCAD. Based on OpenSCAD 2015.03.
|
||||
|
||||

|
||||

|
||||
|
||||
[](https://github.com/JustinSDK/lib-openscad/blob/master/LICENSE)
|
||||
|
||||
@@ -49,11 +49,13 @@ Too many dependencies? Because OpenSCAD doesn't provide namespace management, I
|
||||
- [hull_polyline3d](https://openhome.cc/eGossip/OpenSCAD/lib-hull_polyline3d.html)
|
||||
- [function_grapher](https://openhome.cc/eGossip/OpenSCAD/lib-function_grapher.html)
|
||||
- [polysections](https://openhome.cc/eGossip/OpenSCAD/lib-polysections.html)
|
||||
- [starburst](https://openhome.cc/eGossip/OpenSCAD/lib-starburst.html)
|
||||
|
||||
- Transformation
|
||||
- [along_with](https://openhome.cc/eGossip/OpenSCAD/lib-along_with.html)
|
||||
- [hollow_out](https://openhome.cc/eGossip/OpenSCAD/lib-hollow_out.html)
|
||||
- [bend](https://openhome.cc/eGossip/OpenSCAD/lib-bend.html)
|
||||
- [shear](https://openhome.cc/eGossip/OpenSCAD/lib-shear.html)
|
||||
|
||||
- Functon
|
||||
- [rotate_p](https://openhome.cc/eGossip/OpenSCAD/lib-rotate_p.html)
|
||||
@@ -62,6 +64,8 @@ Too many dependencies? Because OpenSCAD doesn't provide namespace management, I
|
||||
- [parse_number](https://openhome.cc/eGossip/OpenSCAD/lib-parse_number.html)
|
||||
- [cross_sections](https://openhome.cc/eGossip/OpenSCAD/lib-cross_sections.html)
|
||||
- [paths2sections](https://openhome.cc/eGossip/OpenSCAD/lib-paths2sections.html)
|
||||
- [path_scaling_sections](https://openhome.cc/eGossip/OpenSCAD/lib-path_scaling_sections.html)
|
||||
- [bijection_offset](https://openhome.cc/eGossip/OpenSCAD/lib-bijection_offset.html)
|
||||
|
||||
- Path
|
||||
- [arc_path](https://openhome.cc/eGossip/OpenSCAD/lib-arc_path.html)
|
||||
@@ -73,6 +77,7 @@ Too many dependencies? Because OpenSCAD doesn't provide namespace management, I
|
||||
- [golden_spiral](https://openhome.cc/eGossip/OpenSCAD/lib-golden_spiral.html)
|
||||
- [archimedean_spiral](https://openhome.cc/eGossip/OpenSCAD/lib-archimedean_spiral.html)
|
||||
- [sphere_spiral](https://openhome.cc/eGossip/OpenSCAD/lib-sphere_spiral.html)
|
||||
- [torus_knot](https://openhome.cc/eGossip/OpenSCAD/lib-torus_knot.html)
|
||||
|
||||
- Extrusion
|
||||
- [box_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-box_extrude.html)
|
||||
@@ -102,6 +107,14 @@ Too many dependencies? Because OpenSCAD doesn't provide namespace management, I
|
||||
- [archimedean_spiral_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-archimedean_spiral_extrude.html)
|
||||
- [sphere_spiral_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-sphere_spiral_extrude.html)
|
||||
|
||||
- Matrix
|
||||
- [m_cumulate](https://openhome.cc/eGossip/OpenSCAD/lib-m_cumulate.html)
|
||||
- [m_translation](https://openhome.cc/eGossip/OpenSCAD/lib-m_translation.html)
|
||||
- [m_rotation](https://openhome.cc/eGossip/OpenSCAD/lib-m_rotation.html)
|
||||
- [m_scaling](https://openhome.cc/eGossip/OpenSCAD/lib-m_scaling.html)
|
||||
- [m_mirror](https://openhome.cc/eGossip/OpenSCAD/lib-m_mirror.html)
|
||||
- [m_shearing](https://openhome.cc/eGossip/OpenSCAD/lib-m_shearing.html)
|
||||
|
||||
- Other
|
||||
- [turtle2d](https://openhome.cc/eGossip/OpenSCAD/lib-turtle2d.html)
|
||||
- [turtle3d](https://openhome.cc/eGossip/OpenSCAD/lib-turtle3d.html)
|
||||
|
46
RELEASE.md
@@ -1,3 +1,49 @@
|
||||
> Version numbers are based on [Semantic Versioning](https://semver.org/).
|
||||
|
||||
# v1.2.1
|
||||
- Bugfixes
|
||||
- Fixed CCW faces when using `path_scaling_sections`.
|
||||
|
||||
# v1.2
|
||||
- New modules and functions:
|
||||
- [starburst](https://openhome.cc/eGossip/OpenSCAD/lib-starburst.html)
|
||||
- [torus_knot](https://openhome.cc/eGossip/OpenSCAD/lib-torus_knot.html)
|
||||
- [bijection_offset](https://openhome.cc/eGossip/OpenSCAD/lib-bijection_offset.html)
|
||||
- [path_scaling_sections](https://openhome.cc/eGossip/OpenSCAD/lib-path_scaling_sections.html)
|
||||
|
||||
- Others
|
||||
- Avoid warnings when using newer versions of OpenSCAD after 2015.03.
|
||||
|
||||
# v1.1.1
|
||||
- Bugfixes
|
||||
- `m_rotation` returns an identity matrix if `a` is 0.
|
||||
- The `path_pts` parameter of `path_extrude` accepts two or three points.
|
||||
- The `points` parameter of `along_with` accepts two or three points.
|
||||
|
||||
- Others
|
||||
- OpenSCAD has built-in matrix multiplication so `m_multiply` is not necessary.
|
||||
|
||||
# v1.1
|
||||
- New matrix functions:
|
||||
- [m_multiply](https://openhome.cc/eGossip/OpenSCAD/lib-m_multiply.html)
|
||||
- [m_cumulate](https://openhome.cc/eGossip/OpenSCAD/lib-m_cumulate.html)
|
||||
- [m_translation](https://openhome.cc/eGossip/OpenSCAD/lib-m_translation.html)
|
||||
- [m_rotation](https://openhome.cc/eGossip/OpenSCAD/lib-m_rotation.html)
|
||||
- [m_scaling](https://openhome.cc/eGossip/OpenSCAD/lib-m_scaling.html)
|
||||
- [m_mirror](https://openhome.cc/eGossip/OpenSCAD/lib-m_mirror.html)
|
||||
- [m_shearing](https://openhome.cc/eGossip/OpenSCAD/lib-m_shearing.html)
|
||||
|
||||
- New modules:
|
||||
- [shear](https://openhome.cc/eGossip/OpenSCAD/lib-shear.html)
|
||||
|
||||
- New Parameters:
|
||||
- added `v` parameter to [rotate_p](https://openhome.cc/eGossip/OpenSCAD/lib-rotate_p.html)
|
||||
|
||||
|
||||
- Improved Performance:
|
||||
- [path_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-path_extrude.html)
|
||||
- [align_with](https://openhome.cc/eGossip/OpenSCAD/lib-along_with.html)
|
||||
|
||||
# v1.0.1
|
||||
- Fixed `path_extrude` crossing problem. See [issue 3](https://github.com/JustinSDK/dotSCAD/issues/3).
|
||||
- Fixed `along_with` crossing problems (similar to `path_extrude`.)
|
||||
|
BIN
WhirlingTaiwan.JPG
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
docs/images/lib-bijection_offset-1.JPG
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
docs/images/lib-bijection_offset-2.JPG
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
docs/images/lib-m_cumulate-1.JPG
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
docs/images/lib-m_mirror-1.JPG
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
docs/images/lib-m_rotation-1.JPG
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
docs/images/lib-m_rotation-2.JPG
Normal file
After Width: | Height: | Size: 54 KiB |
BIN
docs/images/lib-m_scaling-1.JPG
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
docs/images/lib-m_shearing-1.JPG
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
docs/images/lib-m_translation-1.JPG
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
docs/images/lib-path_scaling_sections-1.JPG
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
docs/images/lib-path_scaling_sections-2.JPG
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
docs/images/lib-path_scaling_sections-3.JPG
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
docs/images/lib-path_scaling_sections-4.JPG
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
docs/images/lib-rotate_p-3.JPG
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
docs/images/lib-shear-1.JPG
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
docs/images/lib-starburst-1.JPG
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
docs/images/lib-torus_knot-1.JPG
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
docs/images/lib-torus_knot-2.JPG
Normal file
After Width: | Height: | Size: 45 KiB |
@@ -15,8 +15,8 @@ Creates an arc path. You can pass a 2 element vector to define the central angle
|
||||
include <hull_polyline2d.scad>;
|
||||
|
||||
$fn = 24;
|
||||
points = arc_path(radius = 20, angle = [45, 290], width = 2);
|
||||
hull_polyline2d(points);
|
||||
points = arc_path(radius = 20, angle = [45, 290]);
|
||||
hull_polyline2d(points, width = 2);
|
||||
|
||||

|
||||
|
||||
@@ -24,8 +24,8 @@ Creates an arc path. You can pass a 2 element vector to define the central angle
|
||||
include <hull_polyline2d.scad>;
|
||||
|
||||
$fn = 24;
|
||||
points = arc_path(radius = 20, angle = 135, width = 2);
|
||||
hull_polyline2d(points);
|
||||
points = arc_path(radius = 20, angle = 135);
|
||||
hull_polyline2d(points, width = 2);
|
||||
|
||||

|
||||
|
||||
|
67
docs/lib-bijection_offset.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# bijection_offset
|
||||
|
||||
Move 2D outlines outward or inward by a given amount. Each point of the offsetted shape is paired with exactly one point of the original shape.
|
||||
|
||||
**Since:** 1.2.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `pts` : Points of a shape.
|
||||
- `d` : Amount to offset the shape. When negative, the shape is offset inwards.
|
||||
|
||||
## Examples
|
||||
|
||||
include <bijection_offset.scad>;
|
||||
|
||||
shape = [
|
||||
[15, 0],
|
||||
[15, 30],
|
||||
[0, 20],
|
||||
[-15, 40],
|
||||
[-15, 0]
|
||||
];
|
||||
|
||||
color("red") polygon(bijection_offset(shape, 3));
|
||||
color("orange") polygon(bijection_offset(shape, 2));
|
||||
color("yellow") polygon(bijection_offset(shape, 1));
|
||||
color("green") polygon(shape);
|
||||
color("blue") polygon(bijection_offset(shape, -1));
|
||||
color("indigo") polygon(bijection_offset(shape, -2));
|
||||
color("purple") polygon(bijection_offset(shape, -3));
|
||||
|
||||

|
||||
|
||||
include <bijection_offset.scad>;
|
||||
include <rotate_p.scad>;
|
||||
include <polysections.scad>;
|
||||
include <path_extrude.scad>;
|
||||
include <bezier_curve.scad>;
|
||||
|
||||
shape = [
|
||||
[5, 0],
|
||||
[3, 9],
|
||||
[0, 10],
|
||||
[-5, 0]
|
||||
];
|
||||
offsetted = bijection_offset(shape, 1);
|
||||
|
||||
offsetted2 = bijection_offset(shape, 2);
|
||||
offsetted3 = bijection_offset(shape, 3);
|
||||
|
||||
t_step = 0.05;
|
||||
|
||||
p0 = [0, 0, 0];
|
||||
p1 = [40, 60, 35];
|
||||
p2 = [-50, 70, 0];
|
||||
p3 = [20, 150, -35];
|
||||
p4 = [30, 50, -3];
|
||||
|
||||
path_pts = bezier_curve(t_step,
|
||||
[p0, p1, p2, p3, p4]
|
||||
);
|
||||
|
||||
path_extrude(concat(offsetted, shape), path_pts, "HOLLOW");
|
||||
path_extrude(concat(offsetted3, offsetted2), path_pts, "HOLLOW");
|
||||
|
||||

|
||||
|
30
docs/lib-m_cumulate.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# m_cumulate
|
||||
|
||||
The power of using transformation matrice is that you can cumulate all transformations in a matrix. This function multipies all transformation matrice.
|
||||
|
||||
**Since:** 1.1
|
||||
|
||||
## Parameters
|
||||
|
||||
- `matrice` : A list of 4x4 transformation matrice.
|
||||
|
||||
## Examples
|
||||
|
||||
include <m_rotation.scad>;
|
||||
include <m_scaling.scad>;
|
||||
include <m_translation.scad>;
|
||||
include <m_cumulate.scad>
|
||||
|
||||
m = m_cumulate([
|
||||
m_translation([10, 20, 10]), m_scaling(2), m_rotation(60)]
|
||||
);
|
||||
|
||||
multmatrix(m)
|
||||
cube(1);
|
||||
|
||||
multmatrix(m)
|
||||
sphere(1);
|
||||
|
||||
|
||||

|
||||
|
25
docs/lib-m_multiply.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# m_multiply
|
||||
|
||||
Multiply two 4x4 transformation matrice.
|
||||
|
||||
**Since:** 1.1
|
||||
|
||||
## Parameters
|
||||
|
||||
- `ma`, `mb` : Two 4x4 transformation matrice.
|
||||
|
||||
## Examples
|
||||
|
||||
include <m_multiply.scad>;
|
||||
include <m_scaling.scad>;
|
||||
include <m_rotation.scad>;
|
||||
|
||||
ma = m_scaling([0.5, 1, 2]);
|
||||
mb = m_rotation([0, 0, 90]);
|
||||
|
||||
cube(10);
|
||||
multmatrix(m_multiply(ma, mb))
|
||||
translate([15, 0, 0]) cube(10);
|
||||
|
||||

|
||||
|
45
docs/lib-m_rotation.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# m_rotation
|
||||
|
||||
Generate a 4x4 transformation matrix which can pass into `multmatrix` to rotate the child element about the axis of the coordinate system or around an arbitrary axis.
|
||||
|
||||
**Since:** 1.1
|
||||
|
||||
## Parameters
|
||||
|
||||
- `a` : If it's `[deg_x, deg_y, deg_z]`, the rotation is applied in the order `x`, `y`, `z`. If it's `[deg_x, deg_y]`, the rotation is applied in the order `x`, `y`. If it's`[deg_x]`, the rotation is only applied to the `x` axis. If it's an number, the rotation is only applied to the `z` axis or an arbitrary axis.
|
||||
- `v`: A vector allows you to set an arbitrary axis about which the object will be rotated. When `a` is an array, the `v` argument is ignored.
|
||||
|
||||
## Examples
|
||||
|
||||
include <m_rotation.scad>;
|
||||
|
||||
point = [20, 0, 0];
|
||||
a = [0, -45, 45];
|
||||
|
||||
hull() {
|
||||
sphere(1);
|
||||
multmatrix(m_rotation(a))
|
||||
translate(point)
|
||||
sphere(1);
|
||||
}
|
||||
|
||||

|
||||
|
||||
include <m_rotation.scad>;
|
||||
|
||||
v = [10, 10, 10];
|
||||
|
||||
hull() {
|
||||
sphere(1);
|
||||
translate(v)
|
||||
sphere(1);
|
||||
}
|
||||
|
||||
p = [10, 10, 0];
|
||||
for(i = [0:20:340]) {
|
||||
multmatrix(m_rotation(a = i, v = v))
|
||||
translate(p)
|
||||
sphere(1);
|
||||
}
|
||||
|
||||

|
21
docs/lib-m_scaling.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# m_scaling
|
||||
|
||||
Generate a 4x4 transformation matrix which can pass into `multmatrix` to scale its child elements using the specified vector.
|
||||
|
||||
**Since:** 1.1
|
||||
|
||||
## Parameters
|
||||
|
||||
- `v` : Elements will be scaled using the vector.
|
||||
|
||||
## Examples
|
||||
|
||||
include <m_scaling.scad>;
|
||||
|
||||
cube(10);
|
||||
translate([15, 0, 0])
|
||||
multmatrix(m_scaling([0.5, 1, 2]))
|
||||
cube(10);
|
||||
|
||||

|
||||
|
51
docs/lib-m_shearing.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# m_shearing
|
||||
|
||||
Generate a 4x4 transformation matrix which can pass into `multmatrix` to shear all child elements along the X-axis, Y-axis, or Z-axis in 3D.
|
||||
|
||||
**Since:** 1.1
|
||||
|
||||
## Parameters
|
||||
|
||||
- `sx` : An array `[SHy, SHz]`. The new coordinates of child elements are `(x + SHy * y + SHz * z, y, z)`.
|
||||
- `sy` : An array `[SHx, SHz]`. The new coordinates of child elements are `(x, y + SHx * x + SHz * z, z)`.
|
||||
- `sz` : An array `[SHx, SHy]`. The new coordinates of child elements are `(x, y, z + SHx * x + SHy * y)`.
|
||||
|
||||
## Examples
|
||||
|
||||
include <m_shearing.scad>;
|
||||
|
||||
color("red") {
|
||||
multmatrix(m_shearing(sx = [1, 0]))
|
||||
cube(1);
|
||||
|
||||
translate([2, 0, 0]) multmatrix(m_shearing(sx = [0, 1]))
|
||||
cube(1);
|
||||
|
||||
translate([4, 0, 0]) multmatrix(m_shearing(sx = [1, 1]))
|
||||
cube(1);
|
||||
}
|
||||
|
||||
translate([0, -3, 0]) color("green") {
|
||||
multmatrix(m_shearing(sy = [1, 0]))
|
||||
cube(1);
|
||||
|
||||
translate([2, 0, 0]) multmatrix(m_shearing(sy = [0, 1]))
|
||||
cube(1);
|
||||
|
||||
translate([4, 0, 0]) multmatrix(m_shearing(sy = [1, 1]))
|
||||
cube(1);
|
||||
}
|
||||
|
||||
translate([0, -5, 0]) color("blue") {
|
||||
multmatrix(m_shearing(sz = [1, 0]))
|
||||
cube(1);
|
||||
|
||||
translate([2, 0, 0]) multmatrix(m_shearing(sz = [0, 1]))
|
||||
cube(1);
|
||||
|
||||
translate([4, 0, 0]) multmatrix(m_shearing(sz = [1, 1]))
|
||||
cube(1);
|
||||
}
|
||||
|
||||

|
||||
|
20
docs/lib-m_translation.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# m_translation
|
||||
|
||||
Generate a 4x4 transformation matrix which can pass into `multmatrix` to translates (moves) its child elements along the specified vector.
|
||||
|
||||
**Since:** 1.1
|
||||
|
||||
## Parameters
|
||||
|
||||
- `v` : Elements will be translated along the vector.
|
||||
|
||||
## Examples
|
||||
|
||||
include <m_translation.scad>;
|
||||
|
||||
cube(2, center = true);
|
||||
multmatrix(m_translation([5, 0, 0]))
|
||||
sphere(1,center = true);
|
||||
|
||||

|
||||
|
@@ -13,7 +13,7 @@ When using this module, you should use points to represent the 2D shape. If your
|
||||
- `triangles` : `"SOLID"` (default), `"HOLLOW"` or user-defined indexes. See example below.
|
||||
- `twist` : The number of degrees of through which the shape is extruded.
|
||||
- `scale` : Scales the 2D shape by this value over the length of the extrusion. Scale can be a scalar or a vector.
|
||||
- `closed` : If the first point and the last point of `path_pts` has the same coordinate, setting `closed` to `true` will connect them automatically.
|
||||
- `closed` : If the first point and the last point of `path_pts` has the same coordinate, setting `closed` to `true` will connect them automatically. You might have to set `twist` for connecting naturally.
|
||||
|
||||
## Examples
|
||||
|
||||
|
133
docs/lib-path_scaling_sections.md
Normal file
@@ -0,0 +1,133 @@
|
||||
# path_scaling_sections
|
||||
|
||||
Given an edge path with the first point at the outline of a shape. This function uses the path to calculate scaling factors and returns all scaled sections in the reversed order of the edge path. Combined with the `polysections` module, you can create an extrusion with the path as an edge.
|
||||
|
||||
In order to control scaling factors easily, I suggest using `[x, 0, 0]` as the first point and keeping y = 0 while building the edge path.
|
||||
|
||||
You can use any point as the first point of the edge path. Just remember that your edge path radiates from the origin.
|
||||
|
||||
**Since:** 1.2.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `shape_pts` : A list of points represent a shape.
|
||||
- `edge_path` : A list of points represent the edge path.
|
||||
|
||||
## Examples
|
||||
|
||||
include <hull_polyline3d.scad>;
|
||||
include <shape_taiwan.scad>;
|
||||
include <path_scaling_sections.scad>;
|
||||
include <m_scaling.scad>;
|
||||
include <polysections.scad>;
|
||||
|
||||
taiwan = shape_taiwan(100);
|
||||
fst_pt = [13, 0, 0];
|
||||
|
||||
edge_path = [
|
||||
fst_pt,
|
||||
fst_pt + [0, 0, 10],
|
||||
fst_pt + [10, 0, 20],
|
||||
fst_pt + [8, 0, 30],
|
||||
fst_pt + [12, 0, 40],
|
||||
fst_pt + [0, 0, 50],
|
||||
fst_pt + [0, 0, 60]
|
||||
];
|
||||
|
||||
#hull_polyline3d(edge_path);
|
||||
polysections(path_scaling_sections(taiwan, edge_path));
|
||||
|
||||

|
||||
|
||||
include <hull_polyline3d.scad>;
|
||||
include <shape_taiwan.scad>;
|
||||
include <path_scaling_sections.scad>;
|
||||
include <m_scaling.scad>;
|
||||
include <polysections.scad>;
|
||||
include <bezier_curve.scad>;
|
||||
|
||||
|
||||
taiwan = shape_taiwan(100);
|
||||
fst_pt = [13, 0, 0];
|
||||
|
||||
edge_path = bezier_curve(0.05, [
|
||||
fst_pt,
|
||||
fst_pt + [0, 0, 10],
|
||||
fst_pt + [10, 0, 20],
|
||||
fst_pt + [8, 0, 30],
|
||||
fst_pt + [12, 0, 40],
|
||||
fst_pt + [0, 0, 50],
|
||||
fst_pt + [0, 0, 60]
|
||||
]);
|
||||
|
||||
#hull_polyline3d(edge_path);
|
||||
polysections(path_scaling_sections(taiwan, edge_path));
|
||||
|
||||

|
||||
|
||||
include <shape_taiwan.scad>;
|
||||
include <path_scaling_sections.scad>;
|
||||
include <m_scaling.scad>;
|
||||
include <polysections.scad>;
|
||||
include <bezier_curve.scad>;
|
||||
include <rotate_p.scad>;
|
||||
|
||||
taiwan = shape_taiwan(100);
|
||||
fst_pt = [13, 0, 0];
|
||||
|
||||
edge_path = bezier_curve(0.05, [
|
||||
fst_pt,
|
||||
fst_pt + [0, 0, 10],
|
||||
fst_pt + [10, 0, 20],
|
||||
fst_pt + [8, 0, 30],
|
||||
fst_pt + [12, 0, 40],
|
||||
fst_pt + [0, 0, 50],
|
||||
fst_pt + [0, 0, 60]
|
||||
]);
|
||||
|
||||
leng = len(edge_path);
|
||||
twist = -90;
|
||||
twist_step = twist / leng;
|
||||
sections = path_scaling_sections(taiwan, edge_path);
|
||||
|
||||
rotated_sections = [
|
||||
for(i = [0:leng - 1])
|
||||
[
|
||||
for(p = sections[i])
|
||||
rotate_p(p, twist_step * i)
|
||||
]
|
||||
];
|
||||
|
||||
polysections(rotated_sections);
|
||||
|
||||

|
||||
|
||||
include <hull_polyline3d.scad>;
|
||||
include <shape_taiwan.scad>;
|
||||
include <path_scaling_sections.scad>;
|
||||
include <m_scaling.scad>;
|
||||
include <polysections.scad>;
|
||||
include <rotate_p.scad>;
|
||||
|
||||
taiwan = shape_taiwan(100);
|
||||
|
||||
/*
|
||||
You can use any point as the first point of the edge path.
|
||||
Just remember that your edge path radiates from the origin.
|
||||
*/
|
||||
fst_pt = [taiwan[0][0], taiwan[0][1], 0];//[13, 0, 0];
|
||||
a = atan2(fst_pt[1], fst_pt[0]);
|
||||
edge_path = [
|
||||
fst_pt,
|
||||
fst_pt + rotate_p([0, 0, 10], a),
|
||||
fst_pt + rotate_p([10, 0, 20], a),
|
||||
fst_pt + rotate_p([8, 0, 30], a),
|
||||
fst_pt + rotate_p([10, 0, 40], a),
|
||||
fst_pt + rotate_p([0, 0, 50], a),
|
||||
fst_pt + rotate_p([0, 0, 60], a)
|
||||
];
|
||||
|
||||
#hull_polyline3d(edge_path);
|
||||
polysections(path_scaling_sections(taiwan, edge_path));
|
||||
|
||||

|
@@ -1,11 +1,12 @@
|
||||
# rotate_p
|
||||
|
||||
Rotates a point `a` degrees around an arbitrary axis. It behaves as the built-in `rotate` module
|
||||
Rotates a point `a` degrees about the axis of the coordinate system or around an arbitrary axis. It behaves as the built-in `rotate` module
|
||||
|
||||
## Parameters
|
||||
|
||||
- `point` : A 3D point `[x, y, z]` or a 2D point `[x, y]`.
|
||||
- `a` : If it's `[deg_x, deg_y, deg_z]`, the rotation is applied in the order `x`, `y`, `z`. If it's `[deg_x, deg_y]`, the rotation is applied in the order `x`, `y`. If it's`[deg_x]`, the rotation is only applied to the `x` axis. If it's an number, the rotation is only applied to the `z` axis.
|
||||
- `a` : If it's `[deg_x, deg_y, deg_z]`, the rotation is applied in the order `x`, `y`, `z`. If it's `[deg_x, deg_y]`, the rotation is applied in the order `x`, `y`. If it's`[deg_x]`, the rotation is only applied to the `x` axis. If it's an number, the rotation is only applied to the `z` axis or an arbitrary axis.
|
||||
- `v`: A vector allows you to set an arbitrary axis about which the object will be rotated. When `a` is an array, the `v` argument is ignored. **Since:** 1.1.
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -60,4 +61,22 @@ The `rotate_p` function is useful in some situations. For example, you probably
|
||||
|
||||
%sphere(radius);
|
||||
|
||||

|
||||

|
||||
|
||||
include <rotate_p.scad>;
|
||||
|
||||
v = [10, 10, 10];
|
||||
|
||||
hull() {
|
||||
sphere(1);
|
||||
translate(v)
|
||||
sphere(1);
|
||||
}
|
||||
|
||||
p = [10, 10, 0];
|
||||
for(i = [0:20:340]) {
|
||||
translate(rotate_p(p, a = i, v = v))
|
||||
sphere(1);
|
||||
}
|
||||
|
||||

|
@@ -6,6 +6,7 @@ Returns shape points of a regular cyclic polygon. They can be used with xxx_extr
|
||||
|
||||
- `sides` : The radius of the circle.
|
||||
- `circle_r` : The radius of the circumcircle.
|
||||
- `corner_r` : The radius of the circle at a corner.
|
||||
- `$fa`, `$fs`, `$fn` : Check [the circle module](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#circle) for more details.
|
||||
|
||||
## Examples
|
||||
|
@@ -6,7 +6,7 @@ Returns shape points of a star. They can be used with xxx_extrude modules of dot
|
||||
|
||||
- `r1` : The outer radius of the starburst.
|
||||
- `r2` : The inner radius of the starburst.
|
||||
- `n` : The number of vertices.
|
||||
- `n` : The burst number.
|
||||
|
||||
|
||||
## Examples
|
||||
|
52
docs/lib-shear.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# shear
|
||||
|
||||
Shear all child elements along the X-axis, Y-axis, or Z-axis in 3D.
|
||||
|
||||
**Since:** 1.1
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
- `sx` : An array `[SHy, SHz]`. The new coordinates of child elements are `(x + SHy * y + SHz * z, y, z)`.
|
||||
- `sy` : An array `[SHx, SHz]`. The new coordinates of child elements are `(x, y + SHx * x + SHz * z, z)`.
|
||||
- `sz` : An array `[SHx, SHy]`. The new coordinates of child elements are `(x, y, z + SHx * x + SHy * y)`.
|
||||
|
||||
## Examples
|
||||
|
||||
include <shear.scad>;
|
||||
|
||||
color("red") {
|
||||
shear(sx = [1, 0])
|
||||
cube(1);
|
||||
|
||||
translate([2, 0, 0]) shear(sx = [0, 1])
|
||||
cube(1);
|
||||
|
||||
translate([4, 0, 0]) shear(sx = [1, 1])
|
||||
cube(1);
|
||||
}
|
||||
|
||||
translate([0, -3, 0]) color("green") {
|
||||
shear(sy = [1, 0])
|
||||
cube(1);
|
||||
|
||||
translate([2, 0, 0]) shear(sy = [0, 1])
|
||||
cube(1);
|
||||
|
||||
translate([4, 0, 0]) shear(sy = [1, 1])
|
||||
cube(1);
|
||||
}
|
||||
|
||||
translate([0, -5, 0]) color("blue") {
|
||||
shear(sz = [1, 0])
|
||||
cube(1);
|
||||
|
||||
translate([2, 0, 0]) shear(sz = [0, 1])
|
||||
cube(1);
|
||||
|
||||
translate([4, 0, 0]) shear(sz = [1, 1])
|
||||
cube(1);
|
||||
}
|
||||
|
||||

|
||||
|
24
docs/lib-starburst.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# starburst
|
||||
|
||||
A 3D version of `shape_starburst`.
|
||||
|
||||
**Since:** 1.2.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `r1` : The outer radius of the starburst.
|
||||
- `r2` : The inner radius of the starburst.
|
||||
- `n` : The number of vertices.
|
||||
- `height` : The height of the starburst.
|
||||
|
||||
## Examples
|
||||
|
||||
include <starburst.scad>;
|
||||
|
||||
starburst(10, 5, 5, 5);
|
||||
translate([20, 0, 0]) starburst(10, 5, 6, 5);
|
||||
translate([40, 0, 0]) starburst(10, 5, 12, 10);
|
||||
translate([60, 0, 0]) starburst(10, 5, 4, 3);
|
||||
|
||||

|
||||
|
40
docs/lib-torus_knot.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# torus_knot
|
||||
|
||||
Generate a path of [The (p,q)-torus knot](https://en.wikipedia.org/wiki/Torus_knot).
|
||||
|
||||
**Since:** 1.2.
|
||||
|
||||

|
||||
|
||||
## Parameters
|
||||
|
||||
- `p` : The p parameter of The (p,q)-torus knot.
|
||||
- `q` : The q parameter of The (p,q)-torus knot.
|
||||
- `phi_step` : The amount when increasing phi.
|
||||
|
||||
## Examples
|
||||
|
||||
include <shape_pentagram.scad>;
|
||||
include <rotate_p.scad>;
|
||||
include <polysections.scad>;
|
||||
include <path_extrude.scad>;
|
||||
include <torus_knot.scad>;
|
||||
|
||||
p = 2;
|
||||
q = 3;
|
||||
phi_step = 0.05;
|
||||
star_radius = 0.5;
|
||||
|
||||
pts = torus_knot(p, q, phi_step);
|
||||
|
||||
shape_pentagram_pts = shape_pentagram(star_radius);
|
||||
|
||||
path_extrude(
|
||||
shape_pentagram_pts,
|
||||
concat(pts, [pts[0]]),
|
||||
closed = true,
|
||||
twist = 188
|
||||
);
|
||||
|
||||

|
||||
|
@@ -44,9 +44,9 @@ function __br_corner(frags, b_ang, l1, l2, h, round_r) =
|
||||
|
||||
function __half_trapezium(length, h, round_r) =
|
||||
let(
|
||||
is_vt = __is_vector(length),
|
||||
l1 = is_vt ? length[0] : length,
|
||||
l2 = is_vt ? length[1] : length,
|
||||
is_flt = __is_float(length),
|
||||
l1 = is_flt ? length : length[0],
|
||||
l2 = is_flt ? length : length[1],
|
||||
frags = __frags(round_r),
|
||||
b_ang = atan2(h, l1 - l2),
|
||||
br_corner = __br_corner(frags, b_ang, l1, l2, h, round_r),
|
||||
|
@@ -1,6 +0,0 @@
|
||||
function __length_between(p1, p2) =
|
||||
let(
|
||||
dx = p2[0] - p1[0],
|
||||
dy = p2[1] - p1[1],
|
||||
dz = p2[2] - p1[2]
|
||||
) sqrt(pow(dx, 2) + pow(dy, 2) + pow(dz, 2));
|
15
src/__private__/__m_shearing.scad
Normal file
@@ -0,0 +1,15 @@
|
||||
function __m_shearing(sx, sy, sz) =
|
||||
let(
|
||||
sx_along_y = sx[0],
|
||||
sx_along_z = sx[1],
|
||||
sy_along_x = sy[0],
|
||||
sy_along_z = sy[1],
|
||||
sz_along_x = sz[0],
|
||||
sz_along_y = sz[1]
|
||||
)
|
||||
[
|
||||
[1, sx_along_y, sx_along_z, 0],
|
||||
[sy_along_x, 1, sy_along_z, 0],
|
||||
[sz_along_x, sz_along_y, 1, 0],
|
||||
[0, 0, 0, 1]
|
||||
];
|
@@ -6,7 +6,7 @@ function __shape_arc(radius, angle, width, width_mode = "LINE_CROSS") =
|
||||
frags = __frags(radius),
|
||||
a_step = 360 / frags,
|
||||
half_a_step = a_step / 2,
|
||||
angles = __is_vector(angle) ? angle : [0, angle],
|
||||
angles = __is_float(angle) ? [0, angle] : angle,
|
||||
m = floor(angles[0] / a_step) + 1,
|
||||
n = floor(angles[1] / a_step),
|
||||
r_outer = radius + w_offset[0],
|
||||
|
@@ -3,7 +3,7 @@ function __shape_pie(radius, angle) =
|
||||
frags = __frags(radius),
|
||||
a_step = 360 / frags,
|
||||
leng = radius * cos(a_step / 2),
|
||||
angles = __is_vector(angle) ? angle : [0:angle],
|
||||
angles = __is_float(angle) ? [0:angle] : angle,
|
||||
m = floor(angles[0] / a_step) + 1,
|
||||
n = floor(angles[1] / a_step),
|
||||
edge_r_begin = leng / cos((m - 0.5) * a_step - angles[0]),
|
||||
|
7
src/__private__/__to_ang_vect.scad
Normal file
@@ -0,0 +1,7 @@
|
||||
function __to_3_elems_ang_vect(a) =
|
||||
let(leng = len(a))
|
||||
leng == 3 ? a : (
|
||||
leng == 2 ? [a[0], a[1], 0] : [a[0], 0, 0]
|
||||
);
|
||||
|
||||
function __to_ang_vect(a) = __is_float(a) ? [0, 0, a] : __to_3_elems_ang_vect(a);
|
@@ -1,20 +1,21 @@
|
||||
/**
|
||||
* along_with.scad
|
||||
*
|
||||
* Puts children along the given path. If there's only one child,
|
||||
* it will put the child for each point.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-along_with.html
|
||||
*
|
||||
**/
|
||||
|
||||
|
||||
include <__private__/__angy_angz.scad>;
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
include <__private__/__to3d.scad>;
|
||||
|
||||
// Becuase of improving the performance, this module requires m_rotation.scad which doesn't require in dotSCAD 1.0.
|
||||
// For backward compatibility, I directly include m_rotation here.
|
||||
include <m_rotation.scad>;
|
||||
|
||||
module along_with(points, angles, twist = 0, scale = 1.0) {
|
||||
leng_points = len(points);
|
||||
leng_points_minus_one = leng_points - 1;
|
||||
@@ -24,13 +25,62 @@ module along_with(points, angles, twist = 0, scale = 1.0) {
|
||||
let(s = (scale - 1) / leng_points_minus_one)
|
||||
[s, s, s];
|
||||
|
||||
scale_step_vt = __is_vector(scale) ?
|
||||
scale_step_vt = __is_float(scale) ?
|
||||
scale_step() :
|
||||
[
|
||||
(scale[0] - 1) / leng_points_minus_one,
|
||||
(scale[1] - 1) / leng_points_minus_one,
|
||||
scale[2] == undef ? 0 : (scale[2] - 1) / leng_points_minus_one
|
||||
] : scale_step();
|
||||
];
|
||||
|
||||
// get rotation matrice for sections
|
||||
|
||||
identity_matrix = [
|
||||
[1, 0, 0, 0],
|
||||
[0, 1, 0, 0],
|
||||
[0, 0, 1, 0],
|
||||
[0, 0, 0, 1]
|
||||
];
|
||||
|
||||
function local_ang_vects(j) =
|
||||
j == 0 ? [] : local_ang_vects_sub(j);
|
||||
|
||||
function local_ang_vects_sub(j) =
|
||||
let(
|
||||
vt0 = points[j] - points[j - 1],
|
||||
vt1 = points[j + 1] - points[j],
|
||||
a = acos((vt0 * vt1) / (norm(vt0) * norm(vt1))),
|
||||
v = cross(vt0, vt1)
|
||||
)
|
||||
concat([[a, v]], local_ang_vects(j - 1));
|
||||
|
||||
function cumulated_rot_matrice(i, rot_matrice) =
|
||||
let(
|
||||
leng_rot_matrice = len(rot_matrice),
|
||||
leng_rot_matrice_minus_one = leng_rot_matrice - 1,
|
||||
leng_rot_matrice_minus_two = leng_rot_matrice - 2
|
||||
)
|
||||
leng_rot_matrice == 0 ? [identity_matrix] : (
|
||||
leng_rot_matrice == 1 ? [rot_matrice[0], identity_matrix] : (
|
||||
i == leng_rot_matrice_minus_two ?
|
||||
[
|
||||
rot_matrice[leng_rot_matrice_minus_one],
|
||||
rot_matrice[leng_rot_matrice_minus_two] * rot_matrice[leng_rot_matrice_minus_one]
|
||||
]
|
||||
: cumulated_rot_matrice_sub(i, rot_matrice)
|
||||
)
|
||||
);
|
||||
|
||||
function cumulated_rot_matrice_sub(i, rot_matrice) =
|
||||
let(
|
||||
matrice = cumulated_rot_matrice(i + 1, rot_matrice),
|
||||
curr_matrix = rot_matrice[i],
|
||||
prev_matrix = matrice[len(matrice) - 1]
|
||||
)
|
||||
concat(matrice, [curr_matrix * prev_matrix]);
|
||||
|
||||
// align modules
|
||||
|
||||
module align_with_pts_angles(i) {
|
||||
translate(points[i])
|
||||
rotate(angles[i])
|
||||
@@ -48,20 +98,17 @@ module along_with(points, angles, twist = 0, scale = 1.0) {
|
||||
children(0);
|
||||
}
|
||||
|
||||
module align_with_pts_local_rotate(j, init_a, init_s) {
|
||||
module align_with_pts_local_rotate(j, init_a, init_s, cumu_rot_matrice) {
|
||||
if(j == 0) { // first child
|
||||
align_with_pts_init(init_a, init_s)
|
||||
children(0);
|
||||
}
|
||||
else {
|
||||
vt0 = points[j] - points[j - 1];
|
||||
vt1 = points[j + 1] - points[j];
|
||||
a = acos((vt0 * vt1) / (norm(vt0) * norm(vt1)));
|
||||
rotate(a, cross(vt0, vt1))
|
||||
align_with_pts_local_rotate(j - 1, init_a, init_s)
|
||||
multmatrix(cumu_rot_matrice[j - 1])
|
||||
align_with_pts_init(init_a, init_s)
|
||||
children(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(angles != undef) {
|
||||
if($children == 1) {
|
||||
@@ -75,23 +122,27 @@ module along_with(points, angles, twist = 0, scale = 1.0) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
cumu_rot_matrice = cumulated_rot_matrice(0, [
|
||||
for(ang_vect = local_ang_vects(leng_points - 2))
|
||||
m_rotation(ang_vect[0], ang_vect[1])
|
||||
]);
|
||||
|
||||
translate(points[0])
|
||||
align_with_pts_local_rotate(0, 0, [1, 1, 1])
|
||||
align_with_pts_local_rotate(0, 0, [1, 1, 1], cumu_rot_matrice)
|
||||
children(0);
|
||||
|
||||
if($children == 1) {
|
||||
for(i = [0:leng_points - 2]) {
|
||||
translate(points[i + 1])
|
||||
align_with_pts_local_rotate(i, i * twist_step_a, [1, 1, 1] + scale_step_vt * i)
|
||||
align_with_pts_local_rotate(i, i * twist_step_a, [1, 1, 1] + scale_step_vt * i, cumu_rot_matrice)
|
||||
children(0);
|
||||
}
|
||||
} else {
|
||||
for(i = [0:min(leng_points, $children) - 2]) {
|
||||
translate(points[i + 1])
|
||||
align_with_pts_local_rotate(i, i * twist_step_a, [1, 1, 1] + scale_step_vt * i)
|
||||
align_with_pts_local_rotate(i, i * twist_step_a, [1, 1, 1] + scale_step_vt * i, cumu_rot_matrice)
|
||||
children(i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* arc.scad
|
||||
*
|
||||
* Creates an arc. You can pass a 2 element vector to define the central angle.
|
||||
* Its $fa, $fs and $fn parameters are consistent with the circle module.
|
||||
* It depends on the circular_sector module so you have to include circular_sector.scad.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -13,7 +9,7 @@
|
||||
**/
|
||||
|
||||
include <__private__/__frags.scad>;
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
include <__private__/__ra_to_xy.scad>;
|
||||
include <__private__/__edge_r.scad>;
|
||||
include <__private__/__shape_arc.scad>;
|
||||
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* arc_shape.scad
|
||||
*
|
||||
* Creates an arc. You can pass a 2 element vector to define the central angle.
|
||||
* Its $fa, $fs and $fn parameters are consistent with the circle module.
|
||||
* It depends on the circular_sector module so you have to include circular_sector.scad.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -13,7 +9,7 @@
|
||||
**/
|
||||
|
||||
include <__private__/__frags.scad>;
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
include <__private__/__ra_to_xy.scad>;
|
||||
include <__private__/__edge_r.scad>;
|
||||
|
||||
@@ -21,7 +17,7 @@ function arc_path(radius, angle) =
|
||||
let(
|
||||
frags = __frags(radius),
|
||||
a_step = 360 / frags,
|
||||
angles = __is_vector(angle) ? angle : [0, angle],
|
||||
angles = __is_float(angle) ? [0, angle] : angle,
|
||||
m = floor(angles[0] / a_step) + 1,
|
||||
n = floor(angles[1] / a_step),
|
||||
points = concat([__ra_to_xy(__edge_r_begin(radius, angles[0], a_step, m), angles[0])],
|
||||
|
@@ -1,17 +1,5 @@
|
||||
/**
|
||||
* archimedean_spiral.scad
|
||||
*
|
||||
* Gets all points and angles on the path of an archimedean spiral. The distance between two points is almost constant.
|
||||
*
|
||||
* It returns a vector of [[x, y], angle].
|
||||
*
|
||||
* In polar coordinates (r, <20>c) Archimedean spiral can be described by the equation r = b<>c where
|
||||
* <20>c is measured in radians. For being consistent with OpenSCAD, the function here use degrees.
|
||||
*
|
||||
* An init_angle less than 180 degrees is not recommended because the function uses an approximate
|
||||
* approach. If you really want an init_angle less than 180 degrees, a larger arm_distance
|
||||
* is required. To avoid a small error value at the calculated distance between two points, you
|
||||
* may try a smaller point_distance.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* archimedean_spiral_extrude.scad
|
||||
*
|
||||
* Extrudes a 2D shape along the path of a archimedean spiral.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,7 +1,5 @@
|
||||
/**
|
||||
* bend.scad
|
||||
*
|
||||
* Bends a 3D object into an arc shape.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* bezier_curve.scad
|
||||
*
|
||||
* Given a set of control points, the bezier_curve function returns points of the Bézier path.
|
||||
* Combined with the polyline, polyline3d or hull_polyline3d module defined in my lib-openscad,
|
||||
* you can create a Bézier curve.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* bezier_smooth.scad
|
||||
*
|
||||
* Given a path, the bezier_smooth function uses bazier curves to smooth all corners.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,12 +1,6 @@
|
||||
/**
|
||||
* bezier_surface.scad
|
||||
*
|
||||
* Given a set of control points, the bezier_surface function returns points of the Bézier surface.
|
||||
* Combined with the function_grapher module defined in my lib-openscad,
|
||||
* you can create a Bézier surface.
|
||||
*
|
||||
* It depends on the bezier_curve function so remember to include bezier_curve.scad.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
86
src/bijection_offset.scad
Normal file
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* bijection_offset.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2019
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-bijection_offset.html
|
||||
*
|
||||
**/
|
||||
|
||||
function _bijection_edges_from(pts) =
|
||||
let(leng = len(pts))
|
||||
concat(
|
||||
[for(i = [0:leng - 2]) [pts[i], pts[i + 1]]],
|
||||
[[pts[len(pts) - 1], pts[0]]]
|
||||
);
|
||||
|
||||
function _bijection_inward_edge_normal(edge) =
|
||||
let(
|
||||
pt1 = edge[0],
|
||||
pt2 = edge[1],
|
||||
dx = pt2[0] - pt1[0],
|
||||
dy = pt2[1] - pt1[1],
|
||||
edge_leng = norm([dx, dy])
|
||||
)
|
||||
[-dy / edge_leng, dx / edge_leng];
|
||||
|
||||
function _bijection_outward_edge_normal(edge) = -1 * _bijection_inward_edge_normal(edge);
|
||||
|
||||
function _bijection_offset_edge(edge, dx, dy) =
|
||||
let(
|
||||
pt1 = edge[0],
|
||||
pt2 = edge[1],
|
||||
dxy = [dx, dy]
|
||||
)
|
||||
[pt1 + dxy, pt2 + dxy];
|
||||
|
||||
function _bijection__bijection_offset_edges(edges, d) =
|
||||
[
|
||||
for(edge = edges)
|
||||
let(
|
||||
ow_normal = _bijection_outward_edge_normal(edge),
|
||||
dx = ow_normal[0] * d,
|
||||
dy = ow_normal[1] * d
|
||||
)
|
||||
_bijection_offset_edge(edge, dx, dy)
|
||||
];
|
||||
|
||||
|
||||
function _bijection__bijection__bijection_offset_edges_intersection(edge1, edge2) =
|
||||
let(
|
||||
den = (edge2[1][1] - edge2[0][1]) * (edge1[1][0] - edge1[0][0]) - (edge2[1][0] - edge2[0][0]) * (edge1[1][1] - edge1[0][1])
|
||||
)
|
||||
// when den is 0, they are parallel or conincident edges
|
||||
den == 0 ? [] : _bijection_offset__bijection__bijection__bijection_offset_edges_intersection_sub(edge1, edge2, den);
|
||||
|
||||
function _bijection_offset__bijection__bijection__bijection_offset_edges_intersection_sub(edge1, edge2, den) =
|
||||
let(
|
||||
ua = ((edge2[1][0] - edge2[0][0]) * (edge1[0][1] - edge2[0][1]) - (edge2[1][1] - edge2[0][1]) * (edge1[0][0] - edge2[0][0])) / den
|
||||
)
|
||||
[
|
||||
edge1[0][0] + ua * (edge1[1][0] - edge1[0][0]),
|
||||
edge1[0][1] + ua * (edge1[1][1] - edge1[0][1])
|
||||
];
|
||||
|
||||
function bijection_offset(pts, d) =
|
||||
let(
|
||||
es = _bijection_edges_from(pts),
|
||||
offset_es = _bijection__bijection_offset_edges(es, d),
|
||||
leng = len(offset_es),
|
||||
last_p = _bijection__bijection__bijection_offset_edges_intersection(offset_es[leng - 1], offset_es[0])
|
||||
)
|
||||
concat(
|
||||
[
|
||||
for(i = [0:leng - 2])
|
||||
let(
|
||||
this_edge = offset_es[i],
|
||||
next_edge = offset_es[i + 1],
|
||||
p = _bijection__bijection__bijection_offset_edges_intersection(this_edge, next_edge)
|
||||
)
|
||||
// p == p to avoid [nan, nan], because [nan, nan] != [nan, nan]
|
||||
if(p != [] && p == p) p
|
||||
],
|
||||
last_p != [] && last_p == last_p ? [last_p] : []
|
||||
);
|
||||
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* box_extrude.scad
|
||||
*
|
||||
* Creates a box (container) from a 2D object.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* circle_path.scad
|
||||
*
|
||||
* Sometimes you need all points on the path of a circle. Here's
|
||||
* the function. Its $fa, $fs and $fn parameters are consistent
|
||||
* with the circle module.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,9 +1,6 @@
|
||||
/**
|
||||
* cross_sections.scad
|
||||
*
|
||||
* Given a 2D shape, points and angles along the path, this function
|
||||
* will return all cross-sections.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -12,16 +9,17 @@
|
||||
**/
|
||||
|
||||
include <__private__/__to3d.scad>;
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
|
||||
function cross_sections(shape_pts, path_pts, angles, twist = 0, scale = 1.0) =
|
||||
let(
|
||||
len_path_pts_minus_one = len(path_pts) - 1,
|
||||
sh_pts = len(shape_pts[0]) == 3 ? shape_pts : [for(p = shape_pts) __to3d(p)],
|
||||
pth_pts = len(path_pts[0]) == 3 ? path_pts : [for(p = path_pts) __to3d(p)],
|
||||
scale_step_vt = __is_vector(scale) ?
|
||||
[(scale[0] - 1) / len_path_pts_minus_one, (scale[1] - 1) / len_path_pts_minus_one] :
|
||||
[(scale - 1) / len_path_pts_minus_one, (scale - 1) / len_path_pts_minus_one],
|
||||
scale_step_vt = __is_float(scale) ?
|
||||
[(scale - 1) / len_path_pts_minus_one, (scale - 1) / len_path_pts_minus_one] :
|
||||
[(scale[0] - 1) / len_path_pts_minus_one, (scale[1] - 1) / len_path_pts_minus_one]
|
||||
,
|
||||
scale_step_x = scale_step_vt[0],
|
||||
scale_step_y = scale_step_vt[1],
|
||||
twist_step = twist / len_path_pts_minus_one
|
||||
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* crystal_ball.scad
|
||||
*
|
||||
* Uses Spherical coordinate system to create a crystal ball.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -11,10 +9,10 @@
|
||||
**/
|
||||
|
||||
include <__private__/__nearest_multiple_of_4.scad>;
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
|
||||
module crystal_ball(radius, theta = 360, phi = 180) {
|
||||
phis = __is_vector(phi) ? phi : [0, phi];
|
||||
phis = __is_float(phi) ? [0, phi] : phi;
|
||||
|
||||
frags = __frags(radius);
|
||||
|
||||
|
@@ -1,9 +1,6 @@
|
||||
/**
|
||||
* ellipse_extrude.scad
|
||||
*
|
||||
* Extrudes a 2D object along the path of an ellipse from 0 to 180 degrees.
|
||||
* The semi-major axis is not necessary because it's eliminated while calculating.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,13 +1,6 @@
|
||||
/**
|
||||
* function_grapher.scad
|
||||
*
|
||||
*
|
||||
* Given a set of points `[x, y, f(x, y)]` where `f(x, y)` is a
|
||||
* mathematics function, the `function_grapher` module can
|
||||
* create the graph of `f(x, y)`.
|
||||
* It depends on the line3d, polyline3d, hull_polyline3d modules so you have
|
||||
* to include "line3d.scad", "polyline3d.scad", "hull_polyline3d.scad".
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* golden_spiral.scad
|
||||
*
|
||||
* Gets all points and angles on the path of a golden spiral. The distance between two points is almost constant.
|
||||
*
|
||||
* It returns a vector of [[x, y], angle].
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* golden_spiral_extrude.scad
|
||||
*
|
||||
* Extrudes a 2D shape along the path of a golden spiral.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* helix.scad
|
||||
*
|
||||
* Gets all points on the path of a spiral around a cylinder.
|
||||
* Its $fa, $fs and $fn parameters are consistent with the cylinder module.
|
||||
* It depends on the circle_path module so you have to include circle_path.scad.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -12,14 +8,14 @@
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
include <__private__/__frags.scad>;
|
||||
|
||||
function helix(radius, levels, level_dist, vt_dir = "SPI_DOWN", rt_dir = "CT_CLK") =
|
||||
let(
|
||||
is_vt = __is_vector(radius),
|
||||
r1 = is_vt ? radius[0] : radius,
|
||||
r2 = is_vt ? radius[1] : radius,
|
||||
is_flt = __is_float(radius),
|
||||
r1 = is_flt ? radius : radius[0],
|
||||
r2 = is_flt ? radius : radius[1],
|
||||
init_r = vt_dir == "SPI_DOWN" ? r2 : r1,
|
||||
_frags = __frags(init_r),
|
||||
h = level_dist * levels,
|
||||
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* helix_extrude.scad
|
||||
*
|
||||
* Extrudes a 2D shape along a helix path.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -10,7 +8,7 @@
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
include <__private__/__frags.scad>;
|
||||
|
||||
module helix_extrude(shape_pts, radius, levels, level_dist,
|
||||
@@ -24,9 +22,9 @@ module helix_extrude(shape_pts, radius, levels, level_dist,
|
||||
vt[leng - 1 - i]
|
||||
];
|
||||
|
||||
is_vt = __is_vector(radius);
|
||||
r1 = is_vt ? radius[0] : radius;
|
||||
r2 = is_vt ? radius[1] : radius;
|
||||
is_flt = __is_float(radius);
|
||||
r1 = is_flt ? radius : radius[0];
|
||||
r2 = is_flt ? radius : radius[1];
|
||||
|
||||
init_r = vt_dir == "SPI_DOWN" ? r2 : r1;
|
||||
|
||||
|
@@ -1,9 +1,6 @@
|
||||
/**
|
||||
* hexagons.scad
|
||||
*
|
||||
* A hexagonal structure is useful in many situations.
|
||||
* This module creates hexagons in a hexagon.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* hollow_out.scad
|
||||
*
|
||||
* Hollows out a 2D object.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* hull_polyline2d.scad
|
||||
*
|
||||
* Creates a 2D polyline from a list of `[x, y]` coordinates.
|
||||
* As the name says, it uses the built-in hull operation for each pair of points (created by the circle module).
|
||||
* It's slow. However, it can be used to create metallic effects for a small $fn, large $fa or $fs.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* hull_polyline3d.scad
|
||||
*
|
||||
* Creates a 3D polyline from a list of `[x, y, z]` coordinates.
|
||||
* As the name says, it uses the built-in hull operation for each pair of points (created by the sphere module).
|
||||
* It's slow. However, it can be used to create metallic effects for a small $fn, large $fa or $fs.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* line2d.scad
|
||||
*
|
||||
* Creates a line from two points.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* line3d.scad
|
||||
*
|
||||
* Creates a 3D line from two points.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* log.scad
|
||||
*
|
||||
* A log module which supports simple level configurations and color titles.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
18
src/m_cumulate.scad
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* m_cumulate.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2019
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-m_cumulate.html
|
||||
*
|
||||
**/
|
||||
|
||||
function _m_cumulate(matrice, i) =
|
||||
i == len(matrice) - 2 ?
|
||||
matrice[i] * matrice[i + 1] :
|
||||
matrice[i] * _m_cumulate(matrice, i + 1);
|
||||
|
||||
function m_cumulate(matrice) =
|
||||
len(matrice) == 1 ? matrice[0] : _m_cumulate(matrice, 0);
|
||||
|
26
src/m_mirror.scad
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* m_mirror.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2019
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-m_mirror.html
|
||||
*
|
||||
**/
|
||||
|
||||
function m_mirror(v) =
|
||||
let(
|
||||
nv = v / norm(v),
|
||||
txx = -2* nv[0] * nv[0],
|
||||
txy = -2* nv[0] * nv[1],
|
||||
txz = -2* nv[0] * nv[2],
|
||||
tyy = -2* nv[1] * nv[1],
|
||||
tyz = -2* nv[1] * nv[2],
|
||||
tzz = -2* nv[2] * nv[2]
|
||||
)
|
||||
[
|
||||
[1 + txx, txy, txz, 0],
|
||||
[txy, 1 + tyy, tyz, 0],
|
||||
[txz, tyz, 1 + tzz, 0],
|
||||
[0, 0, 0, 1]
|
||||
];
|
82
src/m_rotation.scad
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* m_rotation.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2019
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-m_rotation.html
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__is_float.scad>;
|
||||
include <__private__/__to_ang_vect.scad>;
|
||||
|
||||
function _q_rotation(a, v) =
|
||||
let(
|
||||
half_a = a / 2,
|
||||
axis = v / norm(v),
|
||||
s = sin(half_a),
|
||||
x = s * axis[0],
|
||||
y = s * axis[1],
|
||||
z = s * axis[2],
|
||||
w = cos(half_a),
|
||||
|
||||
x2 = x + x,
|
||||
y2 = y + y,
|
||||
z2 = z + z,
|
||||
|
||||
xx = x * x2,
|
||||
yx = y * x2,
|
||||
yy = y * y2,
|
||||
zx = z * x2,
|
||||
zy = z * y2,
|
||||
zz = z * z2,
|
||||
wx = w * x2,
|
||||
wy = w * y2,
|
||||
wz = w * z2
|
||||
)
|
||||
[
|
||||
[1 - yy - zz, yx - wz, zx + wy, 0],
|
||||
[yx + wz, 1 - xx - zz, zy - wx, 0],
|
||||
[zx - wy, zy + wx, 1 - xx - yy, 0],
|
||||
[0, 0, 0, 1]
|
||||
];
|
||||
|
||||
function _m_xRotation(a) =
|
||||
let(c = cos(a), s = sin(a))
|
||||
[
|
||||
[1, 0, 0, 0],
|
||||
[0, c, -s, 0],
|
||||
[0, s, c, 0],
|
||||
[0, 0, 0, 1]
|
||||
];
|
||||
|
||||
function _m_yRotation(a) =
|
||||
let(c = cos(a), s = sin(a))
|
||||
[
|
||||
[c, 0, s, 0],
|
||||
[0, 1, 0, 0],
|
||||
[-s, 0, c, 0],
|
||||
[0, 0, 0, 1]
|
||||
];
|
||||
|
||||
function _m_zRotation(a) =
|
||||
let(c = cos(a), s = sin(a))
|
||||
[
|
||||
[c, -s, 0, 0],
|
||||
[s, c, 0, 0],
|
||||
[0, 0, 1, 0],
|
||||
[0, 0, 0, 1]
|
||||
];
|
||||
|
||||
function _xyz_rotation(a) =
|
||||
let(ang = __to_ang_vect(a))
|
||||
_m_zRotation(ang[2]) * _m_yRotation(ang[1]) * _m_xRotation(ang[0]);
|
||||
|
||||
function m_rotation(a, v) =
|
||||
(a == 0 || a == [0, 0, 0] || a == [0] || a == [0, 0]) ? [
|
||||
[1, 0, 0, 0],
|
||||
[0, 1, 0, 0],
|
||||
[0, 0, 1, 0],
|
||||
[0, 0, 0, 1]
|
||||
] : (v == undef ? _xyz_rotation(a) : _q_rotation(a, v));
|
28
src/m_scaling.scad
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* m_scaling.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2019
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-m_scaling.html
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__is_float.scad>;
|
||||
|
||||
function _to_3_elems_scaling_vect(s) =
|
||||
let(leng = len(s))
|
||||
leng == 3 ? s : (
|
||||
leng == 2 ? [s[0], s[1], 1] : [s[0], 1, 1]
|
||||
);
|
||||
|
||||
function _to_scaling_vect(s) = __is_float(s) ? [s, s, s] : _to_3_elems_scaling_vect(s);
|
||||
|
||||
function m_scaling(s) =
|
||||
let(v = _to_scaling_vect(s))
|
||||
[
|
||||
[v[0], 0, 0, 0],
|
||||
[0, v[1], 0, 0],
|
||||
[0, 0, v[2], 0],
|
||||
[0, 0, 0, 1]
|
||||
];
|
13
src/m_shearing.scad
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* m_shearing.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2019
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-m_shearing.html
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__m_shearing.scad>;
|
||||
|
||||
function m_shearing(sx = [0, 0], sy = [0, 0], sz = [0, 0]) = __m_shearing(sx, sy, sz);
|
28
src/m_translation.scad
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* m_translation.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2019
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-m_translation.html
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__is_float.scad>;
|
||||
|
||||
function _to_3_elems_translation_vect(v) =
|
||||
let(leng = len(v))
|
||||
leng == 3 ? v : (
|
||||
leng == 2 ? [v[0], v[1], 0] : [v[0], 0, 0]
|
||||
);
|
||||
|
||||
function _to_translation_vect(v) = __is_float(v) ? [v, 0, 0] : _to_3_elems_translation_vect(v);
|
||||
|
||||
function m_translation(v) =
|
||||
let(vt = _to_translation_vect(v))
|
||||
[
|
||||
[1, 0, 0, vt[0]],
|
||||
[0, 1, 0, vt[1]],
|
||||
[0, 0, 1, vt[2]],
|
||||
[0, 0, 0, 1]
|
||||
];
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* multi_line_text.scad
|
||||
*
|
||||
* Creates multi-line text from a list of strings.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* parse_number.scad
|
||||
*
|
||||
* Parses the string argument as an number.
|
||||
* It depends on the split_str and the sub_str functions
|
||||
* so remember to include split_str.scad and sub_str.scad.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,11 +1,6 @@
|
||||
/**
|
||||
* path_extrude.scad
|
||||
*
|
||||
* It extrudes a 2D shape along a path.
|
||||
* This module is suitable for a path created by a continuous function.
|
||||
* It depends on the rotate_p function and the polysections module.
|
||||
* Remember to include "rotate_p.scad" and "polysections.scad".
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -13,12 +8,16 @@
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
include <__private__/__to3d.scad>;
|
||||
include <__private__/__angy_angz.scad>;
|
||||
include <__private__/__length_between.scad>;
|
||||
|
||||
// Becuase of improving the performance, this module requires m_rotation.scad which doesn't require in dotSCAD 1.0.
|
||||
// For backward compatibility, I directly include m_rotation here.
|
||||
include <m_rotation.scad>;
|
||||
|
||||
module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale = 1.0, closed = false) {
|
||||
// pre-process parameters
|
||||
function scale_pts(pts, s) = [
|
||||
for(p = pts) [p[0] * s[0], p[1] * s[1], p[2] * s[2]]
|
||||
];
|
||||
@@ -40,13 +39,68 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
|
||||
let(s = (scale - 1) / len_path_pts_minus_one)
|
||||
[s, s, s];
|
||||
|
||||
scale_step_vt = __is_vector(scale) ?
|
||||
scale_step_vt = __is_float(scale) ?
|
||||
scale_step() :
|
||||
[
|
||||
(scale[0] - 1) / len_path_pts_minus_one,
|
||||
(scale[1] - 1) / len_path_pts_minus_one,
|
||||
scale[2] == undef ? 0 : (scale[2] - 1) / len_path_pts_minus_one
|
||||
] : scale_step();
|
||||
];
|
||||
|
||||
// get rotation matrice for sections
|
||||
|
||||
function local_ang_vects(j) =
|
||||
j == 0 ? [] : local_ang_vects_sub(j);
|
||||
|
||||
function local_ang_vects_sub(j) =
|
||||
let(
|
||||
vt0 = pth_pts[j] - pth_pts[j - 1],
|
||||
vt1 = pth_pts[j + 1] - pth_pts[j],
|
||||
a = acos((vt0 * vt1) / (norm(vt0) * norm(vt1))),
|
||||
v = cross(vt0, vt1)
|
||||
)
|
||||
concat([[a, v]], local_ang_vects(j - 1));
|
||||
|
||||
rot_matrice = [
|
||||
for(ang_vect = local_ang_vects(len_path_pts - 2))
|
||||
m_rotation(ang_vect[0], ang_vect[1])
|
||||
];
|
||||
|
||||
leng_rot_matrice = len(rot_matrice);
|
||||
leng_rot_matrice_minus_one = leng_rot_matrice - 1;
|
||||
leng_rot_matrice_minus_two= leng_rot_matrice - 2;
|
||||
|
||||
identity_matrix = [
|
||||
[1, 0, 0, 0],
|
||||
[0, 1, 0, 0],
|
||||
[0, 0, 1, 0],
|
||||
[0, 0, 0, 1]
|
||||
];
|
||||
|
||||
function cumulated_rot_matrice(i) =
|
||||
leng_rot_matrice == 0 ? [identity_matrix] : (
|
||||
leng_rot_matrice == 1 ? [rot_matrice[0], identity_matrix] :
|
||||
(
|
||||
i == leng_rot_matrice_minus_two ?
|
||||
[
|
||||
rot_matrice[leng_rot_matrice_minus_one],
|
||||
rot_matrice[leng_rot_matrice_minus_two] * rot_matrice[leng_rot_matrice_minus_one]
|
||||
]
|
||||
: cumulated_rot_matrice_sub(i))
|
||||
);
|
||||
|
||||
function cumulated_rot_matrice_sub(i) =
|
||||
let(
|
||||
matrice = cumulated_rot_matrice(i + 1),
|
||||
curr_matrix = rot_matrice[i],
|
||||
prev_matrix = matrice[len(matrice) - 1]
|
||||
)
|
||||
concat(matrice, [curr_matrix * prev_matrix]);
|
||||
|
||||
cumu_rot_matrice = cumulated_rot_matrice(0);
|
||||
|
||||
// get all sections
|
||||
|
||||
function init_section(a, s) =
|
||||
let(angleyz = __angy_angz(pth_pts[0], pth_pts[1]))
|
||||
rotate_pts(
|
||||
@@ -66,14 +120,17 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
|
||||
let(
|
||||
vt0 = pth_pts[j] - pth_pts[j - 1],
|
||||
vt1 = pth_pts[j + 1] - pth_pts[j],
|
||||
a = acos((vt0 * vt1) / (norm(vt0) * norm(vt1)))
|
||||
ms = cumu_rot_matrice[j - 1]
|
||||
)
|
||||
rotate_pts(
|
||||
local_rotate_section(j - 1, init_a, init_s),
|
||||
a,
|
||||
cross(vt0, vt1)
|
||||
);
|
||||
|
||||
[
|
||||
for(p = init_section(init_a, init_s))
|
||||
[
|
||||
[ms[0][0], ms[0][1], ms[0][2]] * p,
|
||||
[ms[1][0], ms[1][1], ms[1][2]] * p,
|
||||
[ms[2][0], ms[2][1], ms[2][2]] * p
|
||||
]
|
||||
];
|
||||
|
||||
function sections() =
|
||||
let(
|
||||
fst_section =
|
||||
@@ -93,7 +150,7 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
|
||||
sects = sections();
|
||||
|
||||
function calculated_sections() =
|
||||
closed && pth_pts[0] == pth_pts[len_path_pts - 1] ?
|
||||
closed && pth_pts[0] == pth_pts[len_path_pts_minus_one] ?
|
||||
concat(sects, [sects[0]]) : // round-robin
|
||||
sects;
|
||||
|
||||
|
30
src/path_scaling_sections.scad
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* path_scaling_sections.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2019
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-path_scaling_sections.html
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__reverse.scad>;
|
||||
|
||||
function path_scaling_sections(shape_pts, edge_path) =
|
||||
let(
|
||||
start_point = edge_path[0],
|
||||
base_leng = norm(start_point),
|
||||
scaling_matrice = [
|
||||
for(p = edge_path)
|
||||
let(s = norm([p[0], p[1], 0]) / base_leng)
|
||||
m_scaling([s, s, 1])
|
||||
]
|
||||
)
|
||||
__reverse([
|
||||
for(i = [0:len(edge_path) - 1])
|
||||
[
|
||||
for(p = shape_pts)
|
||||
let(scaled_p = scaling_matrice[i] * [p[0], p[1], edge_path[i][2], 1])
|
||||
[scaled_p[0], scaled_p[1], scaled_p[2]]
|
||||
]
|
||||
]);
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* paths2sections.scad
|
||||
*
|
||||
* Given a list of paths, this function will return all cross-sections described by those paths.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* pie.scad
|
||||
*
|
||||
* Creates a pie (circular sector). You can pass a 2 element vector to define the central angle. Its $fa, $fs and $fn parameters are consistent with the circle module.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -11,7 +9,7 @@
|
||||
**/
|
||||
|
||||
include <__private__/__frags.scad>;
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
include <__private__/__ra_to_xy.scad>;
|
||||
include <__private__/__shape_pie.scad>;
|
||||
|
||||
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* polyline2d.scad
|
||||
*
|
||||
* Creates a polyline from a list of x, y coordinates. When the end points are CAP_ROUND,
|
||||
* you can use $fa, $fs or $fn to controll the circle module used internally.
|
||||
* It depends on the line2d module so you have to include line2d.scad.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,9 +1,6 @@
|
||||
/**
|
||||
* polyline3d.scad
|
||||
*
|
||||
* Creates a 3D polyline from a list of `[x, y, z]` coordinates.
|
||||
* It depends on the line3d module so you have to include line3d.scad.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,9 +1,6 @@
|
||||
/**
|
||||
* polysections.scad
|
||||
*
|
||||
* Crosscutting a tube-like shape at different points gets several cross-sections.
|
||||
* This module can operate reversely. It uses cross-sections to construct a tube-like shape.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,9 +1,6 @@
|
||||
/**
|
||||
* polytransversals.scad
|
||||
*
|
||||
* Crosscutting a polyline at different points gets several transversals.
|
||||
* This module can operate reversely. It uses transversals to construct a polyline.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,9 +1,6 @@
|
||||
/**
|
||||
* ring_extrude.scad
|
||||
*
|
||||
* Rotational extrusion spins a 2D shape around the Z-axis.
|
||||
* It's similar to the built-in `rotate_extrude`; however, it supports angle, twist and scale options.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -22,7 +19,7 @@ module ring_extrude(shape_pts, radius, angle = 360, twist = 0, scale = 1.0, tria
|
||||
} else {
|
||||
a_step = 360 / __frags(radius);
|
||||
|
||||
angles = __is_vector(angle) ? angle : [0, angle];
|
||||
angles = __is_float(angle) ? [0, angle] : angle;
|
||||
|
||||
m = floor(angles[0] / a_step) + 1;
|
||||
n = floor(angles[1] / a_step);
|
||||
|
@@ -1,9 +1,6 @@
|
||||
/**
|
||||
* rotate_p.scad
|
||||
*
|
||||
* Rotates a point 'a' degrees around an arbitrary axis.
|
||||
* The rotation is applied in the following order: x, y, z.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -13,7 +10,8 @@
|
||||
|
||||
include <__private__/__to2d.scad>;
|
||||
include <__private__/__to3d.scad>;
|
||||
|
||||
include <__private__/__is_float.scad>;
|
||||
include <__private__/__to_ang_vect.scad>;
|
||||
|
||||
function _q_rotate_p_3d(p, a, v) =
|
||||
let(
|
||||
@@ -72,15 +70,8 @@ function _rotz(pt, a) =
|
||||
function _rotate_p_3d(point, a) =
|
||||
_rotz(_roty(_rotx(point, a[0]), a[1]), a[2]);
|
||||
|
||||
function to_avect(a) =
|
||||
len(a) == 3 ? a : (
|
||||
len(a) == 2 ? [a[0], a[1], 0] : (
|
||||
len(a) == 1 ? [a[0], 0, 0] : [0, 0, a]
|
||||
)
|
||||
);
|
||||
|
||||
function _rotate_p(p, a) =
|
||||
let(angle = to_avect(a))
|
||||
let(angle = __to_ang_vect(a))
|
||||
len(p) == 3 ?
|
||||
_rotate_p_3d(p, angle) :
|
||||
__to2d(
|
||||
|
@@ -1,9 +1,6 @@
|
||||
/**
|
||||
* rounded_cube.scad
|
||||
*
|
||||
* Creates a rounded cube in the first octant.
|
||||
* When center is true, the cube is centered on the origin.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -11,15 +8,15 @@
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
include <__private__/__frags.scad>;
|
||||
include <__private__/__nearest_multiple_of_4.scad>;
|
||||
|
||||
module rounded_cube(size, corner_r, center = false) {
|
||||
is_vt = __is_vector(size);
|
||||
x = is_vt ? size[0] : size;
|
||||
y = is_vt ? size[1] : size;
|
||||
z = is_vt ? size[2] : size;
|
||||
is_flt = __is_float(size);
|
||||
x = is_flt ? size : size[0];
|
||||
y = is_flt ? size : size[1];
|
||||
z = is_flt ? size : size[2];
|
||||
|
||||
corner_frags = __nearest_multiple_of_4(__frags(corner_r));
|
||||
edge_d = corner_r * cos(180 / corner_frags);
|
||||
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* rounded_cylinder.scad
|
||||
*
|
||||
* Creates a rounded cylinder.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -10,7 +8,7 @@
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
include <__private__/__frags.scad>;
|
||||
include <__private__/__pie_for_rounding.scad>;
|
||||
include <__private__/__half_trapezium.scad>;
|
||||
|
@@ -1,8 +1,6 @@
|
||||
/**
|
||||
* rounded_extrude.scad
|
||||
*
|
||||
* Extrudes a 2D object roundly from 0 to 180 degrees.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -11,13 +9,13 @@
|
||||
**/
|
||||
|
||||
include <__private__/__frags.scad>;
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
|
||||
module rounded_extrude(size, round_r, angle = 90, twist = 0, convexity = 10) {
|
||||
|
||||
is_vt = __is_vector(size);
|
||||
x = is_vt ? size[0] : size;
|
||||
y = is_vt ? size[1] : size;
|
||||
is_flt = __is_float(size);
|
||||
x = is_flt ? size : size[0];
|
||||
y = is_flt ? size : size[1];
|
||||
|
||||
q_corner_frags = __frags(round_r) / 4;
|
||||
|
||||
|
@@ -1,9 +1,6 @@
|
||||
/**
|
||||
* rounded_square.scad
|
||||
*
|
||||
* Creates a rounded square or rectangle in the first quadrant.
|
||||
* When center is true the square is centered on the origin.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -11,16 +8,16 @@
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
include <__private__/__frags.scad>;
|
||||
include <__private__/__pie_for_rounding.scad>;
|
||||
include <__private__/__half_trapezium.scad>;
|
||||
include <__private__/__trapezium.scad>;
|
||||
|
||||
module rounded_square(size, corner_r, center = false) {
|
||||
is_vt = __is_vector(size);
|
||||
x = is_vt ? size[0] : size;
|
||||
y = is_vt ? size[1] : size;
|
||||
is_flt = __is_float(size);
|
||||
x = is_flt ? size : size[0];
|
||||
y = is_flt ? size : size[1];
|
||||
|
||||
position = center ? [0, 0] : [x / 2, y / 2];
|
||||
points = __trapezium(
|
||||
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* shape_arc.scad
|
||||
*
|
||||
* Returns shape points of an arc shape.
|
||||
* They can be used with xxx_extrude modules of dotSCAD.
|
||||
* The shape points can be also used with the built-in polygon module.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -13,9 +9,10 @@
|
||||
**/
|
||||
|
||||
include <__private__/__frags.scad>;
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
include <__private__/__ra_to_xy.scad>;
|
||||
include <__private__/__shape_arc.scad>;
|
||||
include <__private__/__edge_r.scad>
|
||||
|
||||
function shape_arc(radius, angle, width, width_mode = "LINE_CROSS") =
|
||||
__shape_arc(radius, angle, width, width_mode);
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* shape_cyclicpolygon.scad
|
||||
*
|
||||
* Returns shape points of a regular cyclic polygon.
|
||||
* They can be used with xxx_extrude modules of dotSCAD.
|
||||
* The shape points can be also used with the built-in polygon module.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* shape_ellipse.scad
|
||||
*
|
||||
* Returns shape points of an ellipse.
|
||||
* They can be used with xxx_extrude modules of dotSCAD.
|
||||
* The shape points can be also used with the built-in polygon module.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -2,10 +2,6 @@
|
||||
/**
|
||||
* shape_glued2circles.scad
|
||||
*
|
||||
* Returns shape points of two glued circles.
|
||||
* They can be used with xxx_extrude modules of dotSCAD.
|
||||
* The shape points can be also used with the built-in polygon module.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,11 +1,6 @@
|
||||
/**
|
||||
* shape_path_extend.scad
|
||||
*
|
||||
* It extends a 2D stroke along a path.
|
||||
* This module is suitable for a path created by a continuous function.
|
||||
* It depends on the rotate_p function and the polytransversals module.
|
||||
* Remember to include "rotate_p.scad" and "polytransversals.scad".
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -14,7 +9,6 @@
|
||||
**/
|
||||
|
||||
include <__private__/__to3d.scad>;
|
||||
include <__private__/__length_between.scad>;
|
||||
include <__private__/__polytransversals.scad>;
|
||||
include <__private__/__reverse.scad>;
|
||||
|
||||
@@ -39,7 +33,7 @@ function _shape_path_first_stroke(stroke_pts, path_pts) =
|
||||
|
||||
function _shape_path_extend_stroke(stroke_pts, p1, p2, scale_step, i) =
|
||||
let(
|
||||
leng = __length_between(__to3d(p1), __to3d(p2)),
|
||||
leng = norm(__to3d(p2) - __to3d(p1)),
|
||||
a = _shape_path_extend_az(p1, p2)
|
||||
)
|
||||
[
|
||||
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* shape_pentagram.scad
|
||||
*
|
||||
* Returns shape points of a pentagram.
|
||||
* They can be used with xxx_extrude modules of dotSCAD.
|
||||
* The shape points can be also used with the built-in polygon module.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* shape_pie.scad
|
||||
*
|
||||
* Returns shape points of a pie (circular sector) shape.
|
||||
* They can be used with xxx_extrude modules of dotSCAD.
|
||||
* The shape points can be also used with the built-in polygon module.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -13,7 +9,7 @@
|
||||
**/
|
||||
|
||||
include <__private__/__frags.scad>;
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.scad>;
|
||||
include <__private__/__ra_to_xy.scad>;
|
||||
include <__private__/__shape_pie.scad>;
|
||||
|
||||
|
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* shape_square.scad
|
||||
*
|
||||
* Returns shape points of a rounded square or rectangle.
|
||||
* They can be used with xxx_extrude modules of dotSCAD.
|
||||
* The shape points can be also used with the built-in polygon module.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
@@ -12,17 +8,17 @@
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__is_vector.scad>;
|
||||
include <__private__/__is_float.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(
|
||||
is_vt = __is_vector(size),
|
||||
x = is_vt ? size[0] : size,
|
||||
y = is_vt ? size[1] : size
|
||||
is_flt = __is_float(size),
|
||||
x = is_flt ? size : size[0],
|
||||
y = is_flt ? size : size[1]
|
||||
)
|
||||
__trapezium(
|
||||
length = x,
|
||||
|