Search Results for

    Show / Hide Table of Contents

    Class Triangle

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

    Inheritance
    object
    Triangle
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: NetTopologySuite.Geometries
    Assembly: NetTopologySuite.dll
    Syntax
    public class Triangle

    Constructors

    | Edit this page View Source

    Triangle(Coordinate, Coordinate, Coordinate)

    Creates a new triangle with the given vertices.

    Declaration
    public Triangle(Coordinate p0, Coordinate p1, Coordinate p2)
    Parameters
    Type Name Description
    Coordinate p0

    A vertex

    Coordinate p1

    A vertex

    Coordinate p2

    A vertex

    Properties

    | Edit this page View Source

    P0

    A corner point of the triangle

    Declaration
    public Coordinate P0 { get; set; }
    Property Value
    Type Description
    Coordinate
    | Edit this page View Source

    P1

    A corner point of the triangle

    Declaration
    public Coordinate P1 { get; set; }
    Property Value
    Type Description
    Coordinate
    | Edit this page View Source

    P2

    A corner point of the triangle

    Declaration
    public Coordinate P2 { get; set; }
    Property Value
    Type Description
    Coordinate

    Methods

    | Edit this page View Source

    AngleBisector(Coordinate, Coordinate, Coordinate)

    Computes the point at which the bisector of the angle ABC cuts the segment AC.

    Declaration
    public static Coordinate AngleBisector(Coordinate a, Coordinate b, Coordinate c)
    Parameters
    Type Name Description
    Coordinate a

    A vertex of the triangle

    Coordinate b

    A vertex of the triangle

    Coordinate c

    A vertex of the triangle

    Returns
    Type Description
    Coordinate

    The angle bisector cut point

    | Edit this page View Source

    Area()

    Computes the 2D area of this triangle. The area value is always non-negative.

    Declaration
    public double Area()
    Returns
    Type Description
    double

    The area of this triangle

    See Also
    SignedArea()
    | Edit this page View Source

    Area(Coordinate, Coordinate, Coordinate)

    Computes the 2D area of a triangle. The area value is always non-negative.

    Declaration
    public static double Area(Coordinate a, Coordinate b, Coordinate c)
    Parameters
    Type Name Description
    Coordinate a

    A vertex of the triangle

    Coordinate b

    A vertex of the triangle

    Coordinate c

    A vertex of the triangle

    Returns
    Type Description
    double

    The area of the triangle

    See Also
    SignedArea(Coordinate, Coordinate, Coordinate)
    | Edit this page View Source

    Area3D()

    Computes the 3D area of this triangle. The value computed is always non-negative.

    Declaration
    public double Area3D()
    Returns
    Type Description
    double

    The 3D area of this triangle

    | Edit this page View Source

    Area3D(Coordinate, Coordinate, Coordinate)

    Computes the 3D area of a triangle. The value computed is always non-negative.

    Declaration
    public static double Area3D(Coordinate a, Coordinate b, Coordinate c)
    Parameters
    Type Name Description
    Coordinate a

    A vertex of the triangle

    Coordinate b

    A vertex of the triangle

    Coordinate c

    A vertex of the triangle

    Returns
    Type Description
    double

    The 3D area of the triangle

    | Edit this page View Source

    Centroid()

    Computes the centroid (centre of mass) of this 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.

    The centroid always lies within the triangle.
    Declaration
    public Coordinate Centroid()
    Returns
    Type Description
    Coordinate

    The centroid of this triangle

    | Edit this page View Source

    Centroid(Coordinate, Coordinate, Coordinate)

    Computes the centroid (centre of mass) of a triangle.

    Declaration
    public static Coordinate Centroid(Coordinate a, Coordinate b, Coordinate c)
    Parameters
    Type Name Description
    Coordinate a

    A vertex of the triangle

    Coordinate b

    A vertex of the triangle

    Coordinate c

    A vertex of the triangle

    Returns
    Type Description
    Coordinate

    The centroid of the triangle

    Remarks

    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. The centroid always lies within the triangle.

    | Edit this page View Source

    Circumcentre()

    Computes the circumcentre of this triangle. The circumcentre is the centre of the circumcircle, the smallest circle which passes through all the triangle vertices. It is also the common intersection point of the perpendicular bisectors of the sides of the triangle, and is the only point which has equal distance to all three vertices of the triangle.

    The circumcentre does not necessarily lie within the triangle.

    This method uses an algorithm due to J.R.Shewchuk which uses normalization to the origin to improve the accuracy of computation. (See Lecture Notes on Geometric Robustness, Jonathan Richard Shewchuk, 1999).
    Declaration
    public Coordinate Circumcentre()
    Returns
    Type Description
    Coordinate

    The circumcentre of this triangle

    | Edit this page View Source

    Circumcentre(Coordinate, Coordinate, Coordinate)

    Computes the circumcentre of a triangle.

    Declaration
    public static Coordinate Circumcentre(Coordinate a, Coordinate b, Coordinate c)
    Parameters
    Type Name Description
    Coordinate a

    A vertex of the triangle

    Coordinate b

    A vertex of the triangle

    Coordinate c

    A vertex of the triangle

    Returns
    Type Description
    Coordinate

    The circumcentre of the triangle

    Remarks

    The circumcentre is the centre of the circumcircle, the smallest circle which encloses the triangle. It is also the common intersection point of the perpendicular bisectors of the sides of the triangle, and is the only point which has equal distance to all three vertices of the triangle.

    The circumcentre does not necessarily lie within the triangle. For example, the circumcentre of an obtuse isosceles triangle lies outside the triangle.

    This method uses an algorithm due to J.R.Shewchuk which uses normalization to the origin to improve the accuracy of computation. (See Lecture Notes on Geometric Robustness, Jonathan Richard Shewchuk, 1999).

    | Edit this page View Source

    CircumcentreDD(Coordinate, Coordinate, Coordinate)

    Computes the circumcentre of a triangle. The circumcentre is the centre of the circumcircle, the smallest circle which encloses the triangle.It is also the common intersection point of the perpendicular bisectors of the sides of the triangle, and is the only point which has equal distance to all three vertices of the triangle.

    The circumcentre does not necessarily lie within the triangle. For example, the circumcentre of an obtuse isosceles triangle lies outside the triangle.

    This method uses DD extended-precision arithmetic to provide more accurate results than Circumcentre(Coordinate, Coordinate, Coordinate)
    Declaration
    public static Coordinate CircumcentreDD(Coordinate a, Coordinate b, Coordinate c)
    Parameters
    Type Name Description
    Coordinate a

    A vertex of the triangle

    Coordinate b

    A vertex of the triangle

    Coordinate c

    A vertex of the triangle

    Returns
    Type Description
    Coordinate

    The circumcentre of the triangle

    | Edit this page View Source

    Circumradius()

    Computes the radius of the circumcircle of a triangle.

    Declaration
    public double Circumradius()
    Returns
    Type Description
    double

    The triangle circumradius

    | Edit this page View Source

    Circumradius(Coordinate, Coordinate, Coordinate)

    Computes the radius of the circumcircle of a triangle.

    Formula is as per
    Declaration
    public static double Circumradius(Coordinate a, Coordinate b, Coordinate c)
    Parameters
    Type Name Description
    Coordinate a

    A vertex of the triangle

    Coordinate b

    A vertex of the triangle

    Coordinate c

    A vertex of the triangle

    Returns
    Type Description
    double

    The circumradius of the triangle

    | Edit this page View Source

    InCentre()

    Computes the InCentre of this triangle

    Declaration
    public Coordinate InCentre()
    Returns
    Type Description
    Coordinate

    The point which is the InCentre of the triangle.

    Remarks

    The InCentre of a triangle is the point which is equidistant from the sides of the triangle. This is also the point at which the bisectors of the angles meet. It is the centre of the triangle's InCircle, which is the unique circle that is tangent to each of the triangle's three sides.

    | Edit this page View Source

    InCentre(Coordinate, Coordinate, Coordinate)

    Computes the incentre of a triangle.

    Declaration
    public static Coordinate InCentre(Coordinate a, Coordinate b, Coordinate c)
    Parameters
    Type Name Description
    Coordinate a

    A vertex of the triangle

    Coordinate b

    A vertex of the triangle

    Coordinate c

    A vertex of the triangle

    Returns
    Type Description
    Coordinate

    The point which is the incentre of the triangle

    Remarks

    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 triangle's InCircle, which is the unique circle that is tangent to each of the triangle's three sides.

    | Edit this page View Source

    InterpolateZ(Coordinate)

    Computes the Z-value (elevation) of an XY point on a three-dimensional plane defined by this triangle (whose vertices must have Z-values). This triangle must not be degenerate (in other words, the triangle must enclose a non-zero area), and must not be parallel to the Z-axis.

    This method can be used to interpolate the Z-value of a point inside this triangle (for example, of a TIN facet with elevations on the vertices).
    Declaration
    public double InterpolateZ(Coordinate p)
    Parameters
    Type Name Description
    Coordinate p

    The point to compute the Z-value of

    Returns
    Type Description
    double

    The computed Z-value (elevation) of the point

    | Edit this page View Source

    InterpolateZ(Coordinate, Coordinate, Coordinate, Coordinate)

    Computes the Z-value (elevation) of an XY point on a three-dimensional plane defined by a triangle whose vertices have Z-values. The defining triangle must not be degenerate (in other words, the triangle must enclose a non-zero area), and must not be parallel to the Z-axis.

    This method can be used to interpolate the Z-value of a point inside a triangle (for example, of a TIN facet with elevations on the vertices).
    Declaration
    public static double InterpolateZ(Coordinate p, Coordinate v0, Coordinate v1, Coordinate v2)
    Parameters
    Type Name Description
    Coordinate p

    The point to compute the Z-value of

    Coordinate v0

    A vertex of a triangle, with a Z ordinate

    Coordinate v1

    A vertex of a triangle, with a Z ordinate

    Coordinate v2

    A vertex of a triangle, with a Z ordinate

    Returns
    Type Description
    double

    The computed Z-value (elevation) of the point

    | Edit this page View Source

    Intersects(Coordinate, Coordinate, Coordinate, Coordinate)

    Tests whether a triangle intersects a point.

    Declaration
    public static bool Intersects(Coordinate a, Coordinate b, Coordinate c, Coordinate p)
    Parameters
    Type Name Description
    Coordinate a

    A vertex of the triangle

    Coordinate b

    A vertex of the triangle

    Coordinate c

    A vertex of the triangle

    Coordinate p

    The point to test

    Returns
    Type Description
    bool

    true if the triangle intersects the point

    | Edit this page View Source

    IsAcute()

    Tests whether this triangle is acute. A triangle is acute if all interior angles are acute. This is a strict test - right triangles will return false A triangle which is not acute is either right or obtuse.

    Note: this implementation is not robust for angles very close to 90 degrees.
    Declaration
    public bool IsAcute()
    Returns
    Type Description
    bool

    true if this triangle is acute

    | Edit this page View Source

    IsAcute(Coordinate, Coordinate, Coordinate)

    Tests whether a triangle is acute. A triangle is acute if all interior angles are acute. This is a strict test - right triangles will return false A triangle which is not acute is either right or obtuse.

    Note: this implementation is not robust for angles very close to 90 degrees.
    Declaration
    public static bool IsAcute(Coordinate a, Coordinate b, Coordinate c)
    Parameters
    Type Name Description
    Coordinate a

    A vertex of the triangle

    Coordinate b

    A vertex of the triangle

    Coordinate c

    A vertex of the triangle

    Returns
    Type Description
    bool

    True if the triangle is acute.

    | Edit this page View Source

    IsCCW()

    Tests whether this triangle is oriented counter-clockwise.

    Declaration
    public bool IsCCW()
    Returns
    Type Description
    bool

    true if the triangle orientation is counter-clockwise

    | Edit this page View Source

    IsCCW(Coordinate, Coordinate, Coordinate)

    Tests whether a triangle is oriented counter-clockwise.

    Declaration
    public static bool IsCCW(Coordinate a, Coordinate b, Coordinate c)
    Parameters
    Type Name Description
    Coordinate a

    A vertex of the triangle

    Coordinate b

    A vertex of the triangle

    Coordinate c

    A vertex of the triangle

    Returns
    Type Description
    bool

    true if the triangle orientation is counter-clockwise

    | Edit this page View Source

    Length()

    Computes the length of the perimeter of this triangle.

    Declaration
    public double Length()
    Returns
    Type Description
    double

    The length of the perimeter

    | Edit this page View Source

    Length(Coordinate, Coordinate, Coordinate)

    Compute the length of the perimeter of a triangle

    Declaration
    public static double Length(Coordinate a, Coordinate b, Coordinate c)
    Parameters
    Type Name Description
    Coordinate a

    A vertex of the triangle

    Coordinate b

    A vertex of the triangle

    Coordinate c

    A vertex of the triangle

    Returns
    Type Description
    double

    The length of the perimeter of the triangle

    | Edit this page View Source

    LongestSideLength()

    Computes the length of the longest side of this triangle

    Declaration
    public double LongestSideLength()
    Returns
    Type Description
    double

    The length of the longest side of this triangle

    | Edit this page View Source

    LongestSideLength(Coordinate, Coordinate, Coordinate)

    Computes the length of the longest side of a triangle

    Declaration
    public static double LongestSideLength(Coordinate a, Coordinate b, Coordinate c)
    Parameters
    Type Name Description
    Coordinate a

    A vertex of the triangle

    Coordinate b

    A vertex of the triangle

    Coordinate c

    A vertex of the triangle

    Returns
    Type Description
    double

    The length of the longest side of the triangle

    | Edit this page View Source

    PerpendicularBisector(Coordinate, Coordinate)

    Computes the line which is the perpendicular bisector of the

    Declaration
    public static HCoordinate PerpendicularBisector(Coordinate a, Coordinate b)
    Parameters
    Type Name Description
    Coordinate a

    A point

    Coordinate b

    Another point

    Returns
    Type Description
    HCoordinate

    The perpendicular bisector, as an HCoordinate line segment a-b.

    | Edit this page View Source

    SignedArea()

    Computes the signed 2D area of this triangle. The area value is positive if the triangle is oriented CW, and negative if it is oriented CCW.

    The signed area value can be used to determine point orientation, but the implementation in this method is susceptible to round-off errors. Use Index(Coordinate, Coordinate, Coordinate) for robust orientation calculation.
    Declaration
    public double SignedArea()
    Returns
    Type Description
    double

    The signed 2D area of this triangle

    See Also
    Index(Coordinate, Coordinate, Coordinate)
    | Edit this page View Source

    SignedArea(Coordinate, Coordinate, Coordinate)

    Computes the signed 2D area of a triangle.

    Declaration
    public static double SignedArea(Coordinate a, Coordinate b, Coordinate c)
    Parameters
    Type Name Description
    Coordinate a

    A vertex of the triangle

    Coordinate b

    A vertex of the triangle

    Coordinate c

    A vertex of the triangle

    Returns
    Type Description
    double

    The area of the triangle

    Remarks

    The area value is positive if the triangle is oriented CW, and negative if it is oriented CCW.

    The signed area value can be used to determine point orientation, but the implementation in this method is susceptible to round-off errors. Use Index(Coordinate, Coordinate, Coordinate) for robust orientation calculation.

    See Also
    Area(Coordinate, Coordinate, Coordinate)
    Index(Coordinate, Coordinate, Coordinate)
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX