From 023925ef7ecf8314e51f2bb14717f88b92240438 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 31 Dec 2013 16:11:09 +0000 Subject: FDGL: Make repelling forces directionally proportional to area for tighter spacing. git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5241 a436a847-0d15-0410-975c-d299462d15a1 --- src/Canvas.cpp | 2 +- src/fdgl.hpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Canvas.cpp b/src/Canvas.cpp index b1d8900..abf809f 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -768,7 +768,7 @@ GanvCanvasImpl::layout_calculate(double dur, bool update) static const double SPRING_K = 48.0; // A light directional force to push sources to the top left - static const double DIR_MAGNITUDE = -2000.0; + static const double DIR_MAGNITUDE = -2200.0; Vector dir = { 0.0, 0.0 }; switch (_gcanvas->direction) { case GANV_DIRECTION_RIGHT: dir.x = DIR_MAGNITUDE; break; diff --git a/src/fdgl.hpp b/src/fdgl.hpp index 704eb4f..83d9981 100644 --- a/src/fdgl.hpp +++ b/src/fdgl.hpp @@ -16,7 +16,7 @@ #include #include -static const double CHARGE_KE = 100000000.0; +static const double CHARGE_KE = 200000000.0; struct Region { Vector pos; @@ -109,5 +109,7 @@ repel_force(const Region& a, const Region& b) const double mag = vec_mag(vec); const Vector force = vec_mult( vec, (CHARGE_KE * 0.5 / (mag * mag * mag * mag * mag))); - return vec_mult(force, vec_mult(a.area, b.area)); + const Vector dforce = { force.x * (a.area.x * b.area.x), + force.y * (a.area.y * b.area.y) }; + return dforce; } -- cgit v1.2.1