1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-03-14 02:59:42 +01:00
This commit is contained in:
Justin Lin 2020-04-24 11:37:04 +08:00
parent 96255a892a
commit 6c7257184e
2 changed files with 1 additions and 83 deletions

View File

@ -1,82 +0,0 @@
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);

View File

@ -8,7 +8,7 @@
*
**/
use <ptf/_impl/_rotate_p_impl.scad>;
use <ptf/_impl/_ptf_rotate_impl.scad>;
function rotate_p(point, a, v) =
let(_ = echo("<b><i>rotate_p</i> is deprecated: use <i>ptf_rotate</i> instead.</b>"))