Package arc.math.geom

Class Circle

java.lang.Object
arc.math.geom.Circle
All Implemented Interfaces:
Shape2D

public class Circle extends Object implements Shape2D
A convenient 2D circle class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    float
     
    float
     
    float
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new circle with all values set to zero
    Circle(float x, float y, float radius)
    Constructs a new circle with the given X and Y coordinates and the given radius.
    Circle(Circle circle)
    Copy constructor
    Circle(Vec2 position, float radius)
    Constructs a new circle using a given Vec2 that contains the desired X and Y coordinates, and a given radius.
    Circle(Vec2 center, Vec2 edge)
    Creates a new Circle in terms of its center and a point on its edge.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
     
    float
     
    boolean
    contains(float x, float y)
    Checks whether or not this circle contains a given point.
    boolean
     
    boolean
    contains(Vec2 point)
    Checks whether or not this circle contains a given point.
    boolean
     
    int
     
    boolean
     
    set(float x, float y, float radius)
    Sets a new location and radius for this circle.
    set(Circle circle)
    Sets a new location and radius for this circle, based upon another circle.
    set(Vec2 position, float radius)
    Sets a new location and radius for this circle.
    set(Vec2 center, Vec2 edge)
    Sets this Circle's values in terms of its center and a point on its edge.
    setPosition(float x, float y)
    Sets the x and y-coordinates of circle center
    setPosition(Vec2 position)
    Sets the x and y-coordinates of circle center from vector
    void
    setRadius(float radius)
    Sets the radius of circle
    void
    setX(float x)
    Sets the x-coordinate of circle center
    void
    setY(float y)
    Sets the y-coordinate of circle center
    Returns a String representation of this Circle of the form x,y,radius.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • x

      public float x
    • y

      public float y
    • radius

      public float radius
  • Constructor Details

    • Circle

      public Circle()
      Constructs a new circle with all values set to zero
    • Circle

      public Circle(float x, float y, float radius)
      Constructs a new circle with the given X and Y coordinates and the given radius.
      Parameters:
      x - X coordinate
      y - Y coordinate
      radius - The radius of the circle
    • Circle

      public Circle(Vec2 position, float radius)
      Constructs a new circle using a given Vec2 that contains the desired X and Y coordinates, and a given radius.
      Parameters:
      position - The position Vec2.
      radius - The radius
    • Circle

      public Circle(Circle circle)
      Copy constructor
      Parameters:
      circle - The circle to construct a copy of.
    • Circle

      public Circle(Vec2 center, Vec2 edge)
      Creates a new Circle in terms of its center and a point on its edge.
      Parameters:
      center - The center of the new circle
      edge - Any point on the edge of the given circle
  • Method Details

    • set

      public Circle set(float x, float y, float radius)
      Sets a new location and radius for this circle.
      Parameters:
      x - X coordinate
      y - Y coordinate
      radius - Circle radius
    • set

      public Circle set(Vec2 position, float radius)
      Sets a new location and radius for this circle.
      Parameters:
      position - Position Vec2 for this circle.
      radius - Circle radius
    • set

      public Circle set(Circle circle)
      Sets a new location and radius for this circle, based upon another circle.
      Parameters:
      circle - The circle to copy the position and radius of.
    • set

      public Circle set(Vec2 center, Vec2 edge)
      Sets this Circle's values in terms of its center and a point on its edge.
      Parameters:
      center - The new center of the circle
      edge - Any point on the edge of the given circle
    • setPosition

      public Circle setPosition(Vec2 position)
      Sets the x and y-coordinates of circle center from vector
      Parameters:
      position - The position vector
    • setPosition

      public Circle setPosition(float x, float y)
      Sets the x and y-coordinates of circle center
      Parameters:
      x - The x-coordinate
      y - The y-coordinate
    • setX

      public void setX(float x)
      Sets the x-coordinate of circle center
      Parameters:
      x - The x-coordinate
    • setY

      public void setY(float y)
      Sets the y-coordinate of circle center
      Parameters:
      y - The y-coordinate
    • setRadius

      public void setRadius(float radius)
      Sets the radius of circle
      Parameters:
      radius - The radius
    • contains

      public boolean contains(float x, float y)
      Checks whether or not this circle contains a given point.
      Specified by:
      contains in interface Shape2D
      Parameters:
      x - X coordinate
      y - Y coordinate
      Returns:
      true if this circle contains the given point.
    • contains

      public boolean contains(Vec2 point)
      Checks whether or not this circle contains a given point.
      Specified by:
      contains in interface Shape2D
      Parameters:
      point - The Vec2 that contains the point coordinates.
      Returns:
      true if this circle contains this point; false otherwise.
    • contains

      public boolean contains(Circle c)
      Parameters:
      c - the other Circle
      Returns:
      whether this circle contains the other circle.
    • overlaps

      public boolean overlaps(Circle c)
      Parameters:
      c - the other Circle
      Returns:
      whether this circle overlaps the other circle.
    • toString

      public String toString()
      Returns a String representation of this Circle of the form x,y,radius.
      Overrides:
      toString in class Object
    • circumference

      public float circumference()
      Returns:
      The circumference of this circle (as 2 * Mathf.PI2) * radius
    • area

      public float area()
      Returns:
      The area of this circle (as Mathf.PI * radius * radius).
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object