Let's say that I have p-nodes on a two-dimensional pixel surface of size n by m, I want the nodes to be pulled together, so the further they separate the strong appeal. But if the distance between two nodes, say d (A, B) is less than a certain threshold value k, then they begin to reflect. Could someone get me to start with some code on how to update the coordinates of nodes over time.
I have something like the code below that is starting to get attention, but looking for some tips. (PS I can not use the existing library for this).
public class node{
float posX;
float posY;
}
public class mySimulator{
ArrayList<node> myNodes = new ArrayList<node>();
myNodes.add(.....
public void updateLocations(){
for(int i =0; i <= myNodes.size(); i++){
for(int i =0; i <= myNodes.size(); i++){
myNodes.get(i).posX = myNodes.get(i).posX + "some constant"*(myNodes.get(j).posX -myNodes.get(i).posX);
myNodes.get(i).posY = myNodes.get(i).posY + "some constant"*(myNodes.get(j).posY -myNodes.get(i).posY);
}
}
}
}
}
source
share