How to check a point inside in a ellipsoid in lammps?

Hi LAMMPS-users,

The lammps describes a ellipsoid in gayberne potential by the position (xc,yc,zc) and the quaternion (wi,xi,yi,zi). I am confused about that how a ellipsoid body in lammps is obtained. My understanding is that a ellipsoid is obtanied by rotating the ellipsoid (x-xc)^2/a^2+(y-yc)^2/b^2+(z-zc)^2/c^2 = 1 by quaternion (wi,xi,yi,zi).
So if I want to check a point (x0,y0,z0) inside in an ellipsoid, I just do a back rotation to the point, and check the (x0-xc)^2/a^2+(y0-yc)^2/b^2+(z0-zc)^2/c^2 < 1.
Is the above statement correct? Thank you for any suggestions.

I am not sure what you are asking, but this is my understanding of how to handle ellipsoid’s rotations.
In the ellipsoid’s frame of reference, the quaternion q=(1,0,0,0) corresponds to a null rotation, that is, the Cartesian axes coincide with the ellipsoid’s three axes of rotation.

If you define a point \mathbf{p}_0=(x_0,y_0,z_0) in the ellipsoid’s frame of reference and you want to track it in space, you have to do the following operations. We assume that the ellipsoid has a quaternion \mathbf{q}_e=(w_e,i_e,j_e,k_e) and a position \mathbf{p}_e=(x_e,y_e,z_e).

  1. Compute a rotation matrix \mathbf{R}_{e} from the quaternion \mathbf{q}_e (the formula is on Wikipedia if you wonder).
  2. Rotate the point: \mathbf{p}_1=\mathbf{R}_{e} \mathbf{p}_0.
  3. Translate the rotated point to the ellipsoid’s position: \mathbf{p}_2=\mathbf{p}_1+\mathbf{p}_e.

Here you go!

1 Like