C# Class TriangleNet.Primitives

Provides some primitives regularly used in computational geometry.
Mostrar archivo Open project: RegrowthStudios/VoxelRTS Class Usage Examples

Public Methods

Method Description
CounterClockwise ( System.Point pa, System.Point pb, System.Point pc ) : double

Check, if the three points appear in counterclockwise order. The result is also a rough approximation of twice the signed area of the triangle defined by the three points.

Uses exact arithmetic if necessary to ensure a correct answer. The result returned is the determinant of a matrix. This determinant is computed adaptively, in the sense that exact arithmetic is used only to the degree it is needed to ensure that the returned value has the correct sign. Hence, this function is usually quite fast, but will run more slowly when the input points are collinear or nearly so. See Robust Predicates paper for details.

ExactInit ( ) : void

Initialize the variables used for exact arithmetic.

'epsilon' is the largest power of two such that 1.0 + epsilon = 1.0 in floating-point arithmetic. 'epsilon' bounds the relative roundoff error. It is used for floating-point error analysis. 'splitter' is used to split floating-point numbers into two half- length significands for exact multiplication. I imagine that a highly optimizing compiler might be too smart for its own good, and somehow cause this routine to fail, if it pretends that floating-point arithmetic is too much like real arithmetic. Don't change this routine unless you fully understand it.

FindCircumcenter ( System.Point torg, System.Point tdest, System.Point tapex, double &xi, double &eta ) : System.Point

Find the circumcenter of a triangle.

The result is returned both in terms of x-y coordinates and xi-eta (barycentric) coordinates. The xi-eta coordinate system is defined in terms of the triangle: the origin of the triangle is the origin of the coordinate system; the destination of the triangle is one unit along the xi axis; and the apex of the triangle is one unit along the eta axis. This procedure also returns the square of the length of the triangle's shortest edge.

FindCircumcenter ( System.Point torg, System.Point tdest, System.Point tapex, double &xi, double &eta, double offconstant ) : System.Point

Find the circumcenter of a triangle.

InCircle ( System.Point pa, System.Point pb, System.Point pc, System.Point pd ) : double

Check if the point pd lies inside the circle passing through pa, pb, and pc. The points pa, pb, and pc must be in counterclockwise order, or the sign of the result will be reversed.

Uses exact arithmetic if necessary to ensure a correct answer. The result returned is the determinant of a matrix. This determinant is computed adaptively, in the sense that exact arithmetic is used only to the degree it is needed to ensure that the returned value has the correct sign. Hence, this function is usually quite fast, but will run more slowly when the input points are cocircular or nearly so. See Robust Predicates paper for details.

NonRegular ( System.Point pa, System.Point pb, System.Point pc, System.Point pd ) : double

Return a positive value if the point pd is incompatible with the circle or plane passing through pa, pb, and pc (meaning that pd is inside the circle or below the plane); a negative value if it is compatible; and zero if the four points are cocircular/coplanar. The points pa, pb, and pc must be in counterclockwise order, or the sign of the result will be reversed.

Private Methods

Method Description
CounterClockwiseDecimal ( System.Point pa, System.Point pb, System.Point pc ) : decimal
InCircleDecimal ( System.Point pa, System.Point pb, System.Point pc, System.Point pd ) : decimal

Method Details

CounterClockwise() public static method

Check, if the three points appear in counterclockwise order. The result is also a rough approximation of twice the signed area of the triangle defined by the three points.
Uses exact arithmetic if necessary to ensure a correct answer. The result returned is the determinant of a matrix. This determinant is computed adaptively, in the sense that exact arithmetic is used only to the degree it is needed to ensure that the returned value has the correct sign. Hence, this function is usually quite fast, but will run more slowly when the input points are collinear or nearly so. See Robust Predicates paper for details.
public static CounterClockwise ( System.Point pa, System.Point pb, System.Point pc ) : double
pa System.Point Point a.
pb System.Point Point b.
pc System.Point Point c.
return double

ExactInit() public static method

Initialize the variables used for exact arithmetic.
'epsilon' is the largest power of two such that 1.0 + epsilon = 1.0 in floating-point arithmetic. 'epsilon' bounds the relative roundoff error. It is used for floating-point error analysis. 'splitter' is used to split floating-point numbers into two half- length significands for exact multiplication. I imagine that a highly optimizing compiler might be too smart for its own good, and somehow cause this routine to fail, if it pretends that floating-point arithmetic is too much like real arithmetic. Don't change this routine unless you fully understand it.
public static ExactInit ( ) : void
return void

FindCircumcenter() public static method

Find the circumcenter of a triangle.
The result is returned both in terms of x-y coordinates and xi-eta (barycentric) coordinates. The xi-eta coordinate system is defined in terms of the triangle: the origin of the triangle is the origin of the coordinate system; the destination of the triangle is one unit along the xi axis; and the apex of the triangle is one unit along the eta axis. This procedure also returns the square of the length of the triangle's shortest edge.
public static FindCircumcenter ( System.Point torg, System.Point tdest, System.Point tapex, double &xi, double &eta ) : System.Point
torg System.Point Triangle point.
tdest System.Point Triangle point.
tapex System.Point Triangle point.
xi double Relative coordinate of new location.
eta double Relative coordinate of new location.
return System.Point

FindCircumcenter() public static method

Find the circumcenter of a triangle.
public static FindCircumcenter ( System.Point torg, System.Point tdest, System.Point tapex, double &xi, double &eta, double offconstant ) : System.Point
torg System.Point Triangle point.
tdest System.Point Triangle point.
tapex System.Point Triangle point.
xi double Relative coordinate of new location.
eta double Relative coordinate of new location.
offconstant double Off-center constant.
return System.Point

InCircle() public static method

Check if the point pd lies inside the circle passing through pa, pb, and pc. The points pa, pb, and pc must be in counterclockwise order, or the sign of the result will be reversed.
Uses exact arithmetic if necessary to ensure a correct answer. The result returned is the determinant of a matrix. This determinant is computed adaptively, in the sense that exact arithmetic is used only to the degree it is needed to ensure that the returned value has the correct sign. Hence, this function is usually quite fast, but will run more slowly when the input points are cocircular or nearly so. See Robust Predicates paper for details.
public static InCircle ( System.Point pa, System.Point pb, System.Point pc, System.Point pd ) : double
pa System.Point Point a.
pb System.Point Point b.
pc System.Point Point c.
pd System.Point Point d.
return double

NonRegular() public static method

Return a positive value if the point pd is incompatible with the circle or plane passing through pa, pb, and pc (meaning that pd is inside the circle or below the plane); a negative value if it is compatible; and zero if the four points are cocircular/coplanar. The points pa, pb, and pc must be in counterclockwise order, or the sign of the result will be reversed.
public static NonRegular ( System.Point pa, System.Point pb, System.Point pc, System.Point pd ) : double
pa System.Point Point a.
pb System.Point Point b.
pc System.Point Point c.
pd System.Point Point d.
return double