hermes.hshape
Class HCircle

java.lang.Object
  extended by hermes.hshape.HShape
      extended by hermes.hshape.HCircle

public class HCircle
extends HShape

Represents a circle.


Field Summary
 
Fields inherited from class hermes.hshape.HShape
_position
 
Constructor Summary
HCircle(PVector position, float radius)
          Constructor defining center of circle as position of object.
HCircle(PVector position, PVector center, float radius)
          Constructor defining center of circle to be a certain distance away from the position.
 
Method Summary
 boolean contains(float x, float y)
           
 boolean contains(PVector point)
          Whether the Shape contains the given point coordinates (boundary is inclusive).
 void draw()
          Shortcut method for drawing the shape on screen
 HRectangle getBoundingBox()
          Finds the smallest Rectangle that encloses the shape.
 PVector getCenter()
          Getter for center
 float getRadius()
          Getter for radius
 PVector projectionVector(HCircle other)
           
 PVector projectionVector(HPolygon other)
           
 PVector projectionVector(HRectangle other)
           
 PVector projectionVector(HShape other)
          Finds the projection vector for a collision with another shape.
 java.lang.String toString()
           
 
Methods inherited from class hermes.hshape.HShape
collide, getPosition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HCircle

public HCircle(PVector position,
               float radius)
Constructor defining center of circle as position of object.

Parameters:
position -
radius -

HCircle

public HCircle(PVector position,
               PVector center,
               float radius)
Constructor defining center of circle to be a certain distance away from the position.

Parameters:
position -
center -
radius -
Method Detail

getCenter

public PVector getCenter()
Getter for center


getRadius

public float getRadius()
Getter for radius


contains

public boolean contains(PVector point)
Description copied from class: HShape
Whether the Shape contains the given point coordinates (boundary is inclusive).

Specified by:
contains in class HShape
Parameters:
point - the point vector
Returns:
true if (x,y) lies within the Shape

contains

public boolean contains(float x,
                        float y)
Specified by:
contains in class HShape
Parameters:
x - the x coordinate
y - the y coordinate
Returns:
true if (x,y) lies within the Shape

projectionVector

public PVector projectionVector(HShape other)
Description copied from class: HShape
Finds the projection vector for a collision with another shape.

The projection vector is the vector by which one body could be displaced such that it no longer intersects the other body, by the shortest possible distance.

Each shape must contain methods for collision with all other types of HShapes. If you create your own type of shape, you will have to modify HShape (as well as its subclasses) to contain methods colliding it with the new type.

Specified by:
projectionVector in class HShape
Parameters:
other - the shape to collide with
Returns:
the projection vector from this body to other, or null if they aren't colliding

projectionVector

public PVector projectionVector(HPolygon other)
Specified by:
projectionVector in class HShape

projectionVector

public PVector projectionVector(HCircle other)
Specified by:
projectionVector in class HShape

projectionVector

public PVector projectionVector(HRectangle other)
Specified by:
projectionVector in class HShape

getBoundingBox

public HRectangle getBoundingBox()
Description copied from class: HShape
Finds the smallest Rectangle that encloses the shape.

Specified by:
getBoundingBox in class HShape
Returns:
the bounding box

draw

public void draw()
Description copied from class: HShape
Shortcut method for drawing the shape on screen

Specified by:
draw in class HShape

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object