From cf4a609bd10bd678a28adc3f1b263854208a4e9f Mon Sep 17 00:00:00 2001 From: tomvanmele Date: Sun, 26 May 2024 09:31:46 +0200 Subject: [PATCH] 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