Hi everyone, i am trying to find the distance of 3 dimensional bodies. I am able to find the two bodies furthest from each other, but i cannot find the bodies closest to each other.
it displays 0(it's body to itself). is there a way to negate the program from comparing it to itself?
The program works but it always find the closest body as itself.
part of the program.
There are special cases whenever l is equal to q. In those cases, your if statement evaluates to something similar to this: s[l].getDistance(smallest)>0 //Distance to the same body is 0.
Maybe you could use another if statement in the inner loop to avoid those comparisons?