Skip to content

Instantly share code, notes, and snippets.

@shastikk
Created June 21, 2016 17:12
Show Gist options
  • Select an option

  • Save shastikk/f3e2692b4ea6471db9bac35fda7c4fc2 to your computer and use it in GitHub Desktop.

Select an option

Save shastikk/f3e2692b4ea6471db9bac35fda7c4fc2 to your computer and use it in GitHub Desktop.
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;
b.subpoints.get(i).yCoord += moveY;
System.out.println("The coordinates are {" + a.subpoints.get(i).xCoord + "," + a.subpoints.get(i).yCoord + "");
System.out.println("The coordinates are {" + b.subpoints.get(i).xCoord + "," + b.subpoints.get(i).yCoord + "");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment