public class Variable2DShape
extends java.lang.Object
| Constructor and Description |
|---|
Variable2DShape(Line... lines)
Constructor for a 2D shape
|
Variable2DShape(TwoDimensionalVector... vectors)
Constructor for a 2D shape
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object other) |
Line[] |
findSidesWithPoint(TwoDimensionalVector coord)
Creates an array of sides from the shape where the side touches the given coord
This should only ever return 0-2 lines
|
TwoDimensionalVector[] |
getAllPoints()
Deprecated.
|
float |
getAngleForVertex(TwoDimensionalVector vertex)
Finds the (internal) angle of the given vertex
|
double |
getArea()
Calculates the area of the shape
|
TwoDimensionalVector |
getCentroid()
Calculates the approximate center of the polygon
|
int |
getNumberOfSides()
Gets the number of sides for this shape
|
double |
getPerimeter()
Gets the perimeter of the shape
|
Line[] |
getSides()
Gets the lines representing the sides of the shape
|
TwoDimensionalVector[] |
getVertices()
Retrieves all points representing vertices on the shape
|
boolean |
isPointOnPerimeter(TwoDimensionalVector coord)
Checks if the provided point is on the shape's perimeter
|
boolean |
isPointValid(TwoDimensionalVector coord)
Deprecated.
|
Variable2DShape |
rotate(double angle)
Rotates the shape about its centroid
|
Variable2DShape |
rotate(TwoDimensionalVector point,
double angle)
Rotates the shape around a point
|
Variable2DShape |
setCentroid(TwoDimensionalVector centroid)
Translates the whole shape to make a new shape with a matching centroid
|
java.lang.String |
toString() |
public Variable2DShape(TwoDimensionalVector... vectors) throws IncompatibleDimensionsException
vectors - The vectors to form the shape withIncompatibleDimensionsExceptionpublic Variable2DShape(Line... lines) throws IncompatibleDimensionsException
lines - The lines to form the shape withIncompatibleDimensionsExceptionpublic int getNumberOfSides()
public TwoDimensionalVector[] getVertices()
public double getPerimeter()
public double getArea()
public Line[] findSidesWithPoint(TwoDimensionalVector coord)
coord - The coordinate pointpublic float getAngleForVertex(TwoDimensionalVector vertex) throws IncompatibleDimensionsException
vertex - The vertexIncompatibleDimensionsExceptionpublic Line[] getSides()
public TwoDimensionalVector getCentroid()
public Variable2DShape setCentroid(TwoDimensionalVector centroid)
centroid - New centroidpublic Variable2DShape rotate(TwoDimensionalVector point, double angle)
point - The point to rotate aroundangle - The angle to rotate bypublic Variable2DShape rotate(double angle)
angle - The angle to rotate bypublic boolean isPointOnPerimeter(TwoDimensionalVector coord)
coord - The point@Deprecated public boolean isPointValid(TwoDimensionalVector coord)
coord - The point@Deprecated public TwoDimensionalVector[] getAllPoints()
public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object