ch.aplu.jgamegrid
Class GGCircle

java.lang.Object
  extended by ch.aplu.jgamegrid.GGCircle

public class GGCircle
extends java.lang.Object

Class representing a circle in the x-y-plane with a center vector and a radius (all doubles).


Field Summary
 GGVector center
          The public vector to the center of the circle.
 double radius
          The public radius of the circle.
 
Constructor Summary
GGCircle()
          Constructs a circle at (0, 0) with radius = 0.
GGCircle(double radius)
          Constructs a circle at (0, 0) with given radius.
GGCircle(GGCircle circle)
          Constructs a new circle with the same center and radius as the given circle.
GGCircle(GGVector center, double radius)
          Constructs a circle with given center and radius.
 
Method Summary
 GGCircle clone()
          Returns a new circle with the same center and radius as the current circle.
 GGVector getCenter()
          Returns a copy of the center of the circle.
 double getRadius()
          Returns the radius of the circle.
 boolean isEqual(GGCircle circle)
          Returns true, if the current circle is identical to the given circle.
 boolean isIntersecting(GGCircle circle)
          Returns true if the current circle intersects with the given circle.
 boolean isIntersecting(GGRectangle rect)
          Returns true if the current circle intersects with the given rectangle.
 boolean isIntersecting(GGVector vector)
          Returns true if the given points is part of the circle area.
 boolean isIntersecting(GGVector imageCenter, double imageDirection, java.awt.image.BufferedImage image, boolean isRotatable)
          Returns true, if area of the current circle intersects the non-transparant area of the given image.
 boolean isIntersecting(java.awt.Rectangle rect)
          Returns true if the current circle intersects with the given java.awt.Rectangle.
 java.lang.String toString()
          Returns a string that enumerates center and radius.
 void translate(GGVector v)
          Performs a translation by the given vector.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

center

public GGVector center
The public vector to the center of the circle.


radius

public double radius
The public radius of the circle.

Constructor Detail

GGCircle

public GGCircle(GGVector center,
                double radius)
Constructs a circle with given center and radius.

Parameters:
center - the vector to the center
radius - the radius of the circle

GGCircle

public GGCircle(double radius)
Constructs a circle at (0, 0) with given radius.

Parameters:
radius - the radius of the circle

GGCircle

public GGCircle()
Constructs a circle at (0, 0) with radius = 0.


GGCircle

public GGCircle(GGCircle circle)
Constructs a new circle with the same center and radius as the given circle.

Parameters:
circle - the circle from where center and radius are copied.
Method Detail

getRadius

public double getRadius()
Returns the radius of the circle.

Returns:
the radius of the circle

getCenter

public GGVector getCenter()
Returns a copy of the center of the circle.

Returns:
a clone of the center of the circle

clone

public GGCircle clone()
Returns a new circle with the same center and radius as the current circle.

Overrides:
clone in class java.lang.Object

translate

public void translate(GGVector v)
Performs a translation by the given vector.

Parameters:
v - the translation vector

isIntersecting

public boolean isIntersecting(GGCircle circle)
Returns true if the current circle intersects with the given circle.

Parameters:
circle - the circle to be checked for intersection with the current circle
Returns:
true, if the two circles intersects; otherwise false

isIntersecting

public boolean isIntersecting(GGRectangle rect)
Returns true if the current circle intersects with the given rectangle.

Parameters:
rect - the rectangle to be checked for intersection with the current circle
Returns:
true, if the two figures intersects; otherwise false

isIntersecting

public boolean isIntersecting(java.awt.Rectangle rect)
Returns true if the current circle intersects with the given java.awt.Rectangle.

Parameters:
rect - the rectangle to be checked for intersection with the current circle
Returns:
true, if the two figures intersects; otherwise false

isIntersecting

public boolean isIntersecting(GGVector vector)
Returns true if the given points is part of the circle area.

Parameters:
vector - the vector to be checked for intersection
Returns:
true, if the vector (end point) lays inside or on the border of the circle; otherwise false

isIntersecting

public boolean isIntersecting(GGVector imageCenter,
                              double imageDirection,
                              java.awt.image.BufferedImage image,
                              boolean isRotatable)
Returns true, if area of the current circle intersects the non-transparant area of the given image.

Parameters:
imageCenter - the vector to the center of the image
imageDirection - the direction of the image (angle of edge ulx --> uly with respect to the positive x-direction (0..2*pi))
image - the buffered image
isRotatable - if true, the imageDirection is considered; otherwise imageDirection = 0 is assumed

toString

public java.lang.String toString()
Returns a string that enumerates center and radius.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the circle

isEqual

public boolean isEqual(GGCircle circle)
Returns true, if the current circle is identical to the given circle.

Parameters:
circle - the cirle to compare
Returns:
true, if both circles are identical