I am trying to make a module for calculating the position of the object from the obj.getDistanceTo(obj) call
using the Pythagoras method here is the code:
import math
import cmath
def setDistanceToPosition(objfrom, objto, dist):
""" get the distance of two objects and uses that to position the object with xyz using the inverse of Pythagoras """
fPos = objfrom.worldPosition
tPos = objto.worldPosition
Dx = tPos[0] - fPos[0]
Dy = tPos[1] - fPos[1]
Dz = tPos[2] - fPos[2]
Nd = dist**2-Dz**2
Nx = Nd-Dy**2
Ny = Nd-Dx**2
print(Nd)
print(Nx)
print(Ny)
x = fPos[0]+cmath.sqrt(Nx)
y = fPos[1]+cmath.sqrt(Ny)
z = fPos[2]+cmath.sqrt(Nd)
newpos = [x,y,z]
print(newpos)
return newpos
it returns a number like this 4.05627199861j.
does someone know what that means and how to solve this?