function vNewBisect (a, b) {
return [(a[0] + b[0]) * 0.5,
(a[1] + b[1]) * 0.5];
}
function vCentroid (a, b, c) {
a[0] = (a[0] + b[0] + c[0]) * ONE_3;
a[1] = (a[1] + b[1] + c[1]) * ONE_3;
return a;
}
function vLetCentroid (o, a, b, c) {
o[0] = (a[0] + b[0] + c[0]) * ONE_3;
o[1] = (a[1] + b[1] + c[1]) * ONE_3;
return o;
}
function vNewCentroid (a, b, c) {
return [(a[0] + b[0] + c[0]) * ONE_3,
(a[1] + b[1] + c[1]) * ONE_3];
}
function vCircumcenter (a, b, c) {
let cosa = vCosAngleA (a, b, c);
let cosb = vCosAngleA (b, c, a);
let cosc = vCosAngleA (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;
return a;
}
function vLetCircumcenter (o, a, b, c) {
let cosa = vCosAngleA (a, b, c);
let cosb = vCosAngleA (b, c, a);
let cosc = vCosAngleA (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;
return o;
}
function vNewCircumcenter (a, b, c) {
let cosa = vCosAngleA (a, b, c);
let cosb = vCosAngleA (b, c, a);
let cosc = vCosAngleA (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];
}
function vLetCopy (o, a) {
o[0] = a[0];
o[1] = a[1];
return o;
}
function vNewCopy (a) {
return a.concat ();
}
function vCosAngle (a, b) {
let ax = a[0], ay = a[1];
let bx = b[0], by = b[1];
return (ax * bx + ay * by) / (hypot2 (ax, ay) * hypot2 (bx, by));
}
function vCosAngleA (a, b, c) {
let ax = a[0], ay = a[1];
let bx = b[0], by = b[1];
let cx = c[0], cy = c[1];
bx -= ax;
by -= ay;
cx -= ax;
cy -= ay;
return (bx * cx + by * cy) / (hypot2 (bx, by) * hypot2 (cx, cy));
}
function vCounterclockwise (a, b, c) {
let ax = a[0], ay = a[1];
let bx = b[0], by = b[1];
let cx = c[0], cy = c[1];
return (by - ay) * cx - (bx - ax) * cy - ax * by + ay * bx;
}
function vDistance (a, b) {
return hypot2 (b[0] - a[0], b[1] - a[1]);
}
function vDistance2 (a, b) {
let ax = a[0], ay = a[1];
let bx = b[0], by = b[1];
bx -= ax;
by -= ay;
return bx * bx + by * by;
}
function vDot (a, b) {
return a[0] * b[0] + a[1] * b[1];
}
function vHat (a) {
let ax = a[0], ay = a[1];
let s = hypot2 (ax, ay);
a[0] = ax / s;
a[1] = ay / s;
return a;
}
function vLetHat (o, a) {
let ax = a[0], ay = a[1];
let s = hypot2 (ax, ay);
o[0] = ax / s;
o[1] = ay / s;
return o;
}
function vNewHat (a) {
let ax = a[0], ay = a[1];
let s = hypot2 (ax, ay);
return [ax / s,
ay / s];
}
function vHeight (a, b, c) {
return vDistance (a, vNewPerpendicularFoot (a, b, c));
}
function vIncenter (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;
return a;
}
function vLetIncenter (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;
return o;
}
function vNewIncenter (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];
}
function vNorm (a) {
return hypot2 (a[0], a[1]);
}
function vNorm2 (a) {
let ax = a[0], ay = a[1];
return ax * ax + ay * ay;
}
function vLetOneX (o) {
o[0] = 1;
o[1] = 0;
return o;
}
function vNewOneX () {
return [1,
0];
}
function vLetOneY (o) {
o[0] = 0;
o[1] = 1;
return o;
}
function vNewOneY () {
return [0,
1];
}
function vOrthocenter (a, b, c) {
let cosa = vCosAngleA (a, b, c);
let cosb = vCosAngleA (b, c, a);
let cosc = vCosAngleA (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;
return a;
}
function vLetOrthocenter (o, a, b, c) {
let cosa = vCosAngleA (a, b, c);
let cosb = vCosAngleA (b, c, a);
let cosc = vCosAngleA (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;
return o;
}
function vNewOrthocenter (a, b, c) {
let cosa = vCosAngleA (a, b, c);
let cosb = vCosAngleA (b, c, a);
let cosc = vCosAngleA (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];
}
function vPerpendicularFoot (a, b, c) {
let ax = a[0], ay = a[1];
let bx = b[0], by = b[1];
let cx = c[0], cy = c[1];
let s = (((ax - bx) * (cx - bx) + (ay - by) * (cy - by)) /
((cx - bx) * (cx - bx) + (cy - by) * (cy - by)));
a[0] = bx + (cx - bx) * s;
a[1] = by + (cy - by) * s;
return a;
}
function vLetPerpendicularFoot (o, a, b, c) {
let ax = a[0], ay = a[1];
let bx = b[0], by = b[1];
let cx = c[0], cy = c[1];
let s = (((ax - bx) * (cx - bx) + (ay - by) * (cy - by)) /
((cx - bx) * (cx - bx) + (cy - by) * (cy - by)));
o[0] = bx + (cx - bx) * s;
o[1] = by + (cy - by) * s;
return o;
}
function vNewPerpendicularFoot (a, b, c) {
let ax = a[0], ay = a[1];
let bx = b[0], by = b[1];
let cx = c[0], cy = c[1];
let s = (((ax - bx) * (cx - bx) + (ay - by) * (cy - by)) /
((cx - bx) * (cx - bx) + (cy - by) * (cy - by)));
return [bx + (cx - bx) * s,
by + (cy - by) * s];
}
function vReverse (a) {
a[0] = -a[0];
a[1] = -a[1];
return a;
}
function vLetReverse (o, a) {
o[0] = -a[0];
o[1] = -a[1];
return o;
}
function vNewReverse (a) {
return [-a[0],
-a[1]];
}
function vRotate (a, t) {
let ax = a[0], ay = a[1];
let c = cos (t), s = sin (t);
a[0] = c * ax - s * ay;
a[1] = s * ax + c * ay;
return a;
}
function vLetRotate (o, a, t) {
let ax = a[0], ay = a[1];
let c = cos (t), s = sin (t);
o[0] = c * ax - s * ay;
o[1] = s * ax + c * ay;
return o;
}
function vNewRotate (a, t) {
let ax = a[0], ay = a[1];
let c = cos (t), s = sin (t);
return [c * ax - s * ay,
s * ax + c * ay];
}
function vLetScalarX (o, s) {
o[0] = s;
o[1] = 0;
return o;
}
function vNewScalarX (s) {
return [s,
0];
}
function vLetScalarY (o, s) {
o[0] = 0;
o[1] = s;
return o;
}
function vNewScalarY (s) {
return [0,
s];
}
function vScaleS (a, s) {
a[0] *= s;
a[1] *= s;
return a;
}
function vLetScaleS (o, a, s) {
o[0] = a[0] * s;
o[1] = a[1] * s;
return o;
}
function vNewScaleS (a, s) {
return [a[0] * s,
a[1] * s];
}
function vScaleV (a, v) {
a[0] *= v[0];
a[1] *= v[1];
return a;
}
function vLetScaleV (o, a, v) {
o[0] = a[0] * v[0];
o[1] = a[1] * v[1];
return o;
}
function vNewScaleV (a, v) {
return [a[0] * v[0],
a[1] * v[1]];
}
function vScaleX (a, p) {
a[0] *= p;
return a;
}
function vLetScaleX (o, a, p) {
o[0] = a[0] * p;
o[1] = a[1];
return o;
}
function vNewScaleX (a, p) {
return [a[0] * p,
a[1]];
}
function vScaleY (a, q) {
a[1] *= q;
return a;
}
function vLetScaleY (o, a, q) {
o[0] = a[0];
o[1] = a[1] * q;
return o;
}
function vNewScaleY (a, q) {
return [a[0],
a[1] * q];
}
function vScaleXY (a, p, q) {
a[0] *= p;
a[1] *= q;
return a;
}
function vLetScaleXY (o, a, p, q) {
o[0] = a[0] * p;
o[1] = a[1] * q;
return o;
}
function vNewScaleXY (a, p, q) {
return [a[0] * p,
a[1] * q];
}
function vStretch (a, s, t) {
let ax = a[0], ay = a[1];
s += t / hypot2 (ax, ay);
a[0] = ax * s;
a[1] = ay * s;
return a;
}
function vLetStretch (o, a, s, t) {
let ax = a[0], ay = a[1];
s += t / hypot2 (ax, ay);
o[0] = ax * s;
o[1] = ay * s;
return o;
}
function vNewStretch (a, s, t) {
let ax = a[0], ay = a[1];
s += t / hypot2 (ax, ay);
return [ax * s,
ay * s];
}
function vStretchFrom (a, s, t, b) {
let ax = a[0], ay = a[1];
let bx = b[0], by = b[1];
ax -= bx;
ay -= by;
s += t / hypot2 (ax, ay);
a[0] = ax * s + bx;
a[1] = ay * s + by;
return a;
}
function vLetStretchFrom (o, a, s, t, b) {
let ax = a[0], ay = a[1];
let bx = b[0], by = b[1];
ax -= bx;
ay -= by;
s += t / hypot2 (ax, ay);
o[0] = ax * s + bx;
o[1] = ay * s + by;
return o;
}
function vNewStretchFrom (a, s, t, b) {
let ax = a[0], ay = a[1];
let bx = b[0], by = b[1];
ax -= bx;
ay -= by;
s += t / hypot2 (ax, ay);
return [ax * s + bx,
ay * s + by];
}
function vSubtractV (a, b) {
a[0] -= b[0];
a[1] -= b[1];
return a;
}
function vLetSubtractV (o, a, b) {
o[0] = a[0] - b[0];
o[1] = a[1] - b[1];
return o;
}
function vNewSubtractV (a, b) {
return [a[0] - b[0],
a[1] - b[1]];
}
function vSubtractX (a, d) {
a[0] -= d;
return a;
}
function vLetSubtractX (o, a, d) {
o[0] = a[0] - d;
o[1] = a[1];
return o;
}
function vNewSubtractX (a, d) {
return [a[0] - d,
a[1]];
}
function vSubtractY (a, e) {
a[1] -= e;
return a;
}
function vLetSubtractY (o, a, e) {
o[0] = a[0];
o[1] = a[1] - e;
return o;
}
function vNewSubtractY (a, e) {
return [a[0],
a[1] - e];
}
function vSubtractXY (a, d, e) {
a[0] -= d;
a[1] -= e;
return a;
}
function vLetSubtractXY (o, a, d, e) {
o[0] = a[0] - d;
o[1] = a[1] - e;
return o;
}
function vNewSubtractXY (a, d, e) {
return [a[0] - d,
a[1] - e];
}
function vTransform (a, m) {
let ax = a[0], ay = a[1];
a[0] = m[0] * ax + m[1] * ay + m[2];
a[1] = m[3] * ax + m[4] * ay + m[5];
return a;
}
function vLetTransform (o, a, m) {
let ax = a[0], ay = a[1];
o[0] = m[0] * ax + m[1] * ay + m[2];