Class Ellipse

All Implemented Interfaces:
EllipseTypeGeometry, Geometry, Surface, Serializable, Cloneable

public class Ellipse extends DefaultGeometry implements Surface, EllipseTypeGeometry
See Also:
  • Constructor Details

    • Ellipse

      public Ellipse(Point coord, Dimension semiAxes, float angle)
      Creates a new Ellipse using the specified parameters.
      Parameters:
      coord - the ellipse origin.
      semiAxes - the radius of the two axes.
      angle - the ellipse angle.
  • Method Details

    • clone

      public Ellipse clone()
      Clones this geometry.
      Specified by:
      clone in interface Geometry
      Specified by:
      clone in class DefaultGeometry
      Returns:
      a deep copy of the current geometry.
    • ellipseIterator

      public EllipseGeometryIterator ellipseIterator()
      Specified by:
      ellipseIterator in interface EllipseTypeGeometry
      Returns:
    • getGeometryId

      public short getGeometryId()
      Returns the geometry class id. This method is useful for geometry serialization.
      Specified by:
      getGeometryId in interface Geometry
      Returns:
      the geometry id.
    • getGeometryType

      public int getGeometryType()
      Returns the geometry type for this geometry.
      Specified by:
      getGeometryType in interface Geometry
      Returns:
      the geometry type.
      See Also:
    • boundary

      public Geometry boundary()
      Returns the boundary of this geometry as a line string.
      Specified by:
      boundary in interface Geometry
      Returns:
      a line string which defines the boundary of the current geometry.
    • createBounds

      public void createBounds()
      Description copied from interface: Geometry
      Updates the geometry bounds from the current geometry.
      Specified by:
      createBounds in interface Geometry
    • getBounds

      public Rectangle getBounds()
      Returns the minimum bounding rectangle of this geometry.
      Specified by:
      getBounds in interface Geometry
      Returns:
      the bounding box of this geometry.
    • getCenteredPoint

      public Point getCenteredPoint()
      This method returns a point that is typically centered on the geometry. If the geometry is a point, the point is returned. If it is a line, a point on the curve interpolated at 50% is returned. If the geometry is a surface, the centroid is returned if it is inside the polygon, if not, a point inside the polygon (but likely not exactly in the center) will be returned. If the geometry is a collection, the method is called on the first part of the collection.
      Specified by:
      getCenteredPoint in interface Geometry
      Returns:
      a point likely at the center of the geometry
    • serialize

      public Point[] serialize()
      Returns this geometry as an array of Point.
      Specified by:
      serialize in interface Geometry
      Returns:
      this geometry as an array of Point.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • spatiallyEquals

      public boolean spatiallyEquals(Geometry geometry, PrecisionModel precisionModel)
      Tests if this geometry is equal to the argument, on a topological point of view.
      Specified by:
      spatiallyEquals in interface Geometry
      Parameters:
      geometry - the geometry to be tested.
      precisionModel - the precision model to use while comparing geometries.
      Returns:
      whether both geometries are spatially equals.
    • transform

      public Geometry transform(Transformation tr)
      Creates a clone of the current geometry and returns the new instance transformed with the specified geometry transformation.
      The returned geometry can be of any geometry types after the transformation.
      Specified by:
      transform in interface Geometry
      Parameters:
      tr - the transformation to apply.
      Returns:
      the newly created and transformed geometry instance.
    • translate

      public void translate(double dx, double dy)
      Translate this geometry with the specified values.
      Specified by:
      translate in interface Geometry
      Parameters:
      dx - translation on the X-axis.
      dy - translation on the Y-axis.
    • area

      public double area()
      Computes and returns the surface area.
      Specified by:
      area in interface EllipseTypeGeometry
      Specified by:
      area in interface Geometry
      Specified by:
      area in interface Surface
      Returns:
      the surface area.
    • length

      public double length()
      Returns the perimeter approximation, according to Ramanujan's formula. https://www.mathsisfun.com/geometry/ellipse-perimeter.html.
      Specified by:
      length in interface Geometry
      Returns:
      the ellipse perimeter approcimation.
    • centroid

      public Point centroid()
      Returns the centroid of the current surface.
      Specified by:
      centroid in interface EllipseTypeGeometry
      Specified by:
      centroid in interface Surface
      Returns:
      the centroid.
    • pointOnSurface

      public Point pointOnSurface()
      Returns a point that is located in the interior of this surface geometry.
      Specified by:
      pointOnSurface in interface EllipseTypeGeometry
      Specified by:
      pointOnSurface in interface Surface
      Returns:
      a point on thge surface.
    • getAngle

      public float getAngle()
      Returns:
      Returns the angle.
    • getSemiAxes

      public Dimension getSemiAxes()
      Returns:
      Returns the semiAxes.
    • setSemiAxes

      public void setSemiAxes(Dimension semiAxes)
    • getCoord

      public Point getCoord()
      Returns the ellipse origin.
      Note that the origin may not be included in the ellipse surface.
      Returns:
      the ellipse origin.
    • setCoord

      public void setCoord(Point coord)
    • computeFocusPoints

      public Point[] computeFocusPoints(double a, double b, double cosTheta, double sinTheta)
    • computeEndPoints

      public Point[] computeEndPoints(double a, double b, double cosTheta, double sinTheta)
    • toPolygon

      public Polygon toPolygon()
    • toString

      public String toString()
      Description copied from interface: Geometry
      Returns information about the current geometry.
      Specified by:
      toString in interface Geometry
      Overrides:
      toString in class Object
      Returns:
      information about the current geometry.
    • sizeOf

      public int sizeOf()
      Returns an approximation in bytes of the memory used by this geometry.
      Specified by:
      sizeOf in interface Geometry
      Returns:
      the memory used by this geometry.