Switching between coordinate systems
To switch from a global coordinate system to a local coordinate system of an object, we need to multiply the global coordinates by the inverted matrix of an object:
1 2 3 4 5 |
import copy object_matrix_inverted = copy.copy(bpy.context.object.matrix_world) object_matrix_inverted.invert() cursor_location_local = object_matrix_inverted @ bpy.context.scene.cursor.location |
To switch from the local coordinate system of the object to the global coordinate system, we need to multiply the local coordinates by the matrix of an object:
1 2 3 4 5 |
import copy object_matrix = copy.copy(bpy.context.object.matrix_world) vertex_0 = bpy.context.object.data.vertices[0].co vertex_0_global = object_matrix @ vertex_0 |