hi. i have a list of objects in a tuple. i want to get distance from object X to the each objects in my list and then return the smallest of the distances.
i’m stuck in some weird for cycle i know how to get the distance, hot to get the smallest value in a tuple but i can’t get this all to work together. :o
dist = 1000000 # big number
closest = None
for o in myTuple:
newdist = # dist from x to o - You know how to do it!
if newdist < dist:
dist = newdist
closest = o
# Here closest is the closest object - or None if no object is closer than big number
objects = (object1, object2, object3)
#assume that "object_x" is the object you can get the distances from
distances = sorted(objects, key=lambda x:object_x.getDistanceTo(x))
smallest = distances[0]