java.lang.Object
org.bonej.ops.ellipsoid.QuickEllipsoid
Represents an ellipsoid defined by its centroid, eigenvalues and 3x3 eigenvector matrix. Semiaxis lengths (radii) are calculated as the inverse square root of the eigenvalues.
- Author:
- Michael Doube, Alessandro Felder
-
Constructor Summary
ConstructorsConstructorDescriptionQuickEllipsoid(double[] radii, double[] centroid, double[][] eigenVectors) Construct an QuickEllipsoid from the radii (a,b,c), centroid (cx, cy, cz) and Eigenvectors. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(double x, double y, double z) Method based on the inequality (X-X0)^T H (X-X0) ≤ 1 Where X is the test point, X0 is the centroid, H is the ellipsoid's 3x3 matrixvoidcontract(double increment) Constrict all three axes by a fractional incrementcopy()Perform a deep copy of this QuickEllipsoidvoiddilate(double da, double db, double dc) Dilate the ellipsoid semiaxes by independent absolute amountsdouble[][]double[]double[][]Gets an up to date ellipsoid tensor (H)double[]getRadii()Gets a copy of the radii.double[][]Return a copy of the ellipsoid's eigenvector matrixdouble[]Get the radii sorted in ascending order.double[][]getSurfacePoints(double[][] vectors) doubleGets the volume of this ellipsoid, calculated as PI * a * b * c * 4 / 3voidrotate(double[][] rotation) Rotate the ellipsoid by the given 3x3 MatrixvoidsetCentroid(double x, double y, double z) Translate the ellipsoid to a given new centroidvoidsetRotation(double[][] rotation) Set rotation to the supplied rotation matrix.static double[][]transpose(double[][] a) Transpose a 3x3 matrix in double[][] format.
-
Constructor Details
-
QuickEllipsoid
public QuickEllipsoid(double[] radii, double[] centroid, double[][] eigenVectors) Construct an QuickEllipsoid from the radii (a,b,c), centroid (cx, cy, cz) and Eigenvectors.- Parameters:
radii- radii (a,b,c) as a double arraycentroid- ellipsoid centre x,y,z coordinates as a double arrayeigenVectors- the orientation of the ellipsoid.
-
-
Method Details
-
transpose
public static double[][] transpose(double[][] a) Transpose a 3x3 matrix in double[][] format. Does no error checking.- Parameters:
a- a matrix.- Returns:
- new transposed matrix.
-
contains
public boolean contains(double x, double y, double z) Method based on the inequality (X-X0)^T H (X-X0) ≤ 1 Where X is the test point, X0 is the centroid, H is the ellipsoid's 3x3 matrix- Parameters:
x- x-coordinate of the point.y- y-coordinate of the point.z- z-coordinate of the point.- Returns:
- true if the point (x,y,z) lies inside or on the ellipsoid, false otherwise
-
getEllipsoidTensor
public double[][] getEllipsoidTensor()Gets an up to date ellipsoid tensor (H)- Returns:
- 3×3 matrix containing H, the ellipsoid tensor
-
contract
public void contract(double increment) Constrict all three axes by a fractional increment- Parameters:
increment- scaling factor.
-
copy
Perform a deep copy of this QuickEllipsoid- Returns:
- a copy of the instance.
-
dilate
Dilate the ellipsoid semiaxes by independent absolute amounts- Parameters:
da- value added to the 1st radius.db- value added to the 2nd radius.dc- value added to the 3rd radius.- Throws:
IllegalArgumentException- if new semi-axes are non-positive.
-
getCentre
public double[] getCentre() -
getRadii
public double[] getRadii()Gets a copy of the radii.- Returns:
- the semiaxis lengths a, b and c. Note these are not ordered by size, but the order does relate to the 0th, 1st and 2nd columns of the rotation matrix respectively.
-
getRotation
public double[][] getRotation()Return a copy of the ellipsoid's eigenvector matrix- Returns:
- a 3x3 rotation matrix
-
setRotation
public void setRotation(double[][] rotation) Set rotation to the supplied rotation matrix. Does no error checking.- Parameters:
rotation- a 3x3 rotation matrix
-
getSortedRadii
public double[] getSortedRadii()Get the radii sorted in ascending order. Note that there is no guarantee that this ordering relates at all to the eigenvectors or eigenvalues.- Returns:
- radii in ascending order
-
getSurfacePoints
public double[][] getSurfacePoints(double[][] vectors) -
getAxisAlignRandomlyDistributedSurfacePoints
public double[][] getAxisAlignRandomlyDistributedSurfacePoints(int n) -
getVolume
public double getVolume()Gets the volume of this ellipsoid, calculated as PI * a * b * c * 4 / 3- Returns:
- copy of the stored volume value.
-
rotate
public void rotate(double[][] rotation) Rotate the ellipsoid by the given 3x3 Matrix- Parameters:
rotation- a 3x3 rotation matrix
-
setCentroid
public void setCentroid(double x, double y, double z) Translate the ellipsoid to a given new centroid- Parameters:
x- new centroid x-coordinatey- new centroid y-coordinatez- new centroid z-coordinate
-