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

Rotation of child components is handled incorrectly by layout engine #813

Open
WojciechBarczynski opened this issue Oct 9, 2024 · 2 comments

Comments

@WojciechBarczynski
Copy link
Member

top and left calculations of child components should consider the parent component's rotation.

This is the WGSL handling of the similar case I wrote, that might be helpful during implementation:

    let rotated_position = vec2<f32>(
        cos(radians(rotation)) * position.x - sin(radians(rotation)) * position.y,
        sin(radians(rotation)) * position.x + cos(radians(rotation)) * position.y
    );
@wkozyra95
Copy link
Member

This is a known issue, it's more complicated than this because you can have a series of nested components that are each rotated,

@WojciechBarczynski
Copy link
Member Author

I just noticed that it's a little bit more complex since the formula above is only true for rotation around the origin of the coordinate system.

In reality, we need to multiply the position by additional translation matrices to determine the final position.

If C is a point describing the middle of the layout, we need to do:
TranlationMat(C.x, C.y) * RotationMat(R) * Translation(-C.x, -C.y) * PointCoordsVec

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

2 participants