Setting Relative Location with Python

I’m looking to set locations of objects relative to their own referencing frame, i.e. moving it along its local axes as opposed to global axes.

specifically I’m looking to move a camera along its local Z axis, so as to zoom in and out, but a general example would help just the same.

thanks for the help!

i think you need sin, co-sin, something like this:

a = math.radians(ob.rotation_euler.x)
x = math.sin( a )
y = math.cos( a )

m = 0.1 # change this to move more or less along the local axis
ob.location.x = x * m
ob.location.y = y * m

I understand that it may take trigonometry to translate from absolute to relative coordinates, but your example isn’t quite right.

You’re not accounting for relative axis positions if you’re only using 2 variables, that only allows for relative axes that are restricted to a specific plane.