CanSo technically I would like to convert the Euler coordinates to spherical coordinates. Can someone advise how should I compensate for the Y axis? Thanks.
I also tried the rotation matrix, which works perfectly again when the y axis rotation is 0.
import math
import bpy
locator = bpy.data.objects['Camera']
myobject = bpy.data.objects['Suzanne']
frontVector = [0,-6,0]
#Calculates a rotation of a point in 3d space
def rotationMatrix(vector,roll,pitch,yaw):
x = vector[0]*(math.cos(pitch)*math.cos(yaw))+vector[1]*(math.cos(pitch)*-math.sin(yaw)*math.cos(roll)+math.sin(pitch)*math.sin(roll))+vector[2]*(math.sin(pitch)*math.cos(roll)+(math.cos(pitch)*-math.sin(yaw))*-math.sin(roll))
y = vector[0]*math.sin(yaw)+vector[1]*(math.cos(yaw)*math.cos(roll))+vector[2]*(math.cos(yaw)*-math.sin(roll))
z = vector[0]*(-math.sin(pitch)*math.cos(yaw))+vector[1]*(-math.sin(pitch)*-math.sin(yaw)*math.cos(roll)+math.cos(pitch)*math.sin(roll))+vector[2]*(math.cos(pitch)*math.cos(roll)+-math.sin(pitch)*-math.sin(yaw)*-math.sin(roll))
print(x,y,z)
return(x,y,z)
coordinates = rotationMatrix(frontVector,myobject.rotation_euler[0],myobject.rotation_euler[1],myobject.rotation_euler[2])
locator.location = (coordinates[0],coordinates[1],coordinates[2])
```