visit-dav / visit

VisIt - Visualization and Data Analysis for Mesh-based Scientific Data
https://visit.llnl.gov
BSD 3-Clause "New" or "Revised" License
446 stars 117 forks source link

rotate, scale and translate in a single transform operator instance #17923

Open markcmiller86 opened 2 years ago

markcmiller86 commented 2 years ago

Is your feature request related to a problem?

We have a Transform operator that supports rotation, scaling and translation. However, docs indicate the order is pre-defined as rotate, scale, translate.

I wanted to scale and then rotate globe.silo. I needed to add two transform operators to make that happen. Trying to use one operator had no effect (as you can imagine because rotating spherically symmetric data is indistinguishable :wink:)

Is there a way we could add the ability to specify order in the Transform operator. Two ideas...

JustinPrivitera commented 2 years ago

It's been a little while since I took graphics in school, and I don't know a whole lot about our transform operator, but I thought that the order needed to always be scale, rotate, translate. You should be able to get every configuration with that order. I am surprised to hear that we do rotations first; is there a reason for that? I thought scaling needed to come first because scaling is typically done in the x, y, and z directions, and doing a rotation first will change what you are scaling.

So I guess I'm confused. Why do we do rotation first? If we did our operations in the order scale, rotate, translate, then wouldn't that solve your issue, and any further issues with transformations?

markcmiller86 commented 2 years ago

So I guess I'm confused. Why do we do rotation first?

If you are speaking within the context of a graphics library and the operations required to set a view, then yes, I think you are correct about the ordering needed for that specific case.

VisIt's Transform operator is less about setting a view and more about setting one object (variable) relative either to the current view (coordinates) or to other objects. In that case, the specific operations and their orderings are completely arbitrary. For example to rotate one object in a scene 90 degrees but have it otherwise remain in the same position relative to other objects in the scene, the transformation applied to it would be the catenation of a translation to origin, rotation and translation back to its original position (all in one matrix).

JustinPrivitera commented 2 years ago

If you are speaking within the context of a graphics library and the operations required to set a view

I wasn't talking about setting a view, but about setting the positions, sizes, and orientations of geometry in your scene. Is that the same thing?

In that case, the specific operations and their orderings are completely arbitrary.

How are they arbitrary? I don't understand. Following your example, let's say S = scaling matrix R = rotation matrix T0 = translation to origin matrix T = translation to object position matrix M = final model transformation matrix

In your example, M = T R T0 Since the model is translated to the origin, rotated 90 degrees, and translated back.

If I've understood what you've told me, you and the docs are saying that in general, M = T S R * T0

If that is the case, then what I'm trying to propose is that we switch the ordering, so that M = T R S * T0

This way, you don't need to run two distinct transformation operations to accomplish what you were trying to do in your original post, as rotation is "applied" after scaling. It also means we don't need to add functionality for users to choose what order their transformations are applied. I can't imagine too many situations where users would want to scale after rotating.

Am I understanding this correctly? Hopefully all will be cleared up in our meeting tomorrow.

brugger1 commented 2 years ago

Some thoughts/action items.

JustinPrivitera commented 2 years ago

https://docs.blender.org/manual/en/latest/_images/scene-layout_object_properties_transforms_panel.png