Skip to content

Commit

Permalink
update scaled, translated, rotated
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed May 26, 2024
1 parent e4b0938 commit cf4a609
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 9 additions & 18 deletions src/compas/geometry/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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

0 comments on commit cf4a609

Please sign in to comment.