From 687b57183b6a4386eb81a1b37e9176c83c29cd75 Mon Sep 17 00:00:00 2001 From: tomvanmele Date: Sun, 26 May 2024 09:28:45 +0200 Subject: [PATCH 1/3] this file is not needed --- src/compas/data/conftest.py | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 src/compas/data/conftest.py diff --git a/src/compas/data/conftest.py b/src/compas/data/conftest.py deleted file mode 100644 index 0c68f76482d..00000000000 --- a/src/compas/data/conftest.py +++ /dev/null @@ -1,10 +0,0 @@ -import pytest - -from .validators import is_sequence_of_list -from .validators import is_sequence_of_tuple - - -@pytest.fixture(autouse=True) -def add_is_sequence_of(doctest_namespace): - doctest_namespace["is_sequence_of_list"] = is_sequence_of_list - doctest_namespace["is_sequence_of_tuple"] = is_sequence_of_tuple From e4b0938f6a955462156c636abee52f27e079e9cf Mon Sep 17 00:00:00 2001 From: tomvanmele Date: Sun, 26 May 2024 09:29:07 +0200 Subject: [PATCH 2/3] tidy up --- src/compas/geometry/_core/_algebra.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/compas/geometry/_core/_algebra.py b/src/compas/geometry/_core/_algebra.py index 09bb398b275..b8ecfb5176e 100644 --- a/src/compas/geometry/_core/_algebra.py +++ b/src/compas/geometry/_core/_algebra.py @@ -1496,13 +1496,6 @@ def decompose_matrix(M): for j in range(4): Mt[i][j] /= Mt[3][3] - translation = [M[0][3], M[1][3], M[2][3]] - - # scale, shear, angles - scale = [0.0, 0.0, 0.0] - shear = [0.0, 0.0, 0.0] - angles = [0.0, 0.0, 0.0] - # copy Mt[:3, :3] into row row = [ [0, 0, 0], @@ -1513,6 +1506,14 @@ def decompose_matrix(M): for j in range(3): row[i][j] = Mt[i][j] + # translation + translation = [M[0][3], M[1][3], M[2][3]] + + # scale, shear, angles + scale = [0.0, 0.0, 0.0] + shear = [0.0, 0.0, 0.0] + angles = [0.0, 0.0, 0.0] + scale[0] = norm_vector(row[0]) for i in range(3): row[0][i] /= scale[0] # type: ignore From cf4a609bd10bd678a28adc3f1b263854208a4e9f Mon Sep 17 00:00:00 2001 From: tomvanmele Date: Sun, 26 May 2024 09:31:46 +0200 Subject: [PATCH 3/3] update scaled, translated, rotated --- CHANGELOG.md | 3 +++ src/compas/geometry/geometry.py | 27 +++++++++------------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4467a3f3b2..a036b42bad8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed * Fixed bug in `compas.geometry.ic_numpy`, which was caused by returning only the last transformation of the iteration process. +* Changed `compas.geometry.Geometry.scaled` to use `compas.geometry.Geometry.scale` on a copy. +* Changed `compas.geometry.Geometry.translated` to use `compas.geometry.Geometry.translate` on a copy. +* Changed `compas.geometry.Geometry.rotated` to use `compas.geometry.Geometry.rotate` on a copy. ### Removed diff --git a/src/compas/geometry/geometry.py b/src/compas/geometry/geometry.py index 3133c892261..4a16b2bbfbc 100644 --- a/src/compas/geometry/geometry.py +++ b/src/compas/geometry/geometry.py @@ -169,15 +169,9 @@ def scaled(self, x, y=None, z=None): # type: (...) -> G transformed """ - from compas.geometry import Scale - - if y is None: - y = x - - if z is None: - z = x - - return self.transformed(Scale.from_factors([x, y, z])) + geometry = self.copy() # type: Geometry + geometry.scale(x=x, y=y, z=z) + return geometry # type: ignore def translate(self, vector): """Translate the geometry. @@ -224,9 +218,9 @@ def translated(self, vector): # type: (...) -> G transformed """ - from compas.geometry import Translation - - return self.transformed(Translation.from_vector(vector)) + geometry = self.copy() # type: Geometry + geometry.translate(vector) + return geometry # type: ignore def rotate(self, angle, axis=None, point=None): """Rotate the geometry. @@ -288,9 +282,6 @@ def rotated(self, angle, axis=None, point=None): # type: (...) -> G transformed """ - from compas.geometry import Rotation - - if axis is None: - axis = [0.0, 0.0, 1.0] - - return self.transformed(Rotation.from_axis_and_angle(axis, angle, point)) + geometry = self.copy() # type: Geometry + geometry.rotate(angle=angle, axis=axis, point=point) + return geometry # type: ignore