org.newdawn.slick.geom
Class Circle

java.lang.Object
  extended by org.newdawn.slick.geom.Shape
      extended by org.newdawn.slick.geom.Ellipse
          extended by org.newdawn.slick.geom.Circle
All Implemented Interfaces:
java.io.Serializable

public class Circle
extends Ellipse

A simple Circle geometry

Author:
Kevin Glass
See Also:
Serialized Form

Field Summary
 float radius
          The radius of the circle
 
Fields inherited from class org.newdawn.slick.geom.Ellipse
DEFAULT_SEGMENT_COUNT
 
Fields inherited from class org.newdawn.slick.geom.Shape
boundingCircleRadius, center, maxX, maxY, minX, minY, points, pointsDirty, trianglesDirty, tris, x, y
 
Constructor Summary
Circle(float centerPointX, float centerPointY, float radius)
          Create a new circle based on its radius
Circle(float centerPointX, float centerPointY, float radius, int segmentCount)
          Create a new circle based on its radius
 
Method Summary
protected  void calculateRadius()
          Calculate the radius of a circle that can completely enclose this shape.
 boolean contains(float x, float y)
          Check if a point is contained by this circle
protected  void findCenter()
          Get the center of this polygon.
 float[] getCenter()
          Get the coordinates of the center of the circle
 float getCenterX()
          Get the x coordinate of the centre of the circle
 float getCenterY()
          Get the y coordinate of the centre of the circle
 float getRadius()
          Get the radius of the circle
 boolean intersects(Shape shape)
          Check if this circle touches another
 void setRadius(float radius)
          Set the radius of this circle
 
Methods inherited from class org.newdawn.slick.geom.Ellipse
createPoints, getRadius1, getRadius2, setRadii, setRadius1, setRadius2, transform
 
Methods inherited from class org.newdawn.slick.geom.Shape
calculateTriangles, checkPoints, closed, contains, getBoundingCircleRadius, getHeight, getLocation, getMaxX, getMaxY, getMinX, getMinY, getNormal, getPoint, getPointCount, getPoints, getTriangles, getWidth, getX, getY, hasVertex, includes, increaseTriangulation, indexOf, preCache, prune, setCenterX, setCenterY, setLocation, setLocation, setX, setY, subtract, union
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

radius

public float radius
The radius of the circle

Constructor Detail

Circle

public Circle(float centerPointX,
              float centerPointY,
              float radius)
Create a new circle based on its radius

Parameters:
centerPointX - The x location of the center of the circle
centerPointY - The y location of the center of the circle
radius - The radius of the circle

Circle

public Circle(float centerPointX,
              float centerPointY,
              float radius,
              int segmentCount)
Create a new circle based on its radius

Parameters:
centerPointX - The x location of the center of the circle
centerPointY - The y location of the center of the circle
radius - The radius of the circle
segmentCount - The number of segments to build the circle out of
Method Detail

getCenterX

public float getCenterX()
Get the x coordinate of the centre of the circle

Overrides:
getCenterX in class Shape
Returns:
The x coordinate of the centre of the circle

getCenterY

public float getCenterY()
Get the y coordinate of the centre of the circle

Overrides:
getCenterY in class Shape
Returns:
The y coordinate of the centre of the circle

getCenter

public float[] getCenter()
Get the coordinates of the center of the circle

Overrides:
getCenter in class Shape
Returns:
2-element array with the center of the circle.

setRadius

public void setRadius(float radius)
Set the radius of this circle

Parameters:
radius - The radius of this circle

getRadius

public float getRadius()
Get the radius of the circle

Returns:
The radius of the circle

intersects

public boolean intersects(Shape shape)
Check if this circle touches another

Overrides:
intersects in class Shape
Parameters:
shape - The other circle
Returns:
True if they touch

contains

public boolean contains(float x,
                        float y)
Check if a point is contained by this circle

Overrides:
contains in class Shape
Parameters:
x - The x coordinate of the point to check
y - The y coorindate of the point to check
Returns:
True if the point is contained by this circle

findCenter

protected void findCenter()
Description copied from class: Shape
Get the center of this polygon.

Overrides:
findCenter in class Ellipse
See Also:
Ellipse.findCenter()

calculateRadius

protected void calculateRadius()
Description copied from class: Shape
Calculate the radius of a circle that can completely enclose this shape.

Overrides:
calculateRadius in class Ellipse
See Also:
Ellipse.calculateRadius()


Copyright © 2006 New Dawn Software. All Rights Reserved.