Skip to content

[css-transforms] Coordinate inversion for 3D matrix decomposition #3711

@kevers-google

Description

@kevers-google

Link to spec: https://drafts.csswg.org/css-transforms-2/#decomposing-a-3d-matrix

In cases where the determinant is negative, the spec proposes inverting all scales and matrix elements. Though this leads to a valid decomposition it means than any 3D decomposition of a 2D transformation matrix with a scale inversion results in a decomposition that cannot be expressed as a sequence of 2D transform operations.

Consider the 3D decomposition of matrix(-1, 0, 0, 1, 0, 0).

This is equivalent to scaleX(-1); however, following the recipe, the 3D decomposition is equivalent to scale3d(1, -1, -1) rotateX(180deg).

3D decomposition of a 2D transformation matrix should yield comparable results to the 2D algorithm outlined here: https://drafts.csswg.org/css-transforms/#decomposing-a-2d-matrix. This can largely be addressed by using a similar strategy to the 2D case and only invert 1 scale when the determinant is negative. The 2D spec proposes flipping the axis with the minimum unit vector dot product. This approach should work for the 3D case as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions