com.vividsolutions.jts.geom
Class Triangle

java.lang.Object
  extended bycom.vividsolutions.jts.geom.Triangle

public class Triangle
extends java.lang.Object

Represents a planar triangle, and provides methods for calculating various properties of triangles.

Version:
1.7

Field Summary
 Coordinate p0
           
 Coordinate p1
           
 Coordinate p2
           
 
Constructor Summary
Triangle(Coordinate p0, Coordinate p1, Coordinate p2)
           
 
Method Summary
static Coordinate angleBisector(Coordinate a, Coordinate b, Coordinate c)
          Computes the point at which the bisector of the angle ABC cuts the segment AC.
static double area(Coordinate a, Coordinate b, Coordinate c)
          Computes the area of a triangle.
static Coordinate centroid(Coordinate a, Coordinate b, Coordinate c)
          Computes the centroid (centre of mass) of a triangle.
static Coordinate circumcentre(Coordinate a, Coordinate b, Coordinate c)
          Computes the circumcentre of a triangle.
 Coordinate inCentre()
          Computes the incentre of a triangle.
static Coordinate inCentre(Coordinate a, Coordinate b, Coordinate c)
          Computes the incentre of a triangle.
static boolean isAcute(Coordinate a, Coordinate b, Coordinate c)
          Tests whether the triangle is acute.
static double longestSideLength(Coordinate a, Coordinate b, Coordinate c)
          Computes the length of the longest side of a triangle
static HCoordinate perpendicularBisector(Coordinate a, Coordinate b)
          Computes the line which is the perpendicular bisector of the line segment a-b.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

p0

public Coordinate p0

p1

public Coordinate p1

p2

public Coordinate p2
Constructor Detail

Triangle

public Triangle(Coordinate p0,
                Coordinate p1,
                Coordinate p2)
Method Detail

isAcute

public static boolean isAcute(Coordinate a,
                              Coordinate b,
                              Coordinate c)
Tests whether the triangle is acute. A triangle is acute iff all interior angles are acute.

Parameters:
a - a vertex of the triangle
b - a vertex of the triangle
c - a vertex of the triangle
Returns:
true if the triangle is acute

perpendicularBisector

public static HCoordinate perpendicularBisector(Coordinate a,
                                                Coordinate b)
Computes the line which is the perpendicular bisector of the line segment a-b.

Parameters:
a - a point
b - another point
Returns:
the perpendicular bisector, as an HCoordinate

circumcentre

public static Coordinate circumcentre(Coordinate a,
                                      Coordinate b,
                                      Coordinate c)
Computes the circumcentre of a triangle. The circumcentre is the centre of the circumcircle, the smallest circle which encloses the triangle.

Parameters:
a - a vertx of the triangle
b - a vertx of the triangle
c - a vertx of the triangle
Returns:
the circumcentre of the triangle

inCentre

public static Coordinate inCentre(Coordinate a,
                                  Coordinate b,
                                  Coordinate c)
Computes the incentre of a triangle. The inCentre of a triangle is the point which is equidistant from the sides of the triangle. It is also the point at which the bisectors of the triangle's angles meet. It is the centre of the incircle, which is the unique circle that is tangent to each of the triangle's three sides.

Parameters:
a - a vertx of the triangle
b - a vertx of the triangle
c - a vertx of the triangle
Returns:
the point which is the incentre of the triangle

centroid

public static Coordinate centroid(Coordinate a,
                                  Coordinate b,
                                  Coordinate c)
Computes the centroid (centre of mass) of a triangle. This is also the point at which the triangle's three medians intersect (a triangle median is the segment from a vertex of the triangle to the midpoint of the opposite side). The centroid divides each median in a ratio of 2:1.

Parameters:
a - a vertex of the triangle
b - a vertex of the triangle
c - a vertex of the triangle
Returns:
the centroid of the triangle

longestSideLength

public static double longestSideLength(Coordinate a,
                                       Coordinate b,
                                       Coordinate c)
Computes the length of the longest side of a triangle

Parameters:
a - a vertex of the triangle
b - a vertex of the triangle
c - a vertex of the triangle
Returns:
the length of the longest side of the triangle

angleBisector

public static Coordinate angleBisector(Coordinate a,
                                       Coordinate b,
                                       Coordinate c)
Computes the point at which the bisector of the angle ABC cuts the segment AC.

Parameters:
a - a vertex of the triangle
b - a vertex of the triangle
c - a vertex of the triangle
Returns:
the angle bisector cut point

area

public static double area(Coordinate a,
                          Coordinate b,
                          Coordinate c)
Computes the area of a triangle.

Parameters:
a - a vertex of the triangle
b - a vertex of the triangle
c - a vertex of the triangle
Returns:
the area of the triangle

inCentre

public Coordinate inCentre()
Computes the incentre of a triangle. The inCentre of a triangle is the point which is equidistant from the sides of the triangle. It is also the point at which the bisectors of the triangle's angles meet. It is the centre of the incircle, which is the unique circle that is tangent to each of the triangle's three sides.

Returns:
the point which is the inCentre of the triangle