o[1] = m[3] * ax + m[4] * ay + m[5];
return o;
}
function vNewTransform (a, m) {
let ax = a[0], ay = a[1];
return [m[0] * ax + m[1] * ay + m[2],
m[3] * ax + m[4] * ay + m[5]];
}
function vTranslateV (a, b) {
a[0] += b[0];
a[1] += b[1];
return a;
}
function vLetTranslateV (o, a, b) {
o[0] = a[0] + b[0];
o[1] = a[1] + b[1];
return o;
}
function vNewTranslateV (a, b) {
return [a[0] + b[0],
a[1] + b[1]];
}
function vTranslateX (a, d) {
a[0] += d;
return a;
}
function vLetTranslateX (o, a, d) {
o[0] = a[0] + d;
o[1] = a[1];
return o;
}
function vNewTranslateX (a, d) {
return [a[0] + d,
a[1]];
}
function vTranslateY (a, e) {
a[1] += e;
return a;
}
function vLetTranslateY (o, a, e) {
o[0] = a[0];
o[1] = a[1] + e;
return o;
}
function vNewTranslateY (a, e) {
return [a[0],
a[1] + e];
}
function vTranslateXY (a, d, e) {
a[0] += d;
a[1] += e;
return a;
}
function vLetTranslateXY (o, a, d, e) {
o[0] = a[0] + d;
o[1] = a[1] + e;
return o;
}
function vNewTranslateXY (a, d, e) {
return [a[0] + d,
a[1] + e];
}
function vTrisect (a, b) {
a[0] = TWO_3 * a[0] + ONE_3 * b[0];
a[1] = TWO_3 * a[1] + ONE_3 * b[1];
return a;
}
function vLetTrisect (o, a, b) {
o[0] = TWO_3 * a[0] + ONE_3 * b[0];
o[1] = TWO_3 * a[1] + ONE_3 * b[1];
return o;
}
function vNewTrisect (a, b) {
return [TWO_3 * a[0] + ONE_3 * b[0],
TWO_3 * a[1] + ONE_3 * b[1]];
}
function vLetZero (o) {
o[0] = 0;
o[1] = 0;
return o;
}
function vNewZero () {
return [0,
0];
}
function wAngle (a, b) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
return acos ((ax * bx + ay * by + az * bz) / (hypot3 (ax, ay, az) * hypot3 (bx, by, bz)));
}
function wAngleA (a, b, c) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
let cx = c[0], cy = c[1], cz = c[2];
bx -= ax;
by -= ay;
bz -= az;
cx -= ax;
cy -= ay;
cz -= az;
return acos ((bx * cx + by * cy + bz * cz) / (hypot3 (bx, by, bz) * hypot3 (cx, cy, cz)));
}
function wAreaOfTriangle (a, b, c) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
let cx = c[0], cy = c[1], cz = c[2];
bx -= ax;
by -= ay;
bz -= az;
cx -= ax;
cy -= ay;
cz -= az;
return 0.5 * sqrt ((bx * bx + by * by + bz * bz) * (cx * cx + cy * cy + cz * cz) - (bx * cx + by * cy + bz * cz) ** 2);
}
function wAzimuthYZ (a) {
return atan2 (a[2], a[1]);
}
function wAzimuthZX (a) {
return atan2 (a[0], a[2]);
}
function wAzimuthXY (a) {
return atan2 (a[1], a[0]);
}
function wBisect (a, b) {
a[0] = (a[0] + b[0]) * 0.5;
a[1] = (a[1] + b[1]) * 0.5;
a[2] = (a[2] + b[2]) * 0.5;
return a;
}
function wLetBisect (o, a, b) {
o[0] = (a[0] + b[0]) * 0.5;
o[1] = (a[1] + b[1]) * 0.5;
o[2] = (a[2] + b[2]) * 0.5;
return o;
}
function wNewBisect (a, b) {
return [(a[0] + b[0]) * 0.5,
(a[1] + b[1]) * 0.5,
(a[2] + b[2]) * 0.5];
}
function wCentroid (a, b, c) {
a[0] = (a[0] + b[0] + c[0]) * ONE_3;
a[1] = (a[1] + b[1] + c[1]) * ONE_3;
a[2] = (a[2] + b[2] + c[2]) * ONE_3;
return a;
}
function wLetCentroid (o, a, b, c) {
o[0] = (a[0] + b[0] + c[0]) * ONE_3;
o[1] = (a[1] + b[1] + c[1]) * ONE_3;
o[2] = (a[2] + b[2] + c[2]) * ONE_3;
return o;
}
function wNewCentroid (a, b, c) {
return [(a[0] + b[0] + c[0]) * ONE_3,
(a[1] + b[1] + c[1]) * ONE_3,
(a[2] + b[2] + c[2]) * ONE_3];
}
function wCircumcenter (a, b, c) {
let cosa = wCosAngleA (a, b, c);
let cosb = wCosAngleA (b, c, a);
let cosc = wCosAngleA (c, a, b);
let sin2a = 2 * sqrt (1 - cosa * cosa) * cosa;
let sin2b = 2 * sqrt (1 - cosb * cosb) * cosb;
let sin2c = 2 * sqrt (1 - cosc * cosc) * cosc;
let d = sin2a + sin2b + sin2c;
a[0] = (sin2a * a[0] + sin2b * b[0] + sin2c * c[0]) / d;
a[1] = (sin2a * a[1] + sin2b * b[1] + sin2c * c[1]) / d;
a[2] = (sin2a * a[2] + sin2b * b[2] + sin2c * c[2]) / d;
return a;
}
function wLetCircumcenter (o, a, b, c) {
let cosa = wCosAngleA (a, b, c);
let cosb = wCosAngleA (b, c, a);
let cosc = wCosAngleA (c, a, b);
let sin2a = 2 * sqrt (1 - cosa * cosa) * cosa;
let sin2b = 2 * sqrt (1 - cosb * cosb) * cosb;
let sin2c = 2 * sqrt (1 - cosc * cosc) * cosc;
let d = sin2a + sin2b + sin2c;
o[0] = (sin2a * a[0] + sin2b * b[0] + sin2c * c[0]) / d;
o[1] = (sin2a * a[1] + sin2b * b[1] + sin2c * c[1]) / d;
o[2] = (sin2a * a[2] + sin2b * b[2] + sin2c * c[2]) / d;
return o;
}
function wNewCircumcenter (a, b, c) {
let cosa = wCosAngleA (a, b, c);
let cosb = wCosAngleA (b, c, a);
let cosc = wCosAngleA (c, a, b);
let sin2a = 2 * sqrt (1 - cosa * cosa) * cosa;
let sin2b = 2 * sqrt (1 - cosb * cosb) * cosb;
let sin2c = 2 * sqrt (1 - cosc * cosc) * cosc;
let d = sin2a + sin2b + sin2c;
return [(sin2a * a[0] + sin2b * b[0] + sin2c * c[0]) / d,
(sin2a * a[1] + sin2b * b[1] + sin2c * c[1]) / d,
(sin2a * a[2] + sin2b * b[2] + sin2c * c[2]) / d];
}
function wLetCopy (o, a) {
o[0] = a[0];
o[1] = a[1];
o[2] = a[2];
return o;
}
function wNewCopy (a) {
return a.concat ();
}
function wCosAngle (a, b) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
return (ax * bx + ay * by + az * bz) / (hypot3 (ax, ay, az) * hypot3 (bx, by, bz));
}
function wCosAngleA (a, b, c) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
let cx = c[0], cy = c[1], cz = c[2];
bx -= ax;
by -= ay;
bz -= az;
cx -= ax;
cy -= ay;
cz -= az;
return (bx * cx + by * cy + bz * cz) / (hypot3 (bx, by, bz) * hypot3 (cx, cy, cz));
}
function wCross (a, b) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
a[0] = ay * bz - az * by;
a[1] = az * bx - ax * bz;
a[2] = ax * by - ay * bx;
return a;
}
function wLetCross (o, a, b) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
o[0] = ay * bz - az * by;
o[1] = az * bx - ax * bz;
o[2] = ax * by - ay * bx;
return o;
}
function wNewCross (a, b) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
return [ay * bz - az * by,
az * bx - ax * bz,
ax * by - ay * bx];
}
function wDistance (a, b) {
return hypot3 (b[0] - a[0], b[1] - a[1], b[2] - a[2]);
}
function wDistance2 (a, b) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
bx -= ax;
by -= ay;
bz -= az;
return bx * bx + by * by + bz * bz;
}
function wDot (a, b) {
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}
function wHat (a) {
let ax = a[0], ay = a[1], az = a[2];
let s = hypot3 (ax, ay, az);
a[0] = ax / s;
a[1] = ay / s;
a[2] = az / s;
return a;
}
function wLetHat (o, a) {
let ax = a[0], ay = a[1], az = a[2];
let s = hypot3 (ax, ay, az);
o[0] = ax / s;
o[1] = ay / s;
o[2] = az / s;
return o;
}
function wNewHat (a) {
let ax = a[0], ay = a[1], az = a[2];
let s = hypot3 (ax, ay, az);
return [ax / s,
ay / s,
az / s];
}
function wHeight (a, b, c) {
return wDistance (a, wNewPerpendicularFoot (a, b, c));
}
function wIncenter (a, b, c) {
let la = wDistance (b, c);
let lb = wDistance (c, a);
let lc = wDistance (a, b);
let d = la + lb + lc;
a[0] = (la * a[0] + lb * b[0] + lc * c[0]) / d;
a[1] = (la * a[1] + lb * b[1] + lc * c[1]) / d;
a[2] = (la * a[2] + lb * b[2] + lc * c[2]) / d;
return a;
}
function wLetIncenter (o, a, b, c) {
let la = wDistance (b, c);
let lb = wDistance (c, a);
let lc = wDistance (a, b);
let d = la + lb + lc;
o[0] = (la * a[0] + lb * b[0] + lc * c[0]) / d;
o[1] = (la * a[1] + lb * b[1] + lc * c[1]) / d;
o[2] = (la * a[2] + lb * b[2] + lc * c[2]) / d;
return o;
}
function wNewIncenter (a, b, c) {
let la = wDistance (b, c);
let lb = wDistance (c, a);
let lc = wDistance (a, b);
let d = la + lb + lc;
return [(la * a[0] + lb * b[0] + lc * c[0]) / d,
(la * a[1] + lb * b[1] + lc * c[1]) / d,
(la * a[2] + lb * b[2] + lc * c[2]) / d];
}
function wNorm (a) {
return hypot3 (a[0], a[1], a[2]);
}
function wNorm2 (a) {
let ax = a[0], ay = a[1], az = a[2];
return ax * ax + ay * ay + az * az;
}
function wNormal (a, b, c) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
let cx = c[0], cy = c[1], cz = c[2];
bx -= ax;
by -= ay;
bz -= az;
cx -= ax;
cy -= ay;
cz -= az;
a[0] = by * cz - bz * cy;
a[1] = bz * cx - bx * cz;
a[2] = bx * cy - by * cx;
return a;
}
function wLetNormal (o, a, b, c) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
let cx = c[0], cy = c[1], cz = c[2];
bx -= ax;
by -= ay;
bz -= az;
cx -= ax;
cy -= ay;
cz -= az;
o[0] = by * cz - bz * cy;
o[1] = bz * cx - bx * cz;
o[2] = bx * cy - by * cx;
return o;
}
function wNewNormal (a, b, c) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
let cx = c[0], cy = c[1], cz = c[2];
bx -= ax;
by -= ay;
bz -= az;
cx -= ax;
cy -= ay;
cz -= az;
return [by * cz - bz * cy,
bz * cx - bx * cz,
bx * cy - by * cx];
}
function wLetOneX (o) {
o[0] = 1;
o[1] = 0;
o[2] = 0;
return o;
}
function wNewOneX () {
return [1,
0,
0];
}
function wLetOneY (o) {
o[0] = 0;
o[1] = 1;
o[2] = 0;
return o;
}
function wNewOneY () {
return [0,
1,
0];
}
function wLetOneZ (o) {
o[0] = 0;
o[1] = 0;
o[2] = 1;
return o;
}
function wNewOneZ () {
return [0,
0,
1];
}
function wOrthocenter (a, b, c) {
let cosa = wCosAngleA (a, b, c);
let cosb = wCosAngleA (b, c, a);
let cosc = wCosAngleA (c, a, b);
let tana = sqrt (1 - cosa * cosa) / cosa;
let tanb = sqrt (1 - cosb * cosb) / cosb;
let tanc = sqrt (1 - cosc * cosc) / cosc;
let d = tana + tanb + tanc;
a[0] = (tana * a[0] + tanb * b[0] + tanc * c[0]) / d;
a[1] = (tana * a[1] + tanb * b[1] + tanc * c[1]) / d;
a[2] = (tana * a[2] + tanb * b[2] + tanc * c[2]) / d;
return a;
}
function wLetOrthocenter (o, a, b, c) {
let cosa = wCosAngleA (a, b, c);
let cosb = wCosAngleA (b, c, a);
let cosc = wCosAngleA (c, a, b);
let tana = sqrt (1 - cosa * cosa) / cosa;
let tanb = sqrt (1 - cosb * cosb) / cosb;
let tanc = sqrt (1 - cosc * cosc) / cosc;
let d = tana + tanb + tanc;
o[0] = (tana * a[0] + tanb * b[0] + tanc * c[0]) / d;
o[1] = (tana * a[1] + tanb * b[1] + tanc * c[1]) / d;
o[2] = (tana * a[2] + tanb * b[2] + tanc * c[2]) / d;
return o;
}
function wNewOrthocenter (a, b, c) {
let cosa = wCosAngleA (a, b, c);
let cosb = wCosAngleA (b, c, a);
let cosc = wCosAngleA (c, a, b);
let tana = sqrt (1 - cosa * cosa) / cosa;
let tanb = sqrt (1 - cosb * cosb) / cosb;
let tanc = sqrt (1 - cosc * cosc) / cosc;
let d = tana + tanb + tanc;
return [(tana * a[0] + tanb * b[0] + tanc * c[0]) / d,
(tana * a[1] + tanb * b[1] + tanc * c[1]) / d,
(tana * a[2] + tanb * b[2] + tanc * c[2]) / d];
}
function wPerpendicularFoot (a, b, c) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
let cx = c[0], cy = c[1], cz = c[2];
let s = (((ax - bx) * (cx - bx) + (ay - by) * (cy - by) + (az - bz) * (cz - bz)) /
((cx - bx) * (cx - bx) + (cy - by) * (cy - by) + (cz - bz) * (cz - bz)));
a[0] = bx + (cx - bx) * s;
a[1] = by + (cy - by) * s;
a[2] = bz + (cz - bz) * s;
return a;
}
function wLetPerpendicularFoot (o, a, b, c) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
let cx = c[0], cy = c[1], cz = c[2];
let s = (((ax - bx) * (cx - bx) + (ay - by) * (cy - by) + (az - bz) * (cz - bz)) /
((cx - bx) * (cx - bx) + (cy - by) * (cy - by) + (cz - bz) * (cz - bz)));
o[0] = bx + (cx - bx) * s;
o[1] = by + (cy - by) * s;
o[2] = bz + (cz - bz) * s;
return o;
}
function wNewPerpendicularFoot (a, b, c) {
let ax = a[0], ay = a[1], az = a[2];
let bx = b[0], by = b[1], bz = b[2];
let cx = c[0], cy = c[1], cz = c[2];
let s = (((ax - bx) * (cx - bx) + (ay - by) * (cy - by) + (az - bz) * (cz - bz)) /
((cx - bx) * (cx - bx) + (cy - by) * (cy - by) + (cz - bz) * (cz - bz)));
return [bx + (cx - bx) * s,
by + (cy - by) * s,
bz + (cz - bz) * s];
}
function wReverse (a) {
a[0] = -a[0];
a[1] = -a[1];
a[2] = -a[2];
return a;
}
function wLetReverse (o, a) {
o[0] = -a[0];
o[1] = -a[1];
o[2] = -a[2];
return o;
}
function wNewReverse (a) {
return [-a[0],
-a[1],
-a[2]];
}
function wRotateXY (a, t) {
let c = cos (t), s = sin (t);
let ax = a[0], ay = a[1];
a[0] = c * ax - s * ay;
a[1] = s * ax + c * ay;
return a;
}
function wLetRotateXY (o, a, t) {
let c = cos (t), s = sin (t);
let ax = a[0], ay = a[1];
o[0] = c * ax - s * ay;
o[1] = s * ax + c * ay;
o[2] = a[2];
return o;
}