Skip to content

Commit

Permalink
split fmin code to a separate library
Browse files Browse the repository at this point in the history
  • Loading branch information
benfred committed Nov 25, 2016
1 parent 475b2f0 commit b975fb7
Show file tree
Hide file tree
Showing 8 changed files with 352 additions and 692 deletions.
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export {fmin, minimizeConjugateGradient, bisect} from "./src/fmin";
export {intersectionArea, circleCircleIntersection, circleOverlap, circleArea,
distance, circleIntegral} from "./src/circleintersection";
export {venn, greedyLayout, scaleSolution, normalizeSolution, bestInitialLayout,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "venn.js",
"version": "0.2.13",
"version": "0.2.14",
"author": "Ben Frederickson <[email protected]> (http:/www.benfrederickson.com)",
"url": "https://github.com/benfred/venn.js/issues",
"devDependencies": {
Expand Down Expand Up @@ -44,6 +44,7 @@
"postpublish": "zip -j build/venn.zip -- LICENSE README.md build/venn.js build/venn.min.js"
},
"dependencies": {
"fmin": "0.0.2",
"d3-selection": "^1.0.2",
"d3-transition": "^1.0.1"
}
Expand Down
6 changes: 3 additions & 3 deletions src/diagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {transition} from "d3-transition";

import {venn, normalizeSolution, scaleSolution} from "./layout";
import {intersectionArea, distance, getCenter} from "./circleintersection";
import {fmin} from "./fmin";
import {nelderMead} from "../node_modules/fmin/index.js";

/*global console:true*/

Expand Down Expand Up @@ -363,10 +363,10 @@ export function computeTextCentre(interior, exterior) {
}

// maximize the margin numerically
var solution = fmin(
var solution = nelderMead(
function(p) { return -1 * circleMargin({x: p[0], y: p[1]}, interior, exterior); },
[initial.x, initial.y],
{maxIterations:500, minErrorDelta:1e-10}).solution;
{maxIterations:500, minErrorDelta:1e-10}).x;
var ret = {x: solution[0], y: solution[1]};

// check solution, fallback as needed (happens if fully overlapped
Expand Down
318 changes: 0 additions & 318 deletions src/fmin.js

This file was deleted.

Loading

0 comments on commit b975fb7

Please sign in to comment.