# Given the local coordinates of a parented object, how do I get its global coordinates using the Python API?

Here is my setup:

• I have the default cube
• I make a sphere and move it y+4 (now at 0,4,0)
• I parent the sphere (child) to the cube (parent)
• the sphere location is [0,4,0] in local coordinates. It's the same for global coordinates. (This is a simplified example.)

I want to programmatically get the sphere's coordinates in the global space.

Scouring the web, I have found the following general formula for getting global coordinates from local ones:

sphere.matrix_world * sphere.location


In the above example, if I plug that into the python console, it produces [0,8,0]. Why 8? It should be 4, no? Is this not the correct formula? If I make the example more complex (by rotating the cube, for example) I still get this 'doubling' effect. [0,3,0] becomes [0,6,0]. What is the correct python expression to get the correct global coordinates of the parented sphere?

default_cube.matrix_world * sphere.matrix_basis

sphere.matrix_world.translation

• There's also a more or less equal alternative to Object.matrix_world.translation: to_translation(). In contrast to translation, there's always a copy made and modifications to the Vector object won't affect the original matrix. – CoDEmanX Jan 7 '15 at 9:04