/
transformations.py
46 lines (32 loc) · 1.16 KB
/
transformations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import mathutils # type: ignore
from compas.geometry import Transformation
# =============================================================================
# To Blender
# =============================================================================
def transformation_to_blender(transformation):
"""Convert a COMPAS transformation to a Blender transformation.
Parameters
----------
transformation : :class:`compas.geometry.Transformation`
A COMPAS transformation.
Returns
-------
:class:`mathutils.Matrix`
A Blender transformation.
"""
return mathutils.Matrix(transformation.matrix)
# =============================================================================
# To COMPAS
# =============================================================================
def transformation_to_compas(matrix):
"""Convert a Blender transformation to a COMPAS transformation.
Parameters
----------
matrix : :class:`mathutils.Matrix`
A Blender transformation.
Returns
-------
:class:`compas.geometry.Transformation`
A COMPAS transformation.
"""
return Transformation.from_matrix(matrix)