Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `compas_rhino.uninstall` will try to remove compas packages from all possible install locations.
* Changed `angle_vectors_projected` to raise `ValueError` when an input vector is parallel to projection normal.
* Changed `angle_vectors` to raise `ValueError` when one of the input vectors is a zero-length vector instead of returning 0.
* Changed `transformation_to_rhino` and `transformation_matrix_to_rhino` to assign the matrix components directly to the fields of `Rhino.Geometry.Transform` instead of looping over its indexer. About 11x faster per conversion, noticable when used inside an animation loop.

### Removed

Expand Down
16 changes: 7 additions & 9 deletions src/compas_rhino/conversions/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ def transformation_to_rhino(transformation):
:rhino:`Rhino.Geometry.Transform`

"""
transform = Rhino.Geometry.Transform(1.0)
for i in range(0, 4):
for j in range(0, 4):
transform[i, j] = transformation[i, j]
return transform
return transformation_matrix_to_rhino(transformation.matrix)


def transformation_matrix_to_rhino(matrix):
Expand All @@ -38,8 +34,10 @@ def transformation_matrix_to_rhino(matrix):
:rhino:`Rhino.Geometry.Transform`

"""
transform = Rhino.Geometry.Transform(1.0)
for i in range(0, 4):
for j in range(0, 4):
transform[i, j] = matrix[i][j]
row_0, row_1, row_2, row_3 = matrix
transform = Rhino.Geometry.Transform.Identity
transform.M00, transform.M01, transform.M02, transform.M03 = row_0
transform.M10, transform.M11, transform.M12, transform.M13 = row_1
transform.M20, transform.M21, transform.M22, transform.M23 = row_2
transform.M30, transform.M31, transform.M32, transform.M33 = row_3
return transform
Loading