Skip to content

Commit

Permalink
fix decompose when scaling is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
panxinmiao committed Dec 19, 2024
1 parent fd3bb73 commit 5e54fd0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pylinalg/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,11 @@ def mat_decompose(matrix, /, *, scaling_signs=None, dtype=None, out=None):
scaling *= scaling_signs

rotation = out[1] if out is not None else None
rotation_matrix = matrix[:-1, :-1] * (1 / scaling)[None, :]

rotation_matrix = matrix[:-1, :-1].copy()
mask = scaling != 0
rotation_matrix[:, mask] /= scaling[mask][None, :]
rotation_matrix[:, ~mask] = 0.0
rotation = quat_from_mat(rotation_matrix, out=rotation, dtype=dtype)

return translation, rotation, scaling
Expand Down

0 comments on commit 5e54fd0

Please sign in to comment.