Skip to content

Commit b975fb7

Browse files
committed
split fmin code to a separate library
1 parent 475b2f0 commit b975fb7

File tree

8 files changed

+352
-692
lines changed

8 files changed

+352
-692
lines changed

index.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export {fmin, minimizeConjugateGradient, bisect} from "./src/fmin";
21
export {intersectionArea, circleCircleIntersection, circleOverlap, circleArea,
32
distance, circleIntegral} from "./src/circleintersection";
43
export {venn, greedyLayout, scaleSolution, normalizeSolution, bestInitialLayout,

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "venn.js",
3-
"version": "0.2.13",
3+
"version": "0.2.14",
44
"author": "Ben Frederickson <ben@benfrederickson.com> (http:/www.benfrederickson.com)",
55
"url": "https://github.com/benfred/venn.js/issues",
66
"devDependencies": {
@@ -44,6 +44,7 @@
4444
"postpublish": "zip -j build/venn.zip -- LICENSE README.md build/venn.js build/venn.min.js"
4545
},
4646
"dependencies": {
47+
"fmin": "0.0.2",
4748
"d3-selection": "^1.0.2",
4849
"d3-transition": "^1.0.1"
4950
}

src/diagram.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {transition} from "d3-transition";
33

44
import {venn, normalizeSolution, scaleSolution} from "./layout";
55
import {intersectionArea, distance, getCenter} from "./circleintersection";
6-
import {fmin} from "./fmin";
6+
import {nelderMead} from "../node_modules/fmin/index.js";
77

88
/*global console:true*/
99

@@ -363,10 +363,10 @@ export function computeTextCentre(interior, exterior) {
363363
}
364364

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

372372
// check solution, fallback as needed (happens if fully overlapped

src/fmin.js

-318
This file was deleted.

0 commit comments

Comments
 (0)