• Advertisement
Sign in to follow this  

Python Comparing instances?

This topic is 3086 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement

for i in range(len(myObjectArray)):
obj1 = myObjectArray
for j in range(i+1,len(myObjectArray)):
obj2 = myObjectArray[j]
calculateDistance( obj1, obj2 )

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement