sim.physics2D.shape
Class Rectangle

java.lang.Object
  extended by sim.physics2D.shape.Shape
      extended by sim.physics2D.shape.Polygon
          extended by sim.physics2D.shape.Rectangle

public class Rectangle
extends Polygon

Rectangle implementation of Polygon


Field Summary
 
Fields inherited from class sim.physics2D.shape.Polygon
edges, maxXDistanceFromCenter, maxYDistanceFromCenter, normals, scale, vertices
 
Fields inherited from class sim.physics2D.shape.Shape
index, paint, stationary
 
Constructor Summary
Rectangle(double width, double height, java.awt.Paint paint)
           
Rectangle(double width, double height, java.awt.Paint paint, boolean stationary)
           
 
Method Summary
 void calcMaxDistances(boolean mobile)
          Calculate the max distance a point can be from the center of the object.
 double getHeight()
           
 double getMassMomentOfInertia(double mass)
          Calculate the mass moment of intertia of the object.
 double getWidth()
           
 void initEdges()
          Set up the edges matrix
 void initNormals()
          Set up the normals matrix
 void initVertices()
          Set up the vertices matrix in homogenous coordinates
 
Methods inherited from class sim.physics2D.shape.Polygon
draw, getEdges, getMaxXDistanceFromCenter, getMaxYDistanceFromCenter, getNormals, getRow, getVertices, rotationMatrix2D, rotationTranslationMatrix2D
 
Methods inherited from class sim.physics2D.shape.Shape
getOrientation, getPaint, getPosition, setIndex, setPaint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rectangle

public Rectangle(double width,
                 double height,
                 java.awt.Paint paint)

Rectangle

public Rectangle(double width,
                 double height,
                 java.awt.Paint paint,
                 boolean stationary)
Method Detail

initVertices

public void initVertices()
Set up the vertices matrix in homogenous coordinates

Specified by:
initVertices in class Polygon

initEdges

public void initEdges()
Set up the edges matrix

Specified by:
initEdges in class Polygon

initNormals

public void initNormals()
Set up the normals matrix

Specified by:
initNormals in class Polygon

getWidth

public double getWidth()

getHeight

public double getHeight()

calcMaxDistances

public void calcMaxDistances(boolean mobile)
Calculate the max distance a point can be from the center of the object. If the object is stationary, we can give more exact values. Remember that stationary objects can have orientation, though, so it can be more complicated than width / 2 and height / 2

Specified by:
calcMaxDistances in class Shape

getMassMomentOfInertia

public double getMassMomentOfInertia(double mass)
Calculate the mass moment of intertia of the object. This can be done through integration, or by finding a precomputed equation for the polygon being defined

Specified by:
getMassMomentOfInertia in class Shape