Class QuickEllipsoid

java.lang.Object
org.bonej.ops.ellipsoid.QuickEllipsoid

public class QuickEllipsoid extends Object

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

    Constructors
    Constructor
    Description
    QuickEllipsoid(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 Type
    Method
    Description
    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
    void
    contract(double increment)
    Constrict all three axes by a fractional increment
    Perform a deep copy of this QuickEllipsoid
    void
    dilate(double da, double db, double dc)
    Dilate the ellipsoid semiaxes by independent absolute amounts
    double[][]
     
    double[]
     
    double[][]
    Gets an up to date ellipsoid tensor (H)
    double[]
    Gets a copy of the radii.
    double[][]
    Return a copy of the ellipsoid's eigenvector matrix
    double[]
    Get the radii sorted in ascending order.
    double[][]
    getSurfacePoints(double[][] vectors)
     
    double
    Gets the volume of this ellipsoid, calculated as PI * a * b * c * 4 / 3
    void
    rotate(double[][] rotation)
    Rotate the ellipsoid by the given 3x3 Matrix
    void
    setCentroid(double x, double y, double z)
    Translate the ellipsoid to a given new centroid
    void
    setRotation(double[][] rotation)
    Set rotation to the supplied rotation matrix.
    static double[][]
    transpose(double[][] a)
    Transpose a 3x3 matrix in double[][] format.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 array
      centroid - ellipsoid centre x,y,z coordinates as a double array
      eigenVectors - 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

      public QuickEllipsoid copy()
      Perform a deep copy of this QuickEllipsoid
      Returns:
      a copy of the instance.
    • dilate

      public void dilate(double da, double db, double dc) throws IllegalArgumentException
      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-coordinate
      y - new centroid y-coordinate
      z - new centroid z-coordinate