You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
990 B
42 lines
990 B
include <../vector/to_ang_vec.scad>
|
|
function __v_rotation_xRotation(a) =
|
|
let(c = cos(a), s = sin(a))
|
|
[
|
|
[1, 0, 0],
|
|
[0, c, -s],
|
|
[0, s, c],
|
|
];
|
|
|
|
function __v_rotation_yRotation(a) =
|
|
let(c = cos(a), s = sin(a))
|
|
[
|
|
[ c, 0, s],
|
|
[ 0, 1, 0],
|
|
[-s, 0, c],
|
|
];
|
|
|
|
function __v_rotation_zRotation(a) =
|
|
let(c = cos(a), s = sin(a))
|
|
[
|
|
[c, -s, 0],
|
|
[s, c, 0],
|
|
[0, 0, 1],
|
|
];
|
|
|
|
function __v_rotation_xyz_rotation(a) =
|
|
let(ang = to_ang_vec(a))
|
|
__v_rotation_zRotation(ang[2]) * __v_rotation_yRotation(ang[1]) * __v_rotation_xRotation(ang[0]);
|
|
|
|
function _v_rotation_impl(a) =
|
|
(a == 0 || a == [0, 0, 0] || a == [0] || a == [0, 0]) ? [
|
|
[1, 0, 0],
|
|
[0, 1, 0],
|
|
[0, 0, 1],
|
|
] : __v_rotation_xyz_rotation(a);
|
|
|
|
function v_rotation(a) = _v_rotation_impl(a);
|
|
function v_rot(a) = _v_rotation_impl(a);
|
|
|
|
|
|
|
|
function zero_axis(x,p,v=0) = [x!="x"?p[0]:v, x!="y"?p[1]:v,x!="z"?p[2]:v];
|