Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformation of geometry #1359

Open
Licini opened this issue May 24, 2024 · 4 comments
Open

Transformation of geometry #1359

Licini opened this issue May 24, 2024 · 4 comments

Comments

@Licini
Copy link
Contributor

Licini commented May 24, 2024

from compas.geometry import Box
from compas.geometry import Scale

box = Box.from_width_height_depth(1, 1, 1)
print(box)

box.transform(Scale.from_factors([2, 2, 2]))
print(box)

box.scale(2)
print(box)

from compas.geometry import Sphere

sphere = Sphere(1)
print(sphere)

sphere.transform(Scale.from_factors([2, 2, 2]))
print(sphere)

sphere.scale(2)
print(sphere)
Box(xsize=1.0, ysize=1.0, zsize=1.0, frame=Frame(point=Point(x=0.0, y=0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=0.0), yaxis=Vector(x=0.0, y=1.0, z=0.0)))
Box(xsize=1.0, ysize=1.0, zsize=1.0, frame=Frame(point=Point(x=0.0, y=0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=0.0), yaxis=Vector(x=0.0, y=1.0, z=0.0)))
Box(xsize=2.0, ysize=2.0, zsize=2.0, frame=Frame(point=Point(x=0.0, y=0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=0.0), yaxis=Vector(x=0.0, y=1.0, z=0.0)))
Sphere(radius=1.0, frame=Frame(point=Point(x=0.0, y=0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=0.0), yaxis=Vector(x=0.0, y=1.0, z=0.0)))
Sphere(radius=1.0, frame=Frame(point=Point(x=0.0, y=0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=0.0), yaxis=Vector(x=0.0, y=1.0, z=0.0)))
Sphere(radius=2.0, frame=Frame(point=Point(x=0.0, y=0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=0.0), yaxis=Vector(x=0.0, y=1.0, z=0.0)))

We need to be careful about this... I understand this is tricky because of non-uniform scale, maybe there should a some kind of warning saying the Scale transform might not work as expected

@gonzalocasas
Copy link
Member

It's kind of broken now, right? scale vs scaled do different things also

@tomvanmele
Copy link
Member

yes, scaled, translated, rotated don't use the corresponding in-place version but rather a modified version of transformed.

i can fix this...

@tomvanmele
Copy link
Member

i can also bring back the scale part of the regular transform. it was thrown out because of the expensive decomposition of the transformation matrix to get the scale components and avoid non-uniform scaling, but i can try to do that differently...

@tomvanmele
Copy link
Member

#1360

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants