# How to calculate the major and minor axes of a bubble based on 3D tilted bubble interface vtk data

**URL:** https://discourse.paraview.org/t/how-to-calculate-the-major-and-minor-axes-of-a-bubble-based-on-3d-tilted-bubble-interface-vtk-data/11487
**Category:** ParaView Support
**Tags:** vtk
**Created:** [February 24, 2023, 1:58pm UTC](https://discourse.paraview.org/t/how-to-calculate-the-major-and-minor-axes-of-a-bubble-based-on-3d-tilted-bubble-interface-vtk-data/11487 "2023-02-24T13:58:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![MontelukastNa](https://discourse.paraview.org/user_avatar/discourse.paraview.org/montelukastna/32/10664_2.png) [@MontelukastNa](https://discourse.paraview.org/u/MontelukastNa)
#### Post date: [February 24, 2023, 1:58pm UTC](https://discourse.paraview.org/t/how-to-calculate-the-major-and-minor-axes-of-a-bubble-based-on-3d-tilted-bubble-interface-vtk-data/11487/1 "2023-02-24T13:58:14Z")

</div>

Dear all,

> 🏁 **How to calculate the major and minor axes of a bubble based on 3D inclined bubble interface vtk data?**

I sample some vtk bubble interface data from OpenFOAM, at the same time, I also saved the 6 extreme points of the bubble interface in the XYZ direction(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax), the coordinate data of these points are used to calculate the major axis and minor axis of the bubble. In addition, mass center (Xc, Yc, Zc) is also recorded

 ![image](https://discourse.paraview.org/uploads/default/original/2X/2/2ae057932f16ffcb6ce424385beec31f926b649b.jpeg)

The (Xmin, Ymin, Zmin, Xmax, Ymax, Zmax) of this bubble is known,  
ΔX=Xmax-Xmin & ΔY=Ymax-Ymin & ΔZ=Zmax-Zmin;

**So, the major axis equals to ΔY or ΔX, the minor axis equals to ΔZ;**

This approach works well when the bubbles are not incline, **but** ,As the size of the bubble increases, it will incline and the method of directly evaluating the major and minor axes of the bubble using the coordinates of the 6 extreme points fails.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/d/d0ebdf7d442ccf6092a311e54d39c0e2e7dca9e3.jpeg)

For inclined bubbles, now I have vtk files for each moment of the bubble, but the calculated major axis and minor axis are all wrong (because the calculation scheme of the major axis and minor axis of the non-inclined bubble is adopted). In addition, I also have the centroid coordinates at each moment. Most papers indicate that the short axis can be aligned with the velocity direction. I wonder if I can extract the minor axis from this scheme?

But how can this be done from various vtk files in paraview?

For example, how to establish the vector formed by the centroid coordinates of adjacent time steps in paraview and find the coordinates of the two intersections with the vtk interface. In addition, consider that this work needs to be performed in batches, because the long and short axes of multiple vtk files need to be calculated (I guess at present whether we need to cooperate with python script to achieve the purpose)

At one moment, I wanted to measure manually, but suddenly I thought, I am a follower of Paraview, how can I do such a thing.

guys, give me a hands!

> 🚩If it is really impossible to calculate ratio with vtk, we will finally go back to OpenFOAM to improve the solver to output the correct major and minor axes of the inclined bubble. If you have experience, or if you have suggestions on algorithm, can you tell us more? thx

Best regards!  
Na

---

<div class="post-metadata">

### Author: ![Kenichiro-Yoshimi](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Kenichiro-Yoshimi](https://discourse.paraview.org/u/Kenichiro-Yoshimi)
#### Post date: [February 25, 2023, 4:39am UTC](https://discourse.paraview.org/t/how-to-calculate-the-major-and-minor-axes-of-a-bubble-based-on-3d-tilted-bubble-interface-vtk-data/11487/2 "2023-02-25T04:39:46Z")

</div>

One idea is to calculate the `Gaussian_Curvature` or `Mean_Curvature` for the surface of each bubble (Polygonal Mesh) with the **Curvature Filter** and extract its maximum and minimum points using the `Find Data` tool.  
This approach may be useful if the bubble is always a smooth convex shape.

---

<div class="post-metadata">

### Author: ![MontelukastNa](https://discourse.paraview.org/user_avatar/discourse.paraview.org/montelukastna/32/10664_2.png) [@MontelukastNa](https://discourse.paraview.org/u/MontelukastNa)
#### Post date: [March 1, 2023, 3:34am UTC](https://discourse.paraview.org/t/how-to-calculate-the-major-and-minor-axes-of-a-bubble-based-on-3d-tilted-bubble-interface-vtk-data/11487/3 "2023-03-01T03:34:09Z")

</div>

Hello, [Kenichiro-Yoshimi](https://discourse.paraview.org/u/Kenichiro-Yoshimi),  
Thanks for your kind reply.  
Calculate the `Gaussian_Curvature` or `Mean_Curvature` for the surface, then check the major and minor axes. You are right, it’s a good way to find it.

When the bubble is not inclined, the extreme point of curvature is really on the minor axis, which confirms the idea.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/9/9afc46f4a312aa6dbd0986341294c7280b33efa8.jpeg)

> \*\*But,\*\*the extreme points extracted by **Mean\_ Curvature Filter** are not distributed on the major or minor axes directly

When the bubble is inclined, how do the coordinates of these two extreme points reflect the Major and minor axes? Can you tell me more about your experience in handling this situation.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/3/39eddfcff25e08c7555afaf1fac9fb2e15c7184c.jpeg)

Best regards!  
Na

---

<div class="post-metadata">

### Author: ![Kenichiro-Yoshimi](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Kenichiro-Yoshimi](https://discourse.paraview.org/u/Kenichiro-Yoshimi)
#### Post date: [March 1, 2023, 11:52pm UTC](https://discourse.paraview.org/t/how-to-calculate-the-major-and-minor-axes-of-a-bubble-based-on-3d-tilted-bubble-interface-vtk-data/11487/4 "2023-03-01T23:52:20Z")

</div>

The method using curvature does not seem to work well. My apologies.

If the tilted bubbles are elliptical-like in shape, then finding the major and minor axes as eigenvectors of the moment of inertia tensor is a commonly used method. However, since bubbles vary in shape, this method may not work either.

Please refer to the State file below for specific instructions on how to do this.

[ellipsoid\_axes.pvsm](https://discourse.paraview.org/uploads/short-url/mVGRGXLDdqnIyxryfgKaSHxCgVO.pvsm) (436.5 KB)

 ![ellipsoid_axes](https://discourse.paraview.org/uploads/default/original/2X/c/ccff81432aecb1d3247f541cfddef2e8bbbc8136.png)
