Get offset angle of orientation

I have 2 vectors

object.worldOrientation.col[2]

and

camera.worldPosition-objects.worldPosition

how can I get the angular distance from the local Z axis, and the vector to the camera?

VectDiff = object.worldOrientation.col[2]-(camera.worldPosition-objects.worldPosition)

ADist = VectDiff.magnitude?

is this correct? (ADist?)

I’m not exactly sure what you’re looking for but for angular difference, I normally use the dot product


Vec1 = object.getAxisVect([0,0,1]) 
Vec2 = object.getVectTo(camera)
dotproduct = Vec1.dot(Vec2)

getAxisToVect([0,0,1]) is local?

and

dotproduct = Vec1.dot(Vec2[1])

is what I think you mean

which is
camera.worldPosition-own.worldPosition

getAxisToVect([0,0,1]) is local?

I think it gets the local axis and translate it in to world or something? I’m not exactly sure

dotproduct = Vec1.dot(Vec2[1])

is what I think you mean

which is
camera.worldPosition-own.worldPosition

yeah that’s what i mean, my mistake, i forgot getVectTo return a list lol

mathutils.Vector.angle() can calculate you the including angle.

Make sure the vectors are relative to the same coordinate system (e.g. sceneSpace)