

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object org.jrabbit.base.math.geom.Geometry
public class Geometry
A Geometry object represents a 2D arbitrary shape. It is designed to work with all Java2D shapes. The point of Geometry is to provide an advanced geometry/collision detection mechanism that is fast and useful enough to be effective in a variety of situations. Geometry has two main components  a base shape, and its transformed child. The base shape defines the unscaled, unrotated, and untranslated shape. The transformed child is created to represent the shape with a scale, rotation, and translation. In this way, a game object can have a complex shape, and (as it moves, rotates, and scales/flips) then it can tell its Geometry to update its child shape. After this update, all intersection and similar calculations utilize this transformed child. Despite the complexity of this setup, for reasonably simple shapes (say, a 10sided, straightedged polygon) this is fairly fast and can allow a large number of objects. Additionally, a Geometry can be used to access the vertice data for its base shape. This allows it to interact with other objects not designed to work with Java2D Shapes (for example, Primitive rendering).
Field Summary  

protected java.awt.geom.Path2D 
shape
The base shape of the Geometry. 
protected java.awt.geom.AffineTransform 
transform
The AWT transform that updates the base shape to create the transformed child shape. 
protected java.awt.geom.Path2D 
transformedShape
The updated shape that accomodates translation, rotation, and scaling. 
(package private) float[][] 
vertices
The stored vertices of the base shape. 
Constructor Summary  

Geometry()
Creates an empty Geometry. 

Geometry(float[][] vertices)
Creates a Geometry from the supplied vertice data. 

Geometry(float width,
float height)
Creates a rectangular Geometry with the indicated base dimensions. 

Geometry(java.awt.Shape shape)
Creates a Geometry with the indicated base shape. 

Geometry(Vertexed vertexed)
Creates a Geometry that defines its geometry from those of the indicated Vertexed. 
Method Summary  

void 
apply(float x,
float y,
float theta,
float xScale,
float yScale)
Recalculates the transformed shape so that it represents the base shape, but translated, rotated, and scaled as indicated. 
void 
apply(Vector2f location,
Rotation rotation,
Scalar scale)
Recalculates the transformed shape so that it represents the base shape, but translated, rotated, and scaled as indicated. 
java.awt.geom.Path2D 
baseShape()
Accesses the base shape that defines this geometry. 
boolean 
contains(float x,
float y)
Determines if the currently transformed Geometry contains the indicated point. 
boolean 
contains(Vector2f point)
Determines if the currently transformed Geometry contains the indicated point. 
static float[][] 
extractVertices(java.awt.geom.Path2D path)
Converts a GeneralPath to its vertice data. 
java.awt.geom.Area 
intersection(Geometry target)
Calculates the intersecting area of the two Geometries. 
java.awt.geom.Area 
intersection(java.awt.Shape target)
Calculates the intersecting area of the the indicated Shape and the transformed Shape of this Geometry. 
boolean 
intersects(Geometry target)
Determines if the two Geometries intersect. 
boolean 
intersects(java.awt.Shape target)
Determines if the indicated Shape intersects the transformed Shape belonging to this Geometry. 
void 
set(float[][] vertices)
Constructs a new base shape from the indicated vertex data. 
void 
set(java.awt.Shape shape)
Redefines the base shape to be the indicated Java AWT Shape. 
void 
set(java.awt.Shape shape,
double offsetX,
double offsetY)
Redefines the base shape to be the indicated Java AWT Shape. 
void 
set(Vertexed vertexed)
Redefines the Geometry based on the geometry of the indicated Vertexed. 
java.awt.geom.Path2D 
shape()
Accesses the updated shape derived from the base shape. 
float[][] 
vertices()
Accesses the vertex data that approximates the base geometry. 
Methods inherited from class java.lang.Object 

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Field Detail 

protected java.awt.geom.Path2D shape
protected java.awt.geom.Path2D transformedShape
protected java.awt.geom.AffineTransform transform
float[][] vertices
Constructor Detail 

public Geometry()
public Geometry(float width, float height)
width
 The width of the rectangle.height
 The height of the rectangle.public Geometry(java.awt.Shape shape)
shape
 The Java Shape to use for the Geometry.public Geometry(float[][] vertices)
vertices
 The point data to use for calculating the geometry.public Geometry(Vertexed vertexed)
vertexed
 The Vertexed object to acquire geometry info from.Method Detail 

public static float[][] extractVertices(java.awt.geom.Path2D path)
path
 The GeneralPath to convert.
public void set(java.awt.Shape shape)
shape
 The new base shape.public void set(java.awt.Shape shape, double offsetX, double offsetY)
shape
 The new base shape.offsetX
 The amount to offset the shape's X coordinate.offsetY
 The amount to offset the shape's Y coordinate.public void set(float[][] vertices)
vertices
 The vertex data used to build the new shape.public void set(Vertexed vertexed)
vertexed
 The Vertexed object that contains the needed geometry.set(float[][])
public java.awt.geom.Path2D baseShape()
public java.awt.geom.Path2D shape()
public float[][] vertices()
vertices
in interface Vertexed
public void apply(float x, float y, float theta, float xScale, float yScale)
x
 The amount to translate the shape on the x axis.y
 The amount to translate the shape on the y axis.theta
 The amount to rotate, in clockwise radians.xScale
 The amount to scale the base shape on the x axis.yScale
 The amount to scale the base shape on the y axis.public void apply(Vector2f location, Rotation rotation, Scalar scale)
location
 The Vector2f that indicates how far to translate.rotation
 The Rotation that indicates how much to rotate.scale
 The Scalar that indicates how to scale.apply(float, float, float, float, float)
public boolean contains(float x, float y)
x
 The xcoordinate.y
 The ycoordinate.
public boolean contains(Vector2f point)
point
 The Vector2f that represents the point to check for.
contains(float, float)
public boolean intersects(Geometry target)
target
 The Geometry to check against.
intersection(Shape)
public boolean intersects(java.awt.Shape target)
target
 The Shape to check against.
public java.awt.geom.Area intersection(Geometry target)
target
 The Geometry to check against.
intersection(Shape)
public java.awt.geom.Area intersection(java.awt.Shape target)
target
 The Shape to check against.


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 