mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Brought args for rotate_points3d in line with rot() and rotate().
This commit is contained in:
parent
1d6aefc867
commit
019aae4347
1 changed files with 20 additions and 20 deletions
40
math.scad
40
math.scad
|
@ -974,20 +974,20 @@ function rotate_points2d(pts, ang, cp=[0,0]) = let(
|
||||||
|
|
||||||
// Function: rotate_points3d()
|
// Function: rotate_points3d()
|
||||||
// Usage:
|
// Usage:
|
||||||
// rotate_points3d(pts, v, [cp], [reverse]);
|
// rotate_points3d(pts, a, [cp], [reverse]);
|
||||||
// rotate_points3d(pts, v, axis, [cp], [reverse]);
|
// rotate_points3d(pts, a, v, [cp], [reverse]);
|
||||||
// rotate_points3d(pts, from, to, v, [cp], [reverse]);
|
// rotate_points3d(pts, from, to, [a], [cp], [reverse]);
|
||||||
// Description:
|
// Description:
|
||||||
// Rotates each 3D point in an array by a given amount, around a given centerpoint.
|
// Rotates each 3D point in an array by a given amount, around a given centerpoint.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// pts = List of points to rotate.
|
// pts = List of points to rotate.
|
||||||
// v = Rotation angle(s) in degrees.
|
// a = Rotation angle(s) in degrees.
|
||||||
// axis = If given, axis vector to rotate around.
|
// v = If given, axis vector to rotate around.
|
||||||
// cp = Centerpoint to rotate around.
|
// cp = Centerpoint to rotate around.
|
||||||
// from = If given, the vector to rotate something from. Used with `to`.
|
// from = If given, the vector to rotate something from. Used with `to`.
|
||||||
// to = If given, the vector to rotate something to. Used with `from`.
|
// to = If given, the vector to rotate something to. Used with `from`.
|
||||||
// reverse = If true, performs an exactly reversed rotation.
|
// reverse = If true, performs an exactly reversed rotation.
|
||||||
function rotate_points3d(pts, v=0, cp=[0,0,0], axis=undef, from=undef, to=undef, reverse=false) =
|
function rotate_points3d(pts, a=0, v=undef, cp=[0,0,0], from=undef, to=undef, reverse=false) =
|
||||||
let(
|
let(
|
||||||
dummy = assertion(is_def(from)==is_def(to), "`from` and `to` must be given together."),
|
dummy = assertion(is_def(from)==is_def(to), "`from` and `to` must be given together."),
|
||||||
mrot = reverse? (
|
mrot = reverse? (
|
||||||
|
@ -996,15 +996,15 @@ function rotate_points3d(pts, v=0, cp=[0,0,0], axis=undef, from=undef, to=undef,
|
||||||
from = from / norm(from),
|
from = from / norm(from),
|
||||||
to = to / norm(from),
|
to = to / norm(from),
|
||||||
ang = vector_angle(from, to),
|
ang = vector_angle(from, to),
|
||||||
axis = vector_axis(from, to)
|
v = vector_axis(from, to)
|
||||||
)
|
)
|
||||||
matrix4_rot_by_axis(from, -v) * matrix4_rot_by_axis(axis, -ang)
|
matrix4_rot_by_axis(from, -a) * matrix4_rot_by_axis(v, -ang)
|
||||||
) : is_def(axis)? (
|
) : is_def(v)? (
|
||||||
matrix4_rot_by_axis(axis, -v)
|
matrix4_rot_by_axis(v, -a)
|
||||||
) : is_scalar(v)? (
|
) : is_scalar(a)? (
|
||||||
matrix4_zrot(-v)
|
matrix4_zrot(-a)
|
||||||
) : (
|
) : (
|
||||||
matrix4_xrot(-v.x) * matrix4_yrot(-v.y) * matrix4_zrot(-v.z)
|
matrix4_xrot(-a.x) * matrix4_yrot(-a.y) * matrix4_zrot(-a.z)
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
is_def(from)? (
|
is_def(from)? (
|
||||||
|
@ -1012,15 +1012,15 @@ function rotate_points3d(pts, v=0, cp=[0,0,0], axis=undef, from=undef, to=undef,
|
||||||
from = from / norm(from),
|
from = from / norm(from),
|
||||||
to = to / norm(from),
|
to = to / norm(from),
|
||||||
ang = vector_angle(from, to),
|
ang = vector_angle(from, to),
|
||||||
axis = vector_axis(from, to)
|
v = vector_axis(from, to)
|
||||||
)
|
)
|
||||||
matrix4_rot_by_axis(axis, ang) * matrix4_rot_by_axis(from, v)
|
matrix4_rot_by_axis(v, ang) * matrix4_rot_by_axis(from, a)
|
||||||
) : is_def(axis)? (
|
) : is_def(v)? (
|
||||||
matrix4_rot_by_axis(axis, v)
|
matrix4_rot_by_axis(v, a)
|
||||||
) : is_scalar(v)? (
|
) : is_scalar(a)? (
|
||||||
matrix4_zrot(v)
|
matrix4_zrot(a)
|
||||||
) : (
|
) : (
|
||||||
matrix4_zrot(v.z) * matrix4_yrot(v.y) * matrix4_xrot(v.x)
|
matrix4_zrot(a.z) * matrix4_yrot(a.y) * matrix4_xrot(a.x)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
m = matrix4_translate(cp) * mrot * matrix4_translate(-cp)
|
m = matrix4_translate(cp) * mrot * matrix4_translate(-cp)
|
||||||
|
|
Loading…
Reference in a new issue