Skip to content

Instantly share code, notes, and snippets.

@shastikk
shastikk / Bundling.java
Created June 21, 2016 17:12
Method for very basic bundling
public void applyElectrostaticForces (double totalValue, Edge a, Edge b, int i, double x, double y, double multiplier)
{
double difference = Math.min(subpoints.size()-i, i+1);
double divisor = 1 / (Math.pow(difference,1.15) + 1);
double moveX = x * difference * multiplier * divisor;
a.subpoints.get(i).xCoord -= moveX;
b.subpoints.get(i).xCoord += moveX;
double moveY = y * difference * multiplier * divisor;
a.subpoints.get(i).yCoord -= moveY;