Skip to content

Commit 4bb9d7b

Browse files
UPDATE: cvt_ndarray_2_rh_transform() added to cvt_bindings
1 parent 63abe47 commit 4bb9d7b

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/gh/diffCheck/diffCheck/df_cvt_bindings.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,32 @@ def cvt_dfOBB_2_rhbrep(df_OBB) -> rg.Box:
218218
if not rh_obb_brep.IsSolid:
219219
raise ValueError("The OBB Rhino Brep is not solid")
220220

221-
return rh_obb_brep
221+
return rh_obb_brep
222+
223+
def cvt_ndarray_2_rh_transform(matrix) -> rg.Transform:
224+
"""
225+
Convert a numpy matrix to a Rhino transformation.
226+
Useful to transform a DFTransformation-transformation_matrix to a Rhino transformation.
227+
228+
:param matrix: the numpy matrix
229+
230+
:return transfo: the Rhino transformation
231+
"""
232+
transfo = rg.Transform()
233+
transfo.M00 = matrix[0, 0]
234+
transfo.M01 = matrix[0, 1]
235+
transfo.M02 = matrix[0, 2]
236+
transfo.M03 = matrix[0, 3]
237+
transfo.M10 = matrix[1, 0]
238+
transfo.M11 = matrix[1, 1]
239+
transfo.M12 = matrix[1, 2]
240+
transfo.M13 = matrix[1, 3]
241+
transfo.M20 = matrix[2, 0]
242+
transfo.M21 = matrix[2, 1]
243+
transfo.M22 = matrix[2, 2]
244+
transfo.M23 = matrix[2, 3]
245+
transfo.M30 = matrix[3, 0]
246+
transfo.M31 = matrix[3, 1]
247+
transfo.M32 = matrix[3, 2]
248+
transfo.M33 = matrix[3, 3]
249+
return transfo

0 commit comments

Comments
 (0)