Python Comparing instances?
I hope this makes sense
I have an Array of instances representing particles,
and i want to compare the distance between each particle pair
for example
say i have an array
[a, b, c] representing 3 particles a, b, c
how do i compare/ code it so that i get
the difference between pairs
a,b
a,c
b,c
only
rather that comparing the distances multiple times (getting repetive comparisons)between particles
ie
a,a
a,b
a,c
b,a
b,b
b,c
c,a
c,b
c,c
for i in range(len(myObjectArray)): obj1 = myObjectArray for j in range(i+1,len(myObjectArray)): obj2 = myObjectArray[j] calculateDistance( obj1, obj2 )
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement