Skip to content

Transformation of geometry #1359

Open
Open

Description

@Licini
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

Activity

  1. gonzalocasas commented on May 24, 2024

    @gonzalocasas
    Member

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

  2. tomvanmele commented on May 24, 2024

    @tomvanmele
    Member

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

    i can fix this...

  3. tomvanmele commented on May 24, 2024

    @tomvanmele
    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...

  4. tomvanmele commented on May 26, 2024

    @tomvanmele
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions