code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function LinearPosition$1(x0, x1, y0, y1){ this.x0 = x0; this.x1 = x1; this.y0 = y0; this.y1 = y1; }
Compute the curve derivative (hodograph) at t.
LinearPosition$1
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
svgPathProperties = function(svgString) { var length = 0; var partial_lengths = []; var functions = []; function svgProperties(string){ if(!string){return null;} var parsed = parse$1(string); var cur = [0, 0]; var prev_point = [0, 0]; var curve; var ringStart; for (var i = 0; i < pa...
Compute the curve derivative (hodograph) at t.
svgPathProperties
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function svgProperties(string){ if(!string){return null;} var parsed = parse$1(string); var cur = [0, 0]; var prev_point = [0, 0]; var curve; var ringStart; for (var i = 0; i < parsed.length; i++){ //moveTo if(parsed[i][0] === "M"){ cur = [parsed[i][1], parsed[i][2]]; ...
Compute the curve derivative (hodograph) at t.
svgProperties
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
getPartAtLength = function(fractionLength){ if(fractionLength < 0){ fractionLength = 0; } else if(fractionLength > length){ fractionLength = length; } var i = partial_lengths.length - 1; while(partial_lengths[i] >= fractionLength && partial_lengths[i] > 0){ i--; } i++; ...
Compute the curve derivative (hodograph) at t.
getPartAtLength
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function distance(a, b) { return Math.sqrt( (a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]) ); }
Compute the curve derivative (hodograph) at t.
distance
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function pointAlong(a, b, pct) { return [a[0] + (b[0] - a[0]) * pct, a[1] + (b[1] - a[1]) * pct]; }
Compute the curve derivative (hodograph) at t.
pointAlong
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function samePoint(a, b) { return distance(a, b) < 1e-9; }
Compute the curve derivative (hodograph) at t.
samePoint
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function interpolatePoints(a, b, string) { var interpolators = a.map(function (d, i) { return interpolatePoint(d, b[i]); }); return function(t) { var values = interpolators.map(function (fn) { return fn(t); }); return string ? toPathString(values) : values; }; }
Compute the curve derivative (hodograph) at t.
interpolatePoints
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function interpolatePoint(a, b) { return function(t) { return a.map(function (d, i) { return d + t * (b[i] - d); }); }; }
Compute the curve derivative (hodograph) at t.
interpolatePoint
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function isFiniteNumber(number) { return typeof number === "number" && isFinite(number); }
Compute the curve derivative (hodograph) at t.
isFiniteNumber
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function polygonCentroid$$1(polygon) { return nonZeroArea(polygon) ? d3Centroid(polygon) : [ (polygon[0][0] + polygon[polygon.length - 1][0]) / 2, (polygon[0][1] + polygon[polygon.length - 1][1]) / 2 ]; }
Compute the curve derivative (hodograph) at t.
polygonCentroid$$1
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function nonZeroArea(polygon) { for (var i = 0; i < polygon.length - 2; i++) { var a = polygon[i], b = polygon[i + 1], c = polygon[i + 2]; if (a[0] * (b[1] - c[1]) + b[0] * (c[1] - a[1]) + c[0] * (a[1] - b[1])) { return true; } } return false; }
Compute the curve derivative (hodograph) at t.
nonZeroArea
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function parse$$1(str) { return new svgpath(str).abs(); }
Compute the curve derivative (hodograph) at t.
parse$$1
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function split(parsed) { return parsed .toString() .split("M") .map(function (d, i) { d = d.trim(); return i && d ? "M" + d : d; }) .filter(function (d) { return d; }); }
Compute the curve derivative (hodograph) at t.
split
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function toPathString(ring) { return "M" + ring.join("L") + "Z"; }
Compute the curve derivative (hodograph) at t.
toPathString
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function splitPathString(str) { return split(parse$$1(str)); }
Compute the curve derivative (hodograph) at t.
splitPathString
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function pathStringToRing(str, maxSegmentLength) { var parsed = parse$$1(str); return exactRing(parsed) || approximateRing(parsed, maxSegmentLength); }
Compute the curve derivative (hodograph) at t.
pathStringToRing
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function exactRing(parsed) { var segments = parsed.segments || [], ring = []; if (!segments.length || segments[0][0] !== "M") { return false; } for (var i = 0; i < segments.length; i++) { var ref = segments[i]; var command = ref[0]; var x = ref[1]; var y = ref[2]; if ((command === ...
Compute the curve derivative (hodograph) at t.
exactRing
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function approximateRing(parsed, maxSegmentLength) { var ringPath = split(parsed)[0], ring = [], len, m, numPoints = 3; if (!ringPath) { throw new TypeError(INVALID_INPUT); } m = measure(ringPath); len = m.getTotalLength(); if ( maxSegmentLength && isFiniteNumber(maxSegmentLen...
Compute the curve derivative (hodograph) at t.
approximateRing
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function measure(d) { // Use native browser measurement if running in browser if (typeof window !== "undefined" && window && window.document) { try { var path = window.document.createElementNS( "http://www.w3.org/2000/svg", "path" ); path.setAttributeNS(null, "d", d); ret...
Compute the curve derivative (hodograph) at t.
measure
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function addPoints(ring, numPoints) { var desiredLength = ring.length + numPoints, step = polygonLength(ring) / numPoints; var i = 0, cursor = 0, insertAt = step / 2; while (ring.length < desiredLength) { var a = ring[i], b = ring[(i + 1) % ring.length], segment = distance(a, b); ...
Compute the curve derivative (hodograph) at t.
addPoints
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function bisect(ring, maxSegmentLength) { if ( maxSegmentLength === void 0 ) maxSegmentLength = Infinity; for (var i = 0; i < ring.length; i++) { var a = ring[i], b = i === ring.length - 1 ? ring[0] : ring[i + 1]; // Could splice the whole set for a segment instead, but a bit messy while (distan...
Compute the curve derivative (hodograph) at t.
bisect
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function normalizeRing(ring, maxSegmentLength) { var points, area, skipBisect; if (typeof ring === "string") { var converted = pathStringToRing(ring, maxSegmentLength); ring = converted.ring; skipBisect = converted.skipBisect; } else if (!Array.isArray(ring)) { throw new TypeError(INVALID_INPUT);...
Compute the curve derivative (hodograph) at t.
normalizeRing
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function validRing(ring) { return ring.every(function(point) { return ( Array.isArray(point) && point.length >= 2 && isFiniteNumber(point[0]) && isFiniteNumber(point[1]) ); }); }
Compute the curve derivative (hodograph) at t.
validRing
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
rotate = function(ring, vs) { var len = ring.length, min = Infinity, bestOffset, sumOfSquares, spliced; var loop = function ( offset ) { sumOfSquares = 0; vs.forEach(function(p, i) { var d = distance(ring[(offset + i) % len], p); sumOfSquares += d * d; }); if (sumOfSqu...
Compute the curve derivative (hodograph) at t.
rotate
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
loop = function ( offset ) { sumOfSquares = 0; vs.forEach(function(p, i) { var d = distance(ring[(offset + i) % len], p); sumOfSquares += d * d; }); if (sumOfSquares < min) { min = sumOfSquares; bestOffset = offset; } }
Compute the curve derivative (hodograph) at t.
loop
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
interpolate = function( fromShape, toShape, ref ) { if ( ref === void 0 ) ref = {}; var maxSegmentLength = ref.maxSegmentLength; if ( maxSegmentLength === void 0 ) maxSegmentLength = 10; var string = ref.string; if ( string === void 0 ) string = true; var fromRing = normalizeRing(fromShape, maxSegmentLen...
Compute the curve derivative (hodograph) at t.
interpolate
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function interpolateRing(fromRing, toRing, string) { var diff; diff = fromRing.length - toRing.length; // TODO bisect and add points in one step? addPoints(fromRing, diff < 0 ? diff * -1 : 0); addPoints(toRing, diff > 0 ? diff : 0); rotate(fromRing, toRing); return interpolatePoints(fromRing, toRing, ...
Compute the curve derivative (hodograph) at t.
interpolateRing
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function earcut(data, holeIndices, dim) { dim = dim || 2; var hasHoles = holeIndices && holeIndices.length, outerLen = hasHoles ? holeIndices[0] * dim : data.length, outerNode = linkedList(data, 0, outerLen, dim, true), triangles = []; if (!outerNode || outerNode.next === outerNod...
Compute the curve derivative (hodograph) at t.
earcut
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function linkedList(data, start, end, dim, clockwise) { var i, last; if (clockwise === (signedArea(data, start, end, dim) > 0)) { for (i = start; i < end; i += dim) { last = insertNode(i, data[i], data[i + 1], last); } } else { for (i = end - dim; i >= start; i -= dim) { last = insertNode(i...
Compute the curve derivative (hodograph) at t.
linkedList
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function filterPoints(start, end) { if (!start) { return start; } if (!end) { end = start; } var p = start, again; do { again = false; if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { removeNode(p); p = end = p.prev; ...
Compute the curve derivative (hodograph) at t.
filterPoints
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) { if (!ear) { return; } // interlink polygon nodes in z-order if (!pass && invSize) { indexCurve(ear, minX, minY, invSize); } var stop = ear, prev, next; // iterate through ears, slicing them one by one while (ear.p...
Compute the curve derivative (hodograph) at t.
earcutLinked
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function isEar(ear) { var a = ear.prev, b = ear, c = ear.next; if (area(a, b, c) >= 0) { return false; } // reflex, can't be an ear // now make sure we don't have other points inside the potential ear var p = ear.next.next; while (p !== ear.prev) { if (pointInTriangle(a.x,...
Compute the curve derivative (hodograph) at t.
isEar
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function isEarHashed(ear, minX, minY, invSize) { var a = ear.prev, b = ear, c = ear.next; if (area(a, b, c) >= 0) { return false; } // reflex, can't be an ear // triangle bbox; min & max are calculated like this for speed var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b...
Compute the curve derivative (hodograph) at t.
isEarHashed
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function cureLocalIntersections(start, triangles, dim) { var p = start; do { var a = p.prev, b = p.next.next; if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { triangles.push(a.i / dim); triangles.push(p.i / di...
Compute the curve derivative (hodograph) at t.
cureLocalIntersections
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function splitEarcut(start, triangles, dim, minX, minY, invSize) { // look for a valid diagonal that divides the polygon into two var a = start; do { var b = a.next.next; while (b !== a.prev) { if (a.i !== b.i && isValidDiagonal(a, b)) { // split the polygon in tw...
Compute the curve derivative (hodograph) at t.
splitEarcut
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function eliminateHoles(data, holeIndices, outerNode, dim) { var queue = [], i, len, start, end, list; for (i = 0, len = holeIndices.length; i < len; i++) { start = holeIndices[i] * dim; end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; list = linkedList(data, start, e...
Compute the curve derivative (hodograph) at t.
eliminateHoles
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function compareX(a, b) { return a.x - b.x; }
Compute the curve derivative (hodograph) at t.
compareX
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function eliminateHole(hole, outerNode) { outerNode = findHoleBridge(hole, outerNode); if (outerNode) { var b = splitPolygon(outerNode, hole); filterPoints(b, b.next); } }
Compute the curve derivative (hodograph) at t.
eliminateHole
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function findHoleBridge(hole, outerNode) { var p = outerNode, hx = hole.x, hy = hole.y, qx = -Infinity, m; // find a segment intersected by a ray from the hole's leftmost point to the left; // segment's endpoint with lesser x will be potential connection point do { ...
Compute the curve derivative (hodograph) at t.
findHoleBridge
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function sectorContainsSector(m, p) { return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0; }
Compute the curve derivative (hodograph) at t.
sectorContainsSector
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function indexCurve(start, minX, minY, invSize) { var p = start; do { if (p.z === null) { p.z = zOrder(p.x, p.y, minX, minY, invSize); } p.prevZ = p.prev; p.nextZ = p.next; p = p.next; } while (p !== start); p.prevZ.nextZ = null; p.prevZ = null; sortLinked(p); }
Compute the curve derivative (hodograph) at t.
indexCurve
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function sortLinked(list) { var i, p, q, e, tail, numMerges, pSize, qSize, inSize = 1; do { p = list; list = null; tail = null; numMerges = 0; while (p) { numMerges++; q = p; pSize = 0; for (i = 0; i < inSize; i++)...
Compute the curve derivative (hodograph) at t.
sortLinked
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function zOrder(x, y, minX, minY, invSize) { // coords are transformed into non-negative 15-bit integer range x = 32767 * (x - minX) * invSize; y = 32767 * (y - minY) * invSize; x = (x | (x << 8)) & 0x00FF00FF; x = (x | (x << 4)) & 0x0F0F0F0F; x = (x | (x << 2)) & 0x33333333; x = (x | (x <<...
Compute the curve derivative (hodograph) at t.
zOrder
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function getLeftmost(start) { var p = start, leftmost = start; do { if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) { leftmost = p; } p = p.next; } while (p !== start); return leftmost; }
Compute the curve derivative (hodograph) at t.
getLeftmost
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; }
Compute the curve derivative (hodograph) at t.
pointInTriangle
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function isValidDiagonal(a, b) { return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not c...
Compute the curve derivative (hodograph) at t.
isValidDiagonal
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function area(p, q, r) { return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); }
Compute the curve derivative (hodograph) at t.
area
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function equals(p1, p2) { return p1.x === p2.x && p1.y === p2.y; }
Compute the curve derivative (hodograph) at t.
equals
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function intersects(p1, q1, p2, q2) { var o1 = sign(area(p1, q1, p2)); var o2 = sign(area(p1, q1, q2)); var o3 = sign(area(p2, q2, p1)); var o4 = sign(area(p2, q2, q1)); if (o1 !== o2 && o3 !== o4) { return true; } // general case if (o1 === 0 && onSegment(p1, p2, q1)) { return true; } // p1, ...
Compute the curve derivative (hodograph) at t.
intersects
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function onSegment(p, q, r) { return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y); }
Compute the curve derivative (hodograph) at t.
onSegment
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function sign(num) { return num > 0 ? 1 : num < 0 ? -1 : 0; }
Compute the curve derivative (hodograph) at t.
sign
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function intersectsPolygon(a, b) { var p = a; do { if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b)) { return true; } p = p.next; } while (p !== a); return false; }
Compute the curve derivative (hodograph) at t.
intersectsPolygon
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function locallyInside(a, b) { return area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; }
Compute the curve derivative (hodograph) at t.
locallyInside
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function middleInside(a, b) { var p = a, inside = false, px = (a.x + b.x) / 2, py = (a.y + b.y) / 2; do { if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) { inside = !inside; } ...
Compute the curve derivative (hodograph) at t.
middleInside
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function splitPolygon(a, b) { var a2 = new Node(a.i, a.x, a.y), b2 = new Node(b.i, b.x, b.y), an = a.next, bp = b.prev; a.next = b; b.prev = a; a2.next = an; an.prev = a2; b2.next = a2; a2.prev = b2; bp.next = b2; b2.prev = bp; return b2; }
Compute the curve derivative (hodograph) at t.
splitPolygon
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function insertNode(i, x, y, last) { var p = new Node(i, x, y); if (!last) { p.prev = p; p.next = p; } else { p.next = last.next; p.prev = last; last.next.prev = p; last.next = p; } return p; }
Compute the curve derivative (hodograph) at t.
insertNode
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function removeNode(p) { p.next.prev = p.prev; p.prev.next = p.next; if (p.prevZ) { p.prevZ.nextZ = p.nextZ; } if (p.nextZ) { p.nextZ.prevZ = p.prevZ; } }
Compute the curve derivative (hodograph) at t.
removeNode
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function Node(i, x, y) { // vertex index in coordinates array this.i = i; // vertex coordinates this.x = x; this.y = y; // previous and next vertex nodes in a polygon ring this.prev = null; this.next = null; // z-order curve value this.z = null; // previous and next nodes...
Compute the curve derivative (hodograph) at t.
Node
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function signedArea(data, start, end, dim) { var sum = 0; for (var i = start, j = end - dim; i < end; i += dim) { sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); j = i; } return sum; }
Compute the curve derivative (hodograph) at t.
signedArea
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
identity = function(x) { return x; }
Compute the curve derivative (hodograph) at t.
identity
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
transform = function(transform) { if (transform == null) { return identity; } var x0, y0, kx = transform.scale[0], ky = transform.scale[1], dx = transform.translate[0], dy = transform.translate[1]; return function(input, i) { if (!i) { x0 = y0 = 0; } var j = 2, n = input.leng...
Compute the curve derivative (hodograph) at t.
transform
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
reverse = function(array, n) { var t, j = array.length, i = j - n; while (i < --j) { t = array[i], array[i++] = array[j], array[j] = t; } }
Compute the curve derivative (hodograph) at t.
reverse
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
feature = function(topology, o) { return o.type === "GeometryCollection" ? {type: "FeatureCollection", features: o.geometries.map(function(o) { return feature$1(topology, o); })} : feature$1(topology, o); }
Compute the curve derivative (hodograph) at t.
feature
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function feature$1(topology, o) { var id = o.id, bbox = o.bbox, properties = o.properties == null ? {} : o.properties, geometry = object(topology, o); return id == null && bbox == null ? {type: "Feature", properties: properties, geometry: geometry} : bbox == null ? {type: "Feature", id: id, ...
Compute the curve derivative (hodograph) at t.
feature$1
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function object(topology, o) { var transformPoint = transform(topology.transform), arcs = topology.arcs; function arc(i, points) { if (points.length) { points.pop(); } for (var a = arcs[i < 0 ? ~i : i], k = 0, n = a.length; k < n; ++k) { points.push(transformPoint(a[k], k)); } if (i < 0...
Compute the curve derivative (hodograph) at t.
object
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function arc(i, points) { if (points.length) { points.pop(); } for (var a = arcs[i < 0 ? ~i : i], k = 0, n = a.length; k < n; ++k) { points.push(transformPoint(a[k], k)); } if (i < 0) { reverse(points, n); } }
Compute the curve derivative (hodograph) at t.
arc
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function point(p) { return transformPoint(p); }
Compute the curve derivative (hodograph) at t.
point
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function line(arcs) { var points = []; for (var i = 0, n = arcs.length; i < n; ++i) { arc(arcs[i], points); } if (points.length < 2) { points.push(points[0]); } // This should never happen per the specification. return points; }
Compute the curve derivative (hodograph) at t.
line
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function ring(arcs) { var points = line(arcs); while (points.length < 4) { points.push(points[0]); } // This may happen if an arc has only two points. return points; }
Compute the curve derivative (hodograph) at t.
ring
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function polygon(arcs) { return arcs.map(ring); }
Compute the curve derivative (hodograph) at t.
polygon
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function geometry(o) { var type = o.type, coordinates; switch (type) { case "GeometryCollection": return {type: type, geometries: o.geometries.map(geometry)}; case "Point": coordinates = point(o.coordinates); break; case "MultiPoint": coordinates = o.coordinates.map(point); break; case "...
Compute the curve derivative (hodograph) at t.
geometry
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
stitch = function(topology, arcs) { var stitchedArcs = {}, fragmentByStart = {}, fragmentByEnd = {}, fragments = [], emptyIndex = -1; // Stitch empty arcs first, since they may be subsumed by other arcs. arcs.forEach(function(i, j) { var arc = topology.arcs[i < 0 ? ~i : i], t; if ...
Compute the curve derivative (hodograph) at t.
stitch
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function ends(i) { var arc = topology.arcs[i < 0 ? ~i : i], p0 = arc[0], p1; if (topology.transform) { p1 = [0, 0], arc.forEach(function(dp) { p1[0] += dp[0], p1[1] += dp[1]; }); } else { p1 = arc[arc.length - 1]; } return i < 0 ? [p1, p0] : [p0, p1]; }
Compute the curve derivative (hodograph) at t.
ends
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function flush(fragmentByEnd, fragmentByStart) { for (var k in fragmentByEnd) { var f = fragmentByEnd[k]; delete fragmentByStart[f.start]; delete f.start; delete f.end; f.forEach(function(i) { stitchedArcs[i < 0 ? ~i : i] = 1; }); fragments.push(f); } }
Compute the curve derivative (hodograph) at t.
flush
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function planarRingArea(ring) { var i = -1, n = ring.length, a, b = ring[n - 1], area = 0; while (++i < n) { a = b, b = ring[i], area += a[0] * b[1] - a[1] * b[0]; } return Math.abs(area); // Note: doubled area! }
Compute the curve derivative (hodograph) at t.
planarRingArea
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function mergeArcs(topology, objects) { var polygonsByArc = {}, polygons = [], groups = []; objects.forEach(geometry); function geometry(o) { switch (o.type) { case "GeometryCollection": o.geometries.forEach(geometry); break; case "Polygon": extract(o.arcs); break; case "MultiP...
Compute the curve derivative (hodograph) at t.
mergeArcs
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function geometry(o) { switch (o.type) { case "GeometryCollection": o.geometries.forEach(geometry); break; case "Polygon": extract(o.arcs); break; case "MultiPolygon": o.arcs.forEach(extract); break; } }
Compute the curve derivative (hodograph) at t.
geometry
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function extract(polygon) { polygon.forEach(function(ring) { ring.forEach(function(arc) { (polygonsByArc[arc = arc < 0 ? ~arc : arc] || (polygonsByArc[arc] = [])).push(polygon); }); }); polygons.push(polygon); }
Compute the curve derivative (hodograph) at t.
extract
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function area(ring) { return planarRingArea(object(topology, {type: "Polygon", arcs: [ring]}).coordinates[0]); }
Compute the curve derivative (hodograph) at t.
area
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
bisect$1 = function(a, x) { var lo = 0, hi = a.length; while (lo < hi) { var mid = lo + hi >>> 1; if (a[mid] < x) { lo = mid + 1; } else { hi = mid; } } return lo; }
Compute the curve derivative (hodograph) at t.
bisect$1
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
neighbors = function(objects) { var indexesByArc = {}, // arc index -> array of object indexes neighbors = objects.map(function() { return []; }); function line(arcs, i) { arcs.forEach(function(a) { if (a < 0) { a = ~a; } var o = indexesByArc[a]; if (o) { o.push(i); } else { index...
Compute the curve derivative (hodograph) at t.
neighbors
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function line(arcs, i) { arcs.forEach(function(a) { if (a < 0) { a = ~a; } var o = indexesByArc[a]; if (o) { o.push(i); } else { indexesByArc[a] = [i]; } }); }
Compute the curve derivative (hodograph) at t.
line
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function polygon(arcs, i) { arcs.forEach(function(arc) { line(arc, i); }); }
Compute the curve derivative (hodograph) at t.
polygon
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function geometry(o, i) { if (o.type === "GeometryCollection") { o.geometries.forEach(function(o) { geometry(o, i); }); } else if (o.type in geometryType) { geometryType[o.type](o.arcs, i); } }
Compute the curve derivative (hodograph) at t.
geometry
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
ascending = function(a, b) { return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; }
Compute the curve derivative (hodograph) at t.
ascending
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
bisector = function(compare) { if (compare.length === 1) { compare = ascendingComparator(compare); } return { left: function(a, x, lo, hi) { if (lo == null) { lo = 0; } if (hi == null) { hi = a.length; } while (lo < hi) { var mid = lo + hi >>> 1; if (compare(a[mid], x) < 0) { l...
Compute the curve derivative (hodograph) at t.
bisector
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function ascendingComparator(f) { return function(d, x) { return ascending(f(d), x); }; }
Compute the curve derivative (hodograph) at t.
ascendingComparator
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function pair(a, b) { return [a, b]; }
Compute the curve derivative (hodograph) at t.
pair
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
number$1 = function(x) { return x === null ? NaN : +x; }
Compute the curve derivative (hodograph) at t.
number$1
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
extent = function(values, valueof) { var n = values.length, i = -1, value, min, max; if (valueof == null) { while (++i < n) { // Find the first comparable value. if ((value = values[i]) != null && value >= value) { min = max = value; while (++i < n) { // Compare th...
Compute the curve derivative (hodograph) at t.
extent
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
identity$1 = function(x) { return x; }
Compute the curve derivative (hodograph) at t.
identity$1
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
range = function(start, stop, step) { start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step; var i = -1, n = Math.max(0, Math.ceil((stop - start) / step)) | 0, range = new Array(n); while (++i < n) { range[i] = start + i * step; } ...
Compute the curve derivative (hodograph) at t.
range
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function tickIncrement(start, stop, count) { var step = (stop - start) / Math.max(0, count), power = Math.floor(Math.log(step) / Math.LN10), error = step / Math.pow(10, power); return power >= 0 ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power) : -Math.pow(1...
Compute the curve derivative (hodograph) at t.
tickIncrement
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function tickStep(start, stop, count) { var step0 = Math.abs(stop - start) / Math.max(0, count), step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)), error = step0 / step1; if (error >= e10) { step1 *= 10; } else if (error >= e5) { step1 *= 5; } else if (error >= e2) { step1 *= 2; } retu...
Compute the curve derivative (hodograph) at t.
tickStep
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
sturges = function(values) { return Math.ceil(Math.log(values.length) / Math.LN2) + 1; }
Compute the curve derivative (hodograph) at t.
sturges
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
quantile = function(values, p, valueof) { if (valueof == null) { valueof = number$1; } if (!(n = values.length)) { return; } if ((p = +p) <= 0 || n < 2) { return +valueof(values[0], 0, values); } if (p >= 1) { return +valueof(values[n - 1], n - 1, values); } var n, i = (n - 1) * p, i0 = Math.floor...
Compute the curve derivative (hodograph) at t.
quantile
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
min = function(values, valueof) { var n = values.length, i = -1, value, min; if (valueof == null) { while (++i < n) { // Find the first comparable value. if ((value = values[i]) != null && value >= value) { min = value; while (++i < n) { // Compare the remaining values. ...
Compute the curve derivative (hodograph) at t.
min
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function length$1(d) { return d.length; }
Compute the curve derivative (hodograph) at t.
length$1
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT
function createTopology(triangles, ring) { var arcIndices = {}, topology = { type: "Topology", objects: { triangles: { type: "GeometryCollection", geometries: [] } }, arcs: [] }; triangles.forEach(function(triangle) { var geometry = []; t...
Compute the curve derivative (hodograph) at t.
createTopology
javascript
veltman/flubber
build/flubber.js
https://github.com/veltman/flubber/blob/master/build/flubber.js
MIT