ttricco / sarracen

A Python library for smoothed particle hydrodynamics (SPH) analysis and visualization.
https://sarracen.readthedocs.io
GNU General Public License v3.0
16 stars 18 forks source link

Rotations for 3D interpolation & rendering functions #18

Closed AndrewHarris709 closed 2 years ago

AndrewHarris709 commented 2 years ago

Adds support to 3D interpolation & rendering functions for data rotation. This enables the user to render 3D data at any desired angle.

Example of a rotated plot: image

Note that because the data is rotated, the values of the x & y axes no longer have physical relevance to the data. Therefore, the ticks on these axes are removed when the data is rotated.

Rotations are performed as Euler extrinsic rotations, in the order z->y->x (similar to splash). This functionality is provided by the scipy.spatial.transform library.

As an example: passing rotation = [0, 45, 90] to a 3D interpolation function will first rotate the data 45 degrees about the y-axis, and 90 degrees about the x-axis.

ttricco commented 2 years ago

Disregard. Forgot to turn off physical units.

ttricco commented 2 years ago

I think we need to change the API slightly here to not include all three of x, y and z. We're mixing meanings and usage here.

x and y refer to the x and y axes of the plot, and then we're using them again + z to define the spatial directions. I think these two uses need to be separated. Right now you could redefine what x, y and z, and then your rotations are around those new axes. I think it opens up to some funky behaviour and misunderstanding (and misuse) on part of the user. Probably better to keep rotation an independent process.

My recommendation is to drop references to z. Keep x and y, which refer to the axes of the plot. And then the rotation uses the spatial dimensions already defined in the dataframe with xcol, ycol and zcol.

It makes sense to me right now to do it this way, but we should discuss so I can sound it off you. I expect writing some user docs for rotation will be a good thing.