Did I find the right examples for you? yes no

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
Calculate the cartesion distance between objects or points

Each parameter should either be a position tuple or an object with
a .pos and .size

        def distance(o1, o2):
    """Calculate the cartesion distance between objects or points

    Each parameter should either be a position tuple or an object with
    a .pos and .size

    """
    p1, p2 = nearest_points(o1, o2)
    dx, dy = p1[0] - p2[0], p1[1] - p2[1]
    return sqrt(dx ** 2 + dy ** 2)
        


src/m/a/marionette-0.2/marionette/world.py   marionette(Download)
from .collision import CollisionDetector
from .items import Item, get_item_property
from .utils.spatial import distance as calc_distance
 
from math import atan, cos, pi, sin, sqrt
    def distance(self, obj1, obj2):
        key = '%d-%d' % tuple(sorted([obj1.uid, obj2.uid]))
        if key not in self._distances:
            self._distances[key] = calc_distance(obj1, obj2)
        return self._distances[key]