# How to calculate world position of offset point based on rotation of an object in python

I have a sphere parented to another object, offset on the Z axis so that when i rotate the parent i can get the world position of the top part of the parent. How can i calculate this without needing the child sphere object in python?

Parent rotation: 0, 0, 0 Sphere World position: 0, 0, 0.1

Parent rotation: 12.4162, 39.7934, -16.6971 Sphere World position: 0.0537, -0.0386, 0.0750

Some matrix math.

Rotating the vector (0, 0, 1) by the euler rotation described in question (assuming default order 'XYZ')

>>> R = Euler(radians(a) for a in (12.4162, 39.7934, -16.6971))
>>> R
Euler((0.21670356392860413, 0.6945258378982544, -0.2914193570613861), 'XYZ')

>>> v = Vector((0, 0, 1))
>>> R.to_matrix() @ v
Vector((0.5369226336479187, -0.38553091883659363, 0.7503865361213684))


Ooops didn't see the point 0.1, notice though that each element is 10x the result in question, as is the length of the vector

A child object at (0, 0, 1) can be considered at the local coord (0, 0, 1) of the parent. To get global coordinate of a local coordinate we multiply by the objects matrix world.

Consider the following from the python console. In this case the "Circle" has no parent, so its origin, local coordinate (0, 0, 0) will be at its location.

>>> C.object
bpy.data.objects['Circle']

>>> C.object.location
Vector((1.0, 3.0, 2.0))

>>> C.object.rotation_euler
Euler((0.5235987901687622, 0.7853981852531433, 1.0471975803375244), 'XYZ')

>>> C.object.scale
Vector((2.0, 3.0, 3.0))


Ok lets look at the world matrix

>>> C.object.matrix_world
Matrix(((0.7071067094802856, -1.7196698188781738, 2.2175967693328857, 1.0),
(1.2247449159622192, 2.2175967693328857, 0.8409903645515442, 3.0),
(-1.4142135381698608, 1.0606601238250732, 1.8371171951293945, 2.0),
(0.0, 0.0, 0.0, 1.0)))

>>> C.object.matrix_world.translation
Vector((1.0, 3.0, 2.0))

>>> C.object.matrix_world.to_euler()
Euler((0.5235987901687622, 0.7853981852531433, 1.0471975803375244), 'XYZ')

>>> C.object.matrix_world.to_scale()
Vector((2.0, 3.0, 3.0))


The global location of local coordinate (0, 0, 1) of circle is

>>> C.object.matrix_world @ v
Vector((3.2175967693328857, 3.8409903049468994, 3.8371171951293945))

>>>