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)
Shape
public Rectangle calculateRegularBoundingBox()
GeometricObject
calculateRegularBoundingBox
in interface GeometricObject
public void translate(float x, float y)
GeometricObject
translate
in interface GeometricObject
x
- x-translationy
- y-translationpublic void scale(float sc)
GeometricObject
scale
in interface GeometricObject
sc
- the scale factor.public void scale(Point2d centre, float sc)
GeometricObject
scale
in interface GeometricObject
centre
- the centre of the scaling operationsc
- the scale factorpublic void scaleCentroid(float sc)
GeometricObject
scaleCentroid
in interface GeometricObject
sc
- the scale factorpublic Point2d calculateCentroid()
GeometricObject
calculateCentroid
in interface GeometricObject
public double calculateArea()
Shape
calculateArea
in interface Shape
public double minX()
minX
in interface GeometricObject
public double minY()
minY
in interface GeometricObject
public double maxX()
maxX
in interface GeometricObject
public double maxY()
maxY
in interface GeometricObject
public double getWidth()
getWidth
in interface GeometricObject
public double getHeight()
getHeight
in interface GeometricObject
public Triangle transform(Jama.Matrix transform)
Shape
GeometricObject
and
return ittransform
in interface GeometricObject
transform
in interface Shape
transform
- 3x3 transform matrixpublic Polygon asPolygon()
Shape
public Point2d firstVertex()
public Point2d secondVertex()
public Point2d thirdVertex()
public boolean sharesVertex(Triangle other)
other
- the other triangle.public double intersectionArea(Shape that)
Shape
Polygon.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 Shape
public double intersectionArea(Shape that, int nStepsPerDimention)
Shape
intersectionArea
in interface Shape
public Map<Line2d,Point2d> intersectionSides(Line2d line)
line
- the linepublic double calculatePerimeter()
Shape
calculatePerimeter
in interface Shape
public RotatedRectangle minimumBoundingRectangle()
Shape
minimumBoundingRectangle
in interface Shape