mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-14 02:34:12 +02:00
required by path_extrude
This commit is contained in:
@@ -14,6 +14,37 @@
|
||||
include <__private__/__to2d.scad>;
|
||||
include <__private__/__to3d.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) =
|
||||
let(cosa = cos(a), sina = sin(a))
|
||||
[
|
||||
@@ -48,10 +79,21 @@ function to_avect(a) =
|
||||
)
|
||||
);
|
||||
|
||||
function rotate_p(point, a) =
|
||||
function _rotate_p(p, a) =
|
||||
let(angle = to_avect(a))
|
||||
len(point) == 3 ?
|
||||
_rotate_p_3d(point, angle) :
|
||||
len(p) == 3 ?
|
||||
_rotate_p_3d(p, angle) :
|
||||
__to2d(
|
||||
_rotate_p_3d(__to3d(point), angle)
|
||||
_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(point, a, v) =
|
||||
v == undef ? _rotate_p(point, a) : _q_rotate_p(point, a, v);
|
||||
|
Reference in New Issue
Block a user