aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/speedometer/d3-master/src/math
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2015-04-02 19:24:45 +0200
committerKristian Lyngstol <kristian@bohemians.org>2015-04-02 19:24:45 +0200
commit0d8bba263dc195147d6fdb09662e7926f0a58b3e (patch)
tree4c570b4376c323e585120e7695b8715be7aa8881 /web/nms.gathering.org/speedometer/d3-master/src/math
parente4354b47bd8891c5b1ee591fdf74b3ca67eee461 (diff)
Bump lots of changes
Diffstat (limited to 'web/nms.gathering.org/speedometer/d3-master/src/math')
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/math/abs.js1
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/math/adder.js34
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/math/index.js2
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/math/number.js7
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/math/random.js34
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/math/transform.js64
-rw-r--r--web/nms.gathering.org/speedometer/d3-master/src/math/trigonometry.js44
7 files changed, 186 insertions, 0 deletions
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/math/abs.js b/web/nms.gathering.org/speedometer/d3-master/src/math/abs.js
new file mode 100644
index 0000000..6c078b9
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/math/abs.js
@@ -0,0 +1 @@
+var abs = Math.abs;
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/math/adder.js b/web/nms.gathering.org/speedometer/d3-master/src/math/adder.js
new file mode 100644
index 0000000..08fa289
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/math/adder.js
@@ -0,0 +1,34 @@
+// Adds floating point numbers with twice the normal precision.
+// Reference: J. R. Shewchuk, Adaptive Precision Floating-Point Arithmetic and
+// Fast Robust Geometric Predicates, Discrete & Computational Geometry 18(3)
+// 305–363 (1997).
+// Code adapted from GeographicLib by Charles F. F. Karney,
+// http://geographiclib.sourceforge.net/
+// See lib/geographiclib/LICENSE for details.
+
+function d3_adder() {}
+
+d3_adder.prototype = {
+ s: 0, // rounded value
+ t: 0, // exact error
+ add: function(y) {
+ d3_adderSum(y, this.t, d3_adderTemp);
+ d3_adderSum(d3_adderTemp.s, this.s, this);
+ if (this.s) this.t += d3_adderTemp.t;
+ else this.s = d3_adderTemp.t;
+ },
+ reset: function() {
+ this.s = this.t = 0;
+ },
+ valueOf: function() {
+ return this.s;
+ }
+};
+
+var d3_adderTemp = new d3_adder;
+
+function d3_adderSum(a, b, o) {
+ var x = o.s = a + b, // a + b
+ bv = x - a, av = x - bv; // b_virtual & a_virtual
+ o.t = (a - av) + (b - bv); // a_roundoff + b_roundoff
+}
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/math/index.js b/web/nms.gathering.org/speedometer/d3-master/src/math/index.js
new file mode 100644
index 0000000..20f6966
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/math/index.js
@@ -0,0 +1,2 @@
+import "random";
+import "transform";
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/math/number.js b/web/nms.gathering.org/speedometer/d3-master/src/math/number.js
new file mode 100644
index 0000000..44ff332
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/math/number.js
@@ -0,0 +1,7 @@
+function d3_number(x) {
+ return x === null ? NaN : +x;
+}
+
+function d3_numeric(x) {
+ return !isNaN(x);
+}
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/math/random.js b/web/nms.gathering.org/speedometer/d3-master/src/math/random.js
new file mode 100644
index 0000000..d0c6ba0
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/math/random.js
@@ -0,0 +1,34 @@
+d3.random = {
+ normal: function(µ, σ) {
+ var n = arguments.length;
+ if (n < 2) σ = 1;
+ if (n < 1) µ = 0;
+ return function() {
+ var x, y, r;
+ do {
+ x = Math.random() * 2 - 1;
+ y = Math.random() * 2 - 1;
+ r = x * x + y * y;
+ } while (!r || r > 1);
+ return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r);
+ };
+ },
+ logNormal: function() {
+ var random = d3.random.normal.apply(d3, arguments);
+ return function() {
+ return Math.exp(random());
+ };
+ },
+ bates: function(m) {
+ var random = d3.random.irwinHall(m);
+ return function() {
+ return random() / m;
+ };
+ },
+ irwinHall: function(m) {
+ return function() {
+ for (var s = 0, j = 0; j < m; j++) s += Math.random();
+ return s;
+ };
+ }
+};
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/math/transform.js b/web/nms.gathering.org/speedometer/d3-master/src/math/transform.js
new file mode 100644
index 0000000..8a5e6cd
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/math/transform.js
@@ -0,0 +1,64 @@
+import "../core/document";
+import "../core/ns";
+
+d3.transform = function(string) {
+ var g = d3_document.createElementNS(d3.ns.prefix.svg, "g");
+ return (d3.transform = function(string) {
+ if (string != null) {
+ g.setAttribute("transform", string);
+ var t = g.transform.baseVal.consolidate();
+ }
+ return new d3_transform(t ? t.matrix : d3_transformIdentity);
+ })(string);
+};
+
+// Compute x-scale and normalize the first row.
+// Compute shear and make second row orthogonal to first.
+// Compute y-scale and normalize the second row.
+// Finally, compute the rotation.
+function d3_transform(m) {
+ var r0 = [m.a, m.b],
+ r1 = [m.c, m.d],
+ kx = d3_transformNormalize(r0),
+ kz = d3_transformDot(r0, r1),
+ ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0;
+ if (r0[0] * r1[1] < r1[0] * r0[1]) {
+ r0[0] *= -1;
+ r0[1] *= -1;
+ kx *= -1;
+ kz *= -1;
+ }
+ this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_degrees;
+ this.translate = [m.e, m.f];
+ this.scale = [kx, ky];
+ this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 0;
+};
+
+d3_transform.prototype.toString = function() {
+ return "translate(" + this.translate
+ + ")rotate(" + this.rotate
+ + ")skewX(" + this.skew
+ + ")scale(" + this.scale
+ + ")";
+};
+
+function d3_transformDot(a, b) {
+ return a[0] * b[0] + a[1] * b[1];
+}
+
+function d3_transformNormalize(a) {
+ var k = Math.sqrt(d3_transformDot(a, a));
+ if (k) {
+ a[0] /= k;
+ a[1] /= k;
+ }
+ return k;
+}
+
+function d3_transformCombine(a, b, k) {
+ a[0] += k * b[0];
+ a[1] += k * b[1];
+ return a;
+}
+
+var d3_transformIdentity = {a: 1, b: 0, c: 0, d: 1, e: 0, f: 0};
diff --git a/web/nms.gathering.org/speedometer/d3-master/src/math/trigonometry.js b/web/nms.gathering.org/speedometer/d3-master/src/math/trigonometry.js
new file mode 100644
index 0000000..d7099a4
--- /dev/null
+++ b/web/nms.gathering.org/speedometer/d3-master/src/math/trigonometry.js
@@ -0,0 +1,44 @@
+var ε = 1e-6,
+ ε2 = ε * ε,
+ π = Math.PI,
+ τ = 2 * π,
+ τε = τ - ε,
+ halfπ = π / 2,
+ d3_radians = π / 180,
+ d3_degrees = 180 / π;
+
+function d3_sgn(x) {
+ return x > 0 ? 1 : x < 0 ? -1 : 0;
+}
+
+// Returns the 2D cross product of AB and AC vectors, i.e., the z-component of
+// the 3D cross product in a quadrant I Cartesian coordinate system (+x is
+// right, +y is up). Returns a positive value if ABC is counter-clockwise,
+// negative if clockwise, and zero if the points are collinear.
+function d3_cross2d(a, b, c) {
+ return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
+}
+
+function d3_acos(x) {
+ return x > 1 ? 0 : x < -1 ? π : Math.acos(x);
+}
+
+function d3_asin(x) {
+ return x > 1 ? halfπ : x < -1 ? -halfπ : Math.asin(x);
+}
+
+function d3_sinh(x) {
+ return ((x = Math.exp(x)) - 1 / x) / 2;
+}
+
+function d3_cosh(x) {
+ return ((x = Math.exp(x)) + 1 / x) / 2;
+}
+
+function d3_tanh(x) {
+ return ((x = Math.exp(2 * x)) - 1) / (x + 1);
+}
+
+function d3_haversin(x) {
+ return (x = Math.sin(x / 2)) * x;
+}