We should modify/extend the geometry.random_points_on_sphere function to allow for sampling of points on spheroids. This would be useful for generating of molecular complexes while avoiding overlap of atoms.
One way of doing this would be to do a principle-component analysis (PCA) on the coordinates of the molecule with which we can transform points on a unit sphere to points on the spheroid.
Step-by-step algorithm:
Given a molecule with a random orientation and random translation from its centroid:
1) We first calculate the centered set of coordinates
$$X_C = X - C$$
where $X \in \mathbb{R}^{N \times 3}$ is the set of atomic coordinates for this molecule and $$Ci = \sum {k=1,..,N}^N X_{ki}, \quad i \in {x, y, z}$$
is the centroid of the molecule.
2) With the centered coordinates of the molecule we can do a singular-value decomposition. This decomposes the set of coordinates into two matrices $U \in \mathbb{R}^{N \times 3}$ and $V_h \in \mathbb{R}^{3 \times 3}$ and one vector $s \in \mathbb{R}^3$ such that $X_C = U \text{diag}(s) V_h$. The vectors in $V_h$ are orthonormal and scaling them with $\frac{1}{2}s$ (because the spheroid has a negative and positive side) will give a set of coordinate which can be used to generate the minimum-volume spheroid for this molecule.
In this picture the vectors $\text{diag}(\frac{1}{2}s) V_h$ are shown as the silver bonds.
3) We use the principle component vectors $V_h$ and principle component values $s$ to generate a transformation matrix to transform a centered unit sphere into a translated minimum-volume spheroid. To generate the transformation matrix $T$ we use the following expression:
$$X' = \text{diag}(\frac{1}{2}s) V_h X_C + C$$
4) To finally sample the spheroid we first generate samples on a sphere and transform them to the spheroid.
In this figure the original spherical samples are shown on the right and the transformed samples on the left.
5) We can add spacing between the molecule and the samples by simply adding an extra term to $s$. For example, a margin of 3 angstrom:
We should modify/extend the geometry.random_points_on_sphere function to allow for sampling of points on spheroids. This would be useful for generating of molecular complexes while avoiding overlap of atoms.
One way of doing this would be to do a principle-component analysis (PCA) on the coordinates of the molecule with which we can transform points on a unit sphere to points on the spheroid.
Step-by-step algorithm:
Given a molecule with a random orientation and random translation from its centroid:
1) We first calculate the centered set of coordinates $$X_C = X - C$$ where $X \in \mathbb{R}^{N \times 3}$ is the set of atomic coordinates for this molecule and $$Ci = \sum {k=1,..,N}^N X_{ki}, \quad i \in {x, y, z}$$ is the centroid of the molecule.
2) With the centered coordinates of the molecule we can do a singular-value decomposition. This decomposes the set of coordinates into two matrices $U \in \mathbb{R}^{N \times 3}$ and $V_h \in \mathbb{R}^{3 \times 3}$ and one vector $s \in \mathbb{R}^3$ such that $X_C = U \text{diag}(s) V_h$. The vectors in $V_h$ are orthonormal and scaling them with $\frac{1}{2}s$ (because the spheroid has a negative and positive side) will give a set of coordinate which can be used to generate the minimum-volume spheroid for this molecule.
In this picture the vectors $\text{diag}(\frac{1}{2}s) V_h$ are shown as the silver bonds.
3) We use the principle component vectors $V_h$ and principle component values $s$ to generate a transformation matrix to transform a centered unit sphere into a translated minimum-volume spheroid. To generate the transformation matrix $T$ we use the following expression: $$X' = \text{diag}(\frac{1}{2}s) V_h X_C + C$$
4) To finally sample the spheroid we first generate samples on a sphere and transform them to the spheroid.
In this figure the original spherical samples are shown on the right and the transformed samples on the left.
5) We can add spacing between the molecule and the samples by simply adding an extra term to $s$. For example, a margin of 3 angstrom: