Skip to content

Unexpected behavior from chaining Transform2D #34329

Closed
@bluenote10

Description

@bluenote10

Godot version: 3.1.2.stable

OS/device including version: Ubuntu 18.04

Issue description:

Chaining Transform2D calls does not behave as one would expect (both from reading the docs and general affine geometry perspective). The documentation says for:

  • translated: Translates the transform by the given offset.
  • scaled: Scales the transform by the given factor.
  • rotated: Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors.

Thus, one would expect that the order of translated/scaled/rotated calls matters, which doesn't seem to be the case.

Steps to reproduce:

The following two calls:

print(Transform2D().scaled(Vector2(2, 2)).translated(Vector2(10, 0)))
print(Transform2D().translated(Vector2(10, 0)).scaled(Vector2(2, 2)))

both result in

((2, 0), (0, 2), (20, 0))
((2, 0), (0, 2), (20, 0))

but my expectation would have been to see the same difference as here:

image

Not sure if this is expected behavior (in 3D chaining transforms like that seems to work, so I was assuming the same code is valid in 2D as well).

If it is intended behavior, it would be nice to document that translated/scaled/rotated only set the corresponding parts of the transformation matrix and don't perform matrix multiplication, i.e., cannot be chained.

Minimal reproduction project: Needed?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions