162 m11=m[0][0], m12=m[0][1], m13=m[0][2], m14=m[0][3],
163 m21=m[1][0], m22=m[1][1], m23=m[1][2], m24=m[1][3],
164 m31=m[2][0], m32=m[2][1], m33=m[2][2], m34=m[2][3]
170 x = ci[0], y = ci[1], z = ci[2]
172 [m11*x+m12*y+m13*z+m14, m21*x+m22*y+m23*z+m24, m31*x+m32*y+m33*z+m34]
215 [
for (ci=c) [
for (di=[0 : d-1]) ci[di] + w[di]]];
259 ox = eo[0], oy = eo[1],
260 nx = m[0], ny = m[1],
261 nz = (d == 3) ? m[2] : 0,
262 l2 = nx*nx + ny*ny + nz*nz
279 let( dx = ci[0]-ox, dy = ci[1]-oy )
281 ox + r11*dx + r12*dy,
303 let( dx = ci[0]-ox, dy = ci[1]-oy, dz = ci[2]-oz )
305 ox + r11*dx + r12*dy + r13*dz,
306 oy + r21*dx + r22*dy + r23*dz,
307 oz + r31*dx + r32*dy + r33*dz
382 cg = cos(az), sg = sin(az),
385 let( ox = eo[0], oy = eo[1] )
388 let( dx = ci[0]-ox, dy = ci[1]-oy )
397 : (is_undef(av) || is_list(a)) ?
403 ca = cos(ax), cb = cos(ay),
404 sa = sin(ax), sb = sin(ay),
407 m12 = cg*sa*sb-ca*sg,
408 m13 = ca*cg*sb+sa*sg,
410 m22 = ca*cg+sa*sb*sg,
411 m23 = -cg*sa+ca*sb*sg,
416 multmatrix_p(c, [[m11,m12,m13,0], [m21,m22,m23,0], [m31,m32,m33,0]])
420 vx = av[0], vy = av[1], vz = av[2],
421 vx2 = vx*vx, vy2 = vy*vy, vz2 = vz*vz,
431 ux = vx/ll, uy = vy/ll, uz = vz/ll,
432 ux2 = ux*ux, uy2 = uy*uy, uz2 = uz*uz,
433 ox = eo[0], oy = eo[1], oz = eo[2],
436 m11 = ux2+(uy2+uz2)*cg,
437 m12 = ux*uy*oc-uz*sg,
438 m13 = ux*uz*oc+uy*sg,
439 m14 = (ox*(uy2+uz2)-ux*(oy*uy+oz*uz))*oc+(oy*uz-oz*uy)*sg,
440 m21 = ux*uy*oc+uz*sg,
441 m22 = uy2+(ux2+uz2)*cg,
442 m23 = uy*uz*oc-ux*sg,
443 m24 = (oy*(ux2+uz2)-uy*(ox*ux+oz*uz))*oc+(oz*ux-ox*uz)*sg,
444 m31 = ux*uz*oc-uy*sg,
445 m32 = uy*uz*oc+ux*sg,
446 m33 = uz2+(ux2+uy2)*cg,
447 m34 = (oz*(ux2+uy2)-uz*(ox*ux+oy*uy))*oc+(ox*uy-oy*ux)*sg
449 multmatrix_p(c, [[m11,m12,m13,m14], [m21,m22,m23,m24], [m31,m32,m33,m34]])
608 ox = eo[0], oy = eo[1],
614 let( dx = ci[0]-ox, dy = ci[1]-oy )
623 ox = eo[0], oy = eo[1], oz = eo[2],
633 let( dx = ci[0]-ox, dy = ci[1]-oy, dz = ci[2]-oz )
635 ox + dx + sxy*dy + sxz*dz,
636 oy + syx*dx + dy + syz*dz,
637 oz + szx*dx + szy*dy + dz
697 r = [
for (ci=c) [
for (di=[0 : d-1]) eo[di] + (ci[di] - eo[di]) * w[di]]]
772 bv = [
for (i=[0 : d-1]) let (cv = [
for (ci=c) ci[i]]) [min(cv), max(cv)]],
775 s = [
for (i=[0 : d-1]) let (e = bv[i][1] - bv[i][0]) e == 0 ? 1 : w[i]/e],
778 r = [
for (ci=c) [
for (di=[0 : d-1]) (ci[di] - bv[di][0]) * s[di] + eo[di]]]
815 ) = (len(c) == 0) ? c
821 bv = [
for (i=[0 : d-1]) let (cv = [
for (ci=c) ci[i]]) [min(cv), max(cv)]],
824 mid = [
for (i=[0 : d-1]) (bv[i][0] + bv[i][1]) / 2]
826 [
for (ci=c) [
for (di=[0 : d-1]) ci[di] - mid[di]]];
origin2d
<point-2d> The origin point coordinate in 2d Euclidean space.
origin3d
<point-3d> The origin point coordinate in 3-dimensional Euclidean space.
function defined_e_or(v, i, d)
Returns an element from an iterable if it exists, or a default value if not.
function first(v)
Return the first element of an iterable value.
function defined_or(v, d)
Return given value, if defined, or a secondary value, if primary is not defined.
function is_scalar(v)
Test if a value is a single non-iterable value.
function rotate_p(c, a, av, center=false, o)
Rotate all coordinates about one or more axes in 2D or 3D.
function mirror_p(c, m, o)
Mirror all coordinates about a plane or line defined by a normal vector.
function multmatrix_p(c, m)
Multiply all coordinates by a 4x4 transformation matrix in 3D.
function resize_p(c, v, center=false, o)
Scale all coordinates dimensions proportionately to fit inside a region.
function center_p(c)
Center all coordinates about the origin.
function shear_p(c, s, center=false, o)
Shear all coordinates in 2D or 3D.
function scale_p(c, v, center=false, o)
Scale all coordinates dimensions.
function translate_p(c, v)
Translate all coordinates dimensions.
function transform_p(c, m, a, av, center=false, o, t)
Apply an optional mirror, rotation, and translation to a list of 2D or 3D coordinates.