| Modifier and Type | Field and Description |
|---|---|
Point2d[] |
vertices
The vertices of the triangle
|
| Constructor and Description |
|---|
Triangle(Point2d[] vertices)
Construct a Triangle with the given vertices.
|
Triangle(Point2d vertex1,
Point2d vertex2,
Point2d vertex3)
Construct a Triangle with the given vertices.
|
| Modifier and Type | Method and Description |
|---|---|
Polygon |
asPolygon()
Convert the shape to a polygon representation
|
double |
calculateArea()
Calculate the area of the shape
|
Point2d |
calculateCentroid()
Calculate the centroid of the shape
|
double |
calculatePerimeter()
Calculate the perimeter of the shape
|
Rectangle |
calculateRegularBoundingBox()
Compute the regular (oriented to the axes) bounding box of the shape.
|
Triangle |
clone() |
boolean |
equals(Object obj) |
Point2d |
firstVertex() |
List<Line2d> |
getEdges() |
double |
getHeight() |
double |
getWidth() |
int |
hashCode() |
double |
intersectionArea(Shape that)
Calls
Polygon.intersectionArea(Shape, int) with 1 step per pixel
dimension. |
double |
intersectionArea(Shape that,
int nStepsPerDimention)
Return an estimate for the area of the intersection of this polygon and
another polygon.
|
Map<Line2d,Point2d> |
intersectionSides(Line2d line)
The intersection of this triangle with the line defined by y = mx + c.
|
boolean |
isConvex()
Test if the shape is convex.
|
boolean |
isInside(Point2d point)
Test whether the point p is inside the shape.
|
boolean |
isInsideOnLine(Point2d point)
Like
isInside(Point2d) but counts being "on the line" as being
inside also |
double |
maxX() |
double |
maxY() |
RotatedRectangle |
minimumBoundingRectangle()
Compute the minimum size rotated bounding rectangle that contains this
shape.
|
double |
minX() |
double |
minY() |
void |
scale(float sc)
Scale the shape by the given amount about (0,0).
|
void |
scale(Point2d centre,
float sc)
Scale the shape by the given amount about the given point.
|
void |
scaleCentroid(float sc)
Scale the shape about its centroid.
|
Point2d |
secondVertex() |
boolean |
sharesVertex(Triangle other)
Test whether this triangle shares a vertex with another triangle.
|
Point2d |
thirdVertex() |
String |
toString() |
Triangle |
transform(Jama.Matrix transform)
Apply a 3x3 transform matrix to a copy of the
GeometricObject and
return it |
void |
translate(float x,
float y)
Translate the shapes position
|
public Triangle(Point2d vertex1, Point2d vertex2, Point2d vertex3)
vertex1 - first vertexvertex2 - second vertexvertex3 - third vertexpublic final boolean isInsideOnLine(Point2d point)
isInside(Point2d) but counts being "on the line" as being
inside alsopoint - the point being testedpublic final boolean isInside(Point2d point)
Shapepublic Rectangle calculateRegularBoundingBox()
GeometricObjectcalculateRegularBoundingBox in interface GeometricObjectpublic void translate(float x, float y)
GeometricObjecttranslate in interface GeometricObjectx - x-translationy - y-translationpublic void scale(float sc)
GeometricObjectscale in interface GeometricObjectsc - the scale factor.public void scale(Point2d centre, float sc)
GeometricObjectscale in interface GeometricObjectcentre - the centre of the scaling operationsc - the scale factorpublic void scaleCentroid(float sc)
GeometricObjectscaleCentroid in interface GeometricObjectsc - the scale factorpublic Point2d calculateCentroid()
GeometricObjectcalculateCentroid in interface GeometricObjectpublic double calculateArea()
ShapecalculateArea in interface Shapepublic double minX()
minX in interface GeometricObjectpublic double minY()
minY in interface GeometricObjectpublic double maxX()
maxX in interface GeometricObjectpublic double maxY()
maxY in interface GeometricObjectpublic double getWidth()
getWidth in interface GeometricObjectpublic double getHeight()
getHeight in interface GeometricObjectpublic Triangle transform(Jama.Matrix transform)
ShapeGeometricObject and
return ittransform in interface GeometricObjecttransform in interface Shapetransform - 3x3 transform matrixpublic Polygon asPolygon()
Shapepublic Point2d firstVertex()
public Point2d secondVertex()
public Point2d thirdVertex()
public boolean sharesVertex(Triangle other)
other - the other triangle.public double intersectionArea(Shape that)
ShapePolygon.intersectionArea(Shape, int) with 1 step per pixel
dimension. Subsequently this function returns the shared whole pixels of
this polygon and that.intersectionArea in interface Shapepublic double intersectionArea(Shape that, int nStepsPerDimention)
ShapeintersectionArea in interface Shapepublic Map<Line2d,Point2d> intersectionSides(Line2d line)
line - the linepublic double calculatePerimeter()
ShapecalculatePerimeter in interface Shapepublic RotatedRectangle minimumBoundingRectangle()
ShapeminimumBoundingRectangle in interface Shape