Search Results for

    Show / Hide Table of Contents

    Class AngleUtility

    Utility functions for working with angles. Unless otherwise noted, methods in this class express angles in radians.

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

    Fields

    | Edit this page View Source

    PiOver2

    Value of Pi / 2

    Declaration
    public const double PiOver2 = 1.5707963267948966
    Field Value
    Type Description
    double
    | Edit this page View Source

    PiOver4

    Value of Pi / 4

    Declaration
    public const double PiOver4 = 0.7853981633974483
    Field Value
    Type Description
    double
    | Edit this page View Source

    PiTimes2

    Value of 2 * Pi

    Declaration
    public const double PiTimes2 = 6.283185307179586
    Field Value
    Type Description
    double

    Methods

    | Edit this page View Source

    Angle(Coordinate)

    Returns the angle of the vector from (0,0) to p, relative to the positive X-axis.

    Declaration
    public static double Angle(Coordinate p)
    Parameters
    Type Name Description
    Coordinate p

    The terminal point of the vector.

    Returns
    Type Description
    double

    The normalized angle (in radians) that (0,0)-p makes with the positive X-axis.

    Remarks

    The angle is normalized to be in the range ( -Pi, Pi ].

    | Edit this page View Source

    Angle(Coordinate, Coordinate)

    Returns the angle of the vector from p0 to p1, relative to the positive X-axis.

    Declaration
    public static double Angle(Coordinate p0, Coordinate p1)
    Parameters
    Type Name Description
    Coordinate p0

    The initial point of the vector.

    Coordinate p1

    The terminal point of the vector.

    Returns
    Type Description
    double

    The normalized angle (in radians) that p0-p1 makes with the positive X-axis

    Remarks

    The angle is normalized to be in the range [ -Pi, Pi ].

    | Edit this page View Source

    AngleBetween(Coordinate, Coordinate, Coordinate)

    Returns the unoriented smallest angle between two vectors.

    Declaration
    public static double AngleBetween(Coordinate tip1, Coordinate tail, Coordinate tip2)
    Parameters
    Type Name Description
    Coordinate tip1

    The tip of one vector

    Coordinate tail

    The tail of each vector

    Coordinate tip2

    The tip of the other vector

    Returns
    Type Description
    double
    Remarks

    The computed angle will be in the range [0, Pi).

    | Edit this page View Source

    AngleBetweenOriented(Coordinate, Coordinate, Coordinate)

    Returns the oriented smallest angle between two vectors. The computed angle will be in the range (-Pi, Pi]. A positive result corresponds to a CounterClockwise rotation (CCW) from v1 to v2; a negative result corresponds to a Clockwise (CW) rotation; a zero result corresponds to no rotation.

    Declaration
    public static double AngleBetweenOriented(Coordinate tip1, Coordinate tail, Coordinate tip2)
    Parameters
    Type Name Description
    Coordinate tip1

    The tip of v1

    Coordinate tail

    The tail of each vector

    Coordinate tip2

    The tip of v2

    Returns
    Type Description
    double

    The angle between v1 and v2, relative to v1

    | Edit this page View Source

    Bisector(Coordinate, Coordinate, Coordinate)

    Computes the angle of the unoriented bisector of the smallest angle between two vectors.

    Declaration
    public static double Bisector(Coordinate tip1, Coordinate tail, Coordinate tip2)
    Parameters
    Type Name Description
    Coordinate tip1

    The tip of v1

    Coordinate tail

    The tail of each vector

    Coordinate tip2

    The tip of v2

    Returns
    Type Description
    double

    The angle of the bisector between v1 and v2

    Remarks

    The computed angle will be in the range (-Pi, Pi].

    | Edit this page View Source

    CosSnap(double)

    Computes Math.Cos of an angle, snapping near-zero values to zero.

    Declaration
    public static double CosSnap(double ang)
    Parameters
    Type Name Description
    double ang

    The input angle (in radians)

    Returns
    Type Description
    double

    The result of the trigonometric function

    | Edit this page View Source

    Diff(double, double)

    Computes the unoriented smallest difference between two angles.

    Declaration
    public static double Diff(double ang1, double ang2)
    Parameters
    Type Name Description
    double ang1

    The angle of one vector (in [-Pi, Pi] )

    double ang2

    The angle of the other vector (in range [-Pi, Pi] )

    Returns
    Type Description
    double

    The angle (in radians) between the two vectors (in range [0, Pi] )

    Remarks
    • The angles are assumed to be normalized to the range [-Pi, Pi].
    • The result will be in the range [0, Pi].
    | Edit this page View Source

    GetTurn(double, double)

    Returns whether an angle must turn clockwise or counterclockwise to overlap another angle.

    Declaration
    public static OrientationIndex GetTurn(double ang1, double ang2)
    Parameters
    Type Name Description
    double ang1

    An angle (in radians)

    double ang2

    An angle (in radians)

    Returns
    Type Description
    OrientationIndex

    Whether a1 must turn Clockwise, CounterClockwise or None to overlap a2.

    | Edit this page View Source

    InteriorAngle(Coordinate, Coordinate, Coordinate)

    Computes the interior angle between two segments of a ring. The ring is assumed to be oriented in a clockwise direction.

    Declaration
    public static double InteriorAngle(Coordinate p0, Coordinate p1, Coordinate p2)
    Parameters
    Type Name Description
    Coordinate p0

    A point of the ring

    Coordinate p1

    The next point of the ring

    Coordinate p2

    The next point of the ring

    Returns
    Type Description
    double

    The interior angle based at p1

    Remarks

    The computed angle will be in the range [0, 2Pi]

    | Edit this page View Source

    IsAcute(Coordinate, Coordinate, Coordinate)

    Tests whether the angle between p0-p1-p2 is acute.

    Declaration
    public static bool IsAcute(Coordinate p0, Coordinate p1, Coordinate p2)
    Parameters
    Type Name Description
    Coordinate p0

    An endpoint of the angle

    Coordinate p1

    The base of the angle

    Coordinate p2

    Another endpoint of the angle

    Returns
    Type Description
    bool

    true if the angle is acute.

    Remarks

    An angle is acute if it is less than 90 degrees.

    Note: this implementation is not precise (deterministic) for angles very close to 90 degrees.

    | Edit this page View Source

    IsObtuse(Coordinate, Coordinate, Coordinate)

    Tests whether the angle between p0-p1-p2 is obtuse

    Declaration
    public static bool IsObtuse(Coordinate p0, Coordinate p1, Coordinate p2)
    Parameters
    Type Name Description
    Coordinate p0

    An endpoint of the angle

    Coordinate p1

    The base of the angle

    Coordinate p2

    Another endpoint of the angle

    Returns
    Type Description
    bool

    true if the angle is obtuse.

    Remarks

    An angle is obtuse if it is greater than 90 degrees.

    Note: this implementation is not precise (deterministic) for angles very close to 90 degrees.

    | Edit this page View Source

    Normalize(double)

    Computes the normalized value of an angle, which is the equivalent angle in the range ( -Pi, Pi ].

    Declaration
    public static double Normalize(double angle)
    Parameters
    Type Name Description
    double angle

    The angle to normalize

    Returns
    Type Description
    double

    An equivalent angle in the range (-Pi, Pi]

    | Edit this page View Source

    NormalizePositive(double)

    Computes the normalized positive value of an angle, which is the equivalent angle in the range [ 0, 2*Pi ).

    E.g.
    Function callResult
    NormalizePositive(0.0)0.0
    NormalizePositive(-PI)PI
    NormalizePositive(-2PI)0.0
    NormalizePositive(-3PI)PI
    NormalizePositive(-4PI)0.0
    NormalizePositive(PI)PI
    NormalizePositive(2PI)0.0
    NormalizePositive(3PI)PI
    NormalizePositive(4PI)0.0
    Declaration
    public static double NormalizePositive(double angle)
    Parameters
    Type Name Description
    double angle

    The angle to normalize, in radians.

    Returns
    Type Description
    double

    An equivalent positive angle

    | Edit this page View Source

    Project(Coordinate, double, double)

    Projects a point by a given angle and distance.

    Declaration
    public static Coordinate Project(Coordinate p, double angle, double dist)
    Parameters
    Type Name Description
    Coordinate p

    The point to project

    double angle

    The angle at which to project

    double dist

    The distance to project

    Returns
    Type Description
    Coordinate

    The projected point

    | Edit this page View Source

    SinSnap(double)

    Computes Math.Sin of an angle, snapping near-zero values to zero.

    Declaration
    public static double SinSnap(double ang)
    Parameters
    Type Name Description
    double ang

    The input angle (in radians)

    Returns
    Type Description
    double

    The result of the trigonometric function

    | Edit this page View Source

    ToDegrees(double)

    Converts from radians to degrees.

    Declaration
    public static double ToDegrees(double radians)
    Parameters
    Type Name Description
    double radians

    An angle in radians

    Returns
    Type Description
    double

    The angle in degrees

    | Edit this page View Source

    ToRadians(double)

    Converts from degrees to radians.

    Declaration
    public static double ToRadians(double angleDegrees)
    Parameters
    Type Name Description
    double angleDegrees

    An angle in degrees

    Returns
    Type Description
    double

    The angle in radians

    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX