Package toxi.geom

Class Circle

All Implemented Interfaces:
Comparable<ReadonlyVec2D>, ReadonlyVec2D, Shape2D

public class Circle extends Ellipse
This class overrides Ellipse to define a 2D circle and provides several utility methods for it, including factory methods to construct circles from points.
  • Constructor Details

    • Circle

      public Circle()
    • Circle

      public Circle(Circle c)
    • Circle

      public Circle(float radius)
    • Circle

      public Circle(float x, float y, float radius)
    • Circle

      public Circle(ReadonlyVec2D origin, float radius)
  • Method Details

    • from2Points

      public static Circle from2Points(Vec2D p1, Vec2D p2)
      Factory method to construct a circle which has the two given points lying on its perimeter. If the points are coincident, the circle will have a radius of zero.
      Parameters:
      p1 -
      p2 -
      Returns:
      new circle instance
    • from3Points

      public static Circle from3Points(Vec2D p1, Vec2D p2, Vec2D p3)
      Factory method to construct a circle which has the three given points lying on its perimeter. The function returns null, if the 3 points are co-linear (in which case it's impossible to find a circle). Based on CPP code by Paul Bourke: http://local.wasp.uwa.edu.au/~pbourke/geometry/circlefrom3/
      Parameters:
      p1 -
      p2 -
      p3 -
      Returns:
      new circle instance or null
    • newBoundingCircle

      public static Circle newBoundingCircle(List<Vec2D> vertices)
    • containsPoint

      public boolean containsPoint(ReadonlyVec2D p)
      Description copied from interface: Shape2D
      Checks if the point is within the given shape.
      Specified by:
      containsPoint in interface Shape2D
      Overrides:
      containsPoint in class Ellipse
      Returns:
      true, if inside
    • getCircumference

      public float getCircumference()
      Description copied from class: Ellipse
      Computes the approximate circumference of the ellipse, using this equation: 2 * PI * sqrt(1/2 * (rx*rx+ry*ry)). The precise value is an infinite series elliptical integral, but the approximation comes sufficiently close. See Wikipedia for more details: http://en.wikipedia.org/wiki/Ellipse
      Specified by:
      getCircumference in interface Shape2D
      Overrides:
      getCircumference in class Ellipse
      Returns:
      circumference
    • getRadius

      public float getRadius()
    • getTangentPoints

      public Vec2D[] getTangentPoints(ReadonlyVec2D p)
    • intersectsCircle

      public Vec2D[] intersectsCircle(Circle c)
    • setRadius

      public Circle setRadius(float r)