mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-04-19 05:33:57 +02:00
use ptf_rotate
This commit is contained in:
parent
ec0c1fa9ae
commit
55c9493fca
@ -167,6 +167,15 @@ See [examples](examples).
|
||||
- [part/connector_peg](https://openhome.cc/eGossip/OpenSCAD/lib2x-connector_peg.html)
|
||||
- [part/cone](https://openhome.cc/eGossip/OpenSCAD/lib2x-cone.html)
|
||||
- [part/joint_T](https://openhome.cc/eGossip/OpenSCAD/lib2-joint_T.html)
|
||||
|
||||
- Point Transformation (2.3 Preview)
|
||||
- ptf/ptf_rotate
|
||||
- ptf/ptf_x_twist
|
||||
- ptf/ptf_y_twist
|
||||
- ptf/ptf_bend
|
||||
- ptf/ptf_ring
|
||||
- ptf/ptf_sphere
|
||||
- ptf/ptf_torus
|
||||
|
||||
## Bugs and Feedback
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use <hull_polyline3d.scad>;
|
||||
use <bezier_curve.scad>;
|
||||
use <rotate_p.scad>;
|
||||
use <ptf/ptf_rotate.scad>;
|
||||
use <paths2sections.scad>;
|
||||
use <experimental/hollow_out_sweep.scad>;
|
||||
use <experimental/tri_bisectors.scad>;
|
||||
@ -28,7 +28,7 @@ module hollow_out_vase(ctrl_pts, t_step, width, fn, line_style) {
|
||||
a_step = 360 / fn;
|
||||
sects = paths2sections([
|
||||
for(a = [0:a_step:360 - a_step])
|
||||
[for(p = bezier) rotate_p(p, [0, 0, a])]
|
||||
[for(p = bezier) ptf_rotate(p, [0, 0, a])]
|
||||
]);
|
||||
|
||||
// body
|
||||
|
@ -1,4 +1,4 @@
|
||||
use <rotate_p.scad>;
|
||||
use <ptf/ptf_rotate.scad>;
|
||||
use <hull_polyline2d.scad>;
|
||||
use <bezier_curve.scad>;
|
||||
use <ellipse_extrude.scad>;
|
||||
@ -16,7 +16,7 @@ module nautilus_shell(chambered_section_max_angle, steps, thickness) {
|
||||
a_step = chambered_section_max_angle / steps;
|
||||
spiral = [
|
||||
for(a = [a_step:a_step:chambered_section_max_angle + 450])
|
||||
rotate_p([r(a), 0], a)
|
||||
ptf_rotate([r(a), 0], a)
|
||||
];
|
||||
|
||||
render() {
|
||||
@ -25,9 +25,9 @@ module nautilus_shell(chambered_section_max_angle, steps, thickness) {
|
||||
for(a = [a_step:a_step * 2:chambered_section_max_angle]) {
|
||||
a2 = a + 360;
|
||||
a3 = a + 420;
|
||||
p1 = rotate_p([r(a), 0], a);
|
||||
p2 = rotate_p((p1 + rotate_p([r(a2), 0], a2)) * .6, -5);
|
||||
p3 = rotate_p([r(a3), 0], a3);
|
||||
p1 = ptf_rotate([r(a), 0], a);
|
||||
p2 = ptf_rotate((p1 + ptf_rotate([r(a2), 0], a2)) * .6, -5);
|
||||
p3 = ptf_rotate([r(a3), 0], a3);
|
||||
|
||||
hull_polyline2d(bezier_curve(0.1,
|
||||
[p1, p2, p3]
|
||||
|
@ -1,5 +1,5 @@
|
||||
use <shape_circle.scad>;
|
||||
use <rotate_p.scad>;
|
||||
use <ptf/ptf_rotate.scad>;
|
||||
use <polysections.scad>;
|
||||
|
||||
r1 = 0.1;
|
||||
@ -24,7 +24,7 @@ module simple_seashell(r1, r2, a1, a2, steps) {
|
||||
)
|
||||
[
|
||||
for(p = concat(shape_circle(r), shape_circle(r * 0.9)))
|
||||
rotate_p([p[0], p[1], 0] + [r, 0, 0], [0, a, 0])
|
||||
ptf_rotate([p[0], p[1], 0] + [r, 0, 0], [0, a, 0])
|
||||
]
|
||||
|
||||
];
|
||||
|
@ -2,7 +2,7 @@ use <trim_shape.scad>;
|
||||
use <bezier_curve.scad>;
|
||||
use <path_scaling_sections.scad>;
|
||||
use <polysections.scad>;
|
||||
use <rotate_p.scad>;
|
||||
use <ptf/ptf_rotate.scad>;
|
||||
use <bijection_offset.scad>;
|
||||
use <shape_superformula.scad>;
|
||||
|
||||
@ -35,7 +35,7 @@ module superformula_vase(phi_step, m, n, n3, d, r1, r2, h1, h2, t_step, twist) {
|
||||
for(i = [0:leng - 1])
|
||||
[
|
||||
for(p = sects[i])
|
||||
rotate_p(p, twist_step * i)
|
||||
ptf_rotate(p, twist_step * i)
|
||||
]
|
||||
];
|
||||
|
||||
|
@ -3,7 +3,7 @@ use <bezier_curve.scad>;
|
||||
use <shape_taiwan.scad>;
|
||||
use <path_scaling_sections.scad>;
|
||||
use <polysections.scad>;
|
||||
use <rotate_p.scad>;
|
||||
use <ptf/ptf_rotate.scad>;
|
||||
use <bijection_offset.scad>;
|
||||
|
||||
x1 = 4; // [-20:4]
|
||||
@ -27,7 +27,7 @@ module dancing_formosan(x1, x2, x3, y1, y2, y3, twist, t_step) {
|
||||
for(i = [0:leng - 1])
|
||||
[
|
||||
for(p = sects[i])
|
||||
rotate_p(p, twist_step * i)
|
||||
ptf_rotate(p, twist_step * i)
|
||||
]
|
||||
];
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use <golden_spiral.scad>;
|
||||
use <rotate_p.scad>;
|
||||
use <ptf/ptf_rotate.scad>;
|
||||
use <hollow_out.scad>;
|
||||
use <experimental/voronoi2d_cells.scad>;
|
||||
|
||||
@ -27,7 +27,7 @@ module voronoi_fibonacci() {
|
||||
|
||||
pts = [
|
||||
for(a = [0:a_step:360 - a_step])
|
||||
each [for(p = spiral) rotate_p(p, a)]
|
||||
each [for(p = spiral) ptf_rotate(p, a)]
|
||||
];
|
||||
|
||||
half_line_thicness = line_thickness / 2;
|
||||
|
82
src/_impl/_ptf_rotate_impl.scad
Normal file
82
src/_impl/_ptf_rotate_impl.scad
Normal file
@ -0,0 +1,82 @@
|
||||
use <__comm__/__to2d.scad>;
|
||||
use <__comm__/__to3d.scad>;
|
||||
use <__comm__/__to_ang_vect.scad>;
|
||||
|
||||
function _q_rotate_p_3d(p, 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] * p,
|
||||
[yx + wz, 1 - xx - zz, zy - wx] * p,
|
||||
[zx - wy, zy + wx, 1 - xx - yy] * p
|
||||
];
|
||||
|
||||
function _rotx(pt, a) =
|
||||
a == 0 ? pt :
|
||||
let(cosa = cos(a), sina = sin(a))
|
||||
[
|
||||
pt[0],
|
||||
pt[1] * cosa - pt[2] * sina,
|
||||
pt[1] * sina + pt[2] * cosa
|
||||
];
|
||||
|
||||
function _roty(pt, a) =
|
||||
a == 0 ? pt :
|
||||
let(cosa = cos(a), sina = sin(a))
|
||||
[
|
||||
pt[0] * cosa + pt[2] * sina,
|
||||
pt[1],
|
||||
-pt[0] * sina + pt[2] * cosa,
|
||||
];
|
||||
|
||||
function _rotz(pt, a) =
|
||||
a == 0 ? pt :
|
||||
let(cosa = cos(a), sina = sin(a))
|
||||
[
|
||||
pt[0] * cosa - pt[1] * sina,
|
||||
pt[0] * sina + pt[1] * cosa,
|
||||
pt[2]
|
||||
];
|
||||
|
||||
function _rotate_p_3d(point, a) =
|
||||
_rotz(_roty(_rotx(point, a[0]), a[1]), a[2]);
|
||||
|
||||
function _rotate_p(p, a) =
|
||||
let(angle = __to_ang_vect(a))
|
||||
len(p) == 3 ?
|
||||
_rotate_p_3d(p, angle) :
|
||||
__to2d(
|
||||
_rotate_p_3d(__to3d(p), angle)
|
||||
);
|
||||
|
||||
|
||||
function _q_rotate_p(p, a, v) =
|
||||
len(p) == 3 ?
|
||||
_q_rotate_p_3d(p, a, v) :
|
||||
__to2d(
|
||||
_q_rotate_p_3d(__to3d(p), a, v)
|
||||
);
|
||||
|
||||
function _rotate_p_impl(point, a, v) =
|
||||
is_undef(v) ? _rotate_p(point, a) : _q_rotate_p(point, a, v);
|
13
src/ptf/ptf_rotate.scad
Normal file
13
src/ptf/ptf_rotate.scad
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* rotate_p.scad
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-rotate_p.html
|
||||
*
|
||||
**/
|
||||
|
||||
use <_impl/_ptf_rotate_impl.scad>;
|
||||
|
||||
function ptf_rotate(point, a, v) = _rotate_p_impl(point, a, v);
|
Loading…
x
Reference in New Issue
Block a user