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

Documentation doesn't explain well the model matrix things #2637

Open
Zou-Bo opened this issue Jan 29, 2023 · 4 comments
Open

Documentation doesn't explain well the model matrix things #2637

Zou-Bo opened this issue Jan 29, 2023 · 4 comments
Labels
documentation Makie Backend independent issues (Makie core) maybe wontfix TODO: review transformation related to `Transformation` objects

Comments

@Zou-Bo
Copy link

Zou-Bo commented Jan 29, 2023

Many plotting functions(e.g. heatmap) have this attribute:
"model::Makie.Mat4f sets a model matrix for the plot. This replaces adjustments made with translate! , rotate! and scale! ."
I don't understand this description and cannot find any explanations in detail or any examples about how to use this attribute.

@ffreyer ffreyer added maybe wontfix TODO: review Makie Backend independent issues (Makie core) transformation related to `Transformation` objects labels Aug 24, 2024
@ffreyer
Copy link
Collaborator

ffreyer commented Aug 24, 2024

I would personally prefer if we pushed against using model as an attribute since working with a translation-rotation-scale matrix makes some things a lot easier internally than a completely general Mat4f. So maybe instead of documenting model better we should document translate!, rotate! & scale! better and push plot.model into a footnote.

@bjarthur
Copy link
Contributor

bjarthur commented Oct 9, 2024

+1 for better documentation for rotate!. specifically, if i render a Toggle in the middle of a figure, how do i rotate it about it's center? see #4445 (comment) for a failed attempt of mine.

@EdsterG
Copy link
Contributor

EdsterG commented Oct 10, 2024

Another +1 for better documentation (and maybe even an updated implementation). Following up on #4445, I too can't figure out what the origin is for those toggles. I looked at all of the parent models and they are all identity matrices implying that the toggle should be drawn at the origin (0, 0), but it obviously isn't. So what transform is translating it to the middle of the screen?

t2.blockscene.transformation.model[]
t2.blockscene.parent.transformation.model[]
t2.blockscene.transformation.parent_model[]
t2.blockscene.transformation.parent[].model[]
t2.blockscene.transformation.parent[].parent_model[]
t2.parent.scene.transformation.model[]

I would expect at least one of the above matrices to contain the translation. Am I missing one?

As a suggestion to the translate/roatate API's, it would be helpful to have the following:

  1. document the reference point
  2. allow users to specify the reference point (see Unity API for example Rotate/Translate, both have a relativeTo parameter which defaults to self)

@ffreyer
Copy link
Collaborator

ffreyer commented Oct 10, 2024

Transformations affect plots, not scenes. At least not directly. Effectively Makie ends up calculating

plot.model * apply_transform(plot.transformation.transform_func, plot.converted)

where things default as

t = plot.transformation
plot.model = t.model = t.parent.model * transformationmatrix(t.translation, t.scale, t.rotation)
t.transform_func = t.parent.transform_func

So if you translate/rotate/scale a scene and a plot in that scene those transformation will accumulate.

The origin of rotation etc is 0 in your plot input data (well technically after transform_func). For Toggle you're rendering to a pixel space scene (blockscene) with no transform_func. The plots that make up the toggle (poly, scatter) are therefore also in pixel space. (0, 0, 0) is at the bottom left of the window (or more specifically the blockscene, which is the same size as the window).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Makie Backend independent issues (Makie core) maybe wontfix TODO: review transformation related to `Transformation` objects
Projects
Status: No status
Development

No branches or pull requests

5 participants