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?