Skip to content

Commit 589683c

Browse files
committed
xform: remove scale parameter
1 parent ccd56a6 commit 589683c

2 files changed

Lines changed: 5 additions & 29 deletions

File tree

metafold/utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,21 @@
77
def xform(
88
translation: Optional[ArrayLike] = None,
99
rotation: Optional[ArrayLike] = None,
10-
scale: Optional[ArrayLike] = None,
1110
) -> np.ndarray:
1211
"""Compose transformation matrix.
1312
1413
Args:
1514
translation: Translation in the x, y, and z directions.
1615
rotation: Euler angles in degrees. Rotation is applied in the order Rz, Ry, Rx.
17-
scale: Scale factor applied in the x, y, z directions before rotation.
1816
1917
Returns:
2018
4 x 4 affine transformation matrix.
2119
"""
2220
translation = translation or np.array([0.0, 0.0, 0.0])
2321
rotation = rotation or np.array([0.0, 0.0, 0.0])
24-
scale = scale or np.array([1.0, 1.0, 1.0])
2522

2623
r = R.from_euler("xyz", rotation, degrees=True).as_matrix()
2724
m = np.eye(4)
28-
m[:3, :3] = np.diag(scale) @ r
25+
m[:3, :3] = r
2926
m[3, :3] = translation
3027
return m

tests/test_utils.py

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,21 @@ def test_xform():
1212
], atol=1.0e-7)
1313

1414
m = xform(
15-
[1.0, 2.0, 3.0], # T
16-
[180.0, -90.0, 0.0]) # R
15+
rotation=[180.0, -90.0, 0.0]) # R
1716
assert_allclose(m, [
1817
[0.0, 0.0, 1.0, 0.0],
1918
[0.0, -1.0, 0.0, 0.0],
2019
[1.0, 0.0, 0.0, 0.0],
21-
[1.0, 2.0, 3.0, 1.0],
22-
], atol=1.0e-7)
23-
24-
m = xform(
25-
[1.0, 2.0, 3.0], # T
26-
scale=[2.0, 1.0, 1.0]) # S
27-
assert_allclose(m, [
28-
[2.0, 0.0, 0.0, 0.0],
29-
[0.0, 1.0, 0.0, 0.0],
30-
[0.0, 0.0, 1.0, 0.0],
31-
[1.0, 2.0, 3.0, 1.0],
32-
], atol=1.0e-7)
33-
34-
m = xform(
35-
rotation=[180.0, -90.0, 0.0], # R
36-
scale=[2.0, 1.0, 1.0]) # S
37-
assert_allclose(m, [
38-
[0.0, 0.0, 2.0, 0.0],
39-
[0.0, -1.0, 0.0, 0.0],
40-
[1.0, 0.0, 0.0, 0.0],
4120
[0.0, 0.0, 0.0, 1.0],
4221
], atol=1.0e-7)
4322

4423
m = xform(
4524
[1.0, 2.0, 3.0], # T
46-
[180.0, -90.0, 0.0], # R
47-
[2.0, 1.0, 1.0]) # S
25+
[180.0, -90.0, 0.0]) # R
4826
assert_allclose(m, [
49-
[0.0, 0.0, 2.0, 0.0],
27+
[0.0, 0.0, 1.0, 0.0],
5028
[0.0, -1.0, 0.0, 0.0],
5129
[1.0, 0.0, 0.0, 0.0],
5230
[1.0, 2.0, 3.0, 1.0],
5331
], atol=1.0e-7)
32+

0 commit comments

Comments
 (0)