maya python, finding the distance between two vectors

Great little funciton for finding the distance between two points in maya.

import maya.cmds as Mc 
from math import pow,sqrt

def GetDistance(objA, objB):
	gObjA = Mc.xform(objA, q=True, t=True, ws=True)
	gObjB = Mc.xform(objB, q=True, t=True, ws=True)
	
	return sqrt(pow(gObjA[0]-gObjB[0],2)+pow(gObjA[1]-gObjB[1],2)+pow(gObjA[2]-gObjB[2],2))

2 thoughts on “maya python, finding the distance between two vectors”

Leave a Reply to Pete Cancel reply

Your email address will not be published. Required fields are marked *