• Create Account

### #ActualShippou

Posted 14 January 2012 - 01:02 PM

I would like to knoow if my math is correct in calculating the distance between 2 objects on a 2D plain:
def distance(x1,x2,y1,y2):
# A squared + B squared = C squared
return ( ( (x2 - x1)**2) + ( (y2-y1)**2) )**.5
# Object 1 Location
coordinate1 = 2,8	 # x,y
# Object 2 Location
coordinate2 = 5,10	 # x,y
print (distance(coordinate1[0],coordinate2[0],coordinate1[1],coordinate2[1]))

Thanks.

### #1Shippou

Posted 14 January 2012 - 01:01 PM

I would like to knoow if my math is correct in calculatint the distance between 2 objects on a 2D plain:
def distance(x1,x2,y1,y2):
# A squared + B squared = C squared
return ( ( (x2 - x1)**2) + ( (y2-y1)**2) )**.5
# Object 1 Location
coordinate1 = 2,8	 # x,y
# Object 2 Location
coordinate2 = 5,10	 # x,y
print (distance(coordinate1[0],coordinate2[0],coordinate1[1],coordinate2[1]))

Thanks.

PARTNERS