Class Precision
- Namespace
- CADability
- Assembly
- CADability.dll
Precision specifies the order of size of a typical model. For example two points are considered geometrically equal if their distance is less than Precision.eps. Default value for Precision.eps is 1e-6. Precision.epsa is the angular precision. Two directions are considered equal if their angular difference is less than Precision.epsa.
public class Precision
- Inheritance
-
Precision
- Inherited Members
Constructors
Precision()
public Precision()
Properties
eps
The maximum distance for which two points are considered geometrically equal. Setting it changes the value for all threads, a PrecisionOverride changes it only for the thread that creates it.
public static double eps { get; set; }
Property Value
epsa
The maximum difference in radians for two angles to be considered geometrically equal. Setting it changes the value for all threads, a PrecisionOverride changes it only for the thread that creates it.
public static double epsa { get; set; }
Property Value
Methods
IsColinear(GeoPoint2D[])
Determines whether all points lie on a straight line. The points are expected to be ordered from start to end, the line is the connection of the first and the last one.
public static bool IsColinear(GeoPoint2D[] pnts)
Parameters
pntsGeoPoint2D[]the points to test, at least two
Returns
- bool
true, if all points are colinear
IsDirectionInPlane(GeoVector, Plane)
Determines, whether the given vector is in the given plane
public static bool IsDirectionInPlane(GeoVector dir, Plane pl)
Parameters
Returns
- bool
true, if the direction is in the plane
IsEqual(Angle, Angle)
Determines whether the two angles are almost identical, i.e. their difference is less than epsa. The wrap-around at 2pi is taken into account, so an angle slightly below 2pi equals an angle slightly above 0.
public static bool IsEqual(Angle a1, Angle a2)
Parameters
Returns
- bool
true: almost identical, false: different
IsEqual(GeoPoint, GeoPoint)
Determins, whether the given points are almost identical, i.e. the distance of the points is less than eps.
public static bool IsEqual(GeoPoint p1, GeoPoint p2)
Parameters
Returns
- bool
true: almost identical, false: different
IsEqual(GeoPoint, params GeoPoint[])
Returns true if the distance of each point from p to c is less than eps.
public static bool IsEqual(GeoPoint c, params GeoPoint[] p)
Parameters
Returns
- bool
true if all points are close, false otherwise
IsEqual(GeoPoint2D, GeoPoint2D)
Determines whether the given 2d points are almost identical, i.e. the distance of the points is less than eps.
public static bool IsEqual(GeoPoint2D p1, GeoPoint2D p2)
Parameters
p1GeoPoint2Dfirst point
p2GeoPoint2Dsecond point
Returns
- bool
true: almost identical, false: different
IsEqual(GeoPoint2D, params GeoPoint2D[])
Returns true if the distance of each point from p to c is less than eps.
public static bool IsEqual(GeoPoint2D c, params GeoPoint2D[] p)
Parameters
cGeoPoint2Dthe center to test to
pGeoPoint2D[]points to test
Returns
- bool
true if all points are close, false otherwise
IsEqual(GeoPoint[])
Determines whether all points are almost identical: each point must be within eps of its successor in the array. Returns true for an empty array or a single point.
public static bool IsEqual(GeoPoint[] pnts)
Parameters
pntsGeoPoint[]the points to test
Returns
- bool
true: all points coincide, false: two consecutive points are further apart than eps
IsEqual(GeoVector, GeoVector)
Determines whether the two vectors are almost identical, i.e. the sum of the absolute differences of their components is less than eps. Unlike SameDirection(GeoVector, GeoVector, bool) this compares the vectors themselves including their lengths, not only their directions.
public static bool IsEqual(GeoVector v1, GeoVector v2)
Parameters
Returns
- bool
true: almost identical, false: different
IsEqual(GeoVector2D, GeoVector2D)
Determines whether the two 2d vectors are almost identical, i.e. the sum of the absolute differences of their components is less than eps. Unlike SameDirection(GeoVector2D, GeoVector2D, bool) this compares the vectors themselves including their lengths, not only their directions.
public static bool IsEqual(GeoVector2D v1, GeoVector2D v2)
Parameters
v1GeoVector2Dfirst vector
v2GeoVector2Dsecond vector
Returns
- bool
true: almost identical, false: different
IsEqual(Plane, Plane)
Determins, whether the two planes are almost identical, i.e. the angular difference is less than epsa and the distance of then location of p2 to the plane p1 is less than eps. The DirectionX, DirectionY and Location properties of the two planes may be completely different, the two coordinate systems of the planes may be different.
public static bool IsEqual(Plane p1, Plane p2)
Parameters
Returns
IsEqual(double, double)
Determines whether the two values are almost identical, i.e. their difference is less than eps. Intended for lengths and coordinates; for angles use IsEqual(Angle, Angle), which compares with epsa.
public static bool IsEqual(double d1, double d2)
Parameters
Returns
- bool
true: almost identical, false: different
IsNormedVector(GeoVector)
Determines whether the vector is almost normalized, i.e. its length differs from 1.0 by less than eps.
public static bool IsNormedVector(GeoVector v)
Parameters
vGeoVectorthe vector to test
Returns
- bool
true if the length is almost 1.0, false otherwise
IsNull(Angle)
Determines whether the angle is almost 0, i.e. its value is less than epsa. Since an Angle is always in the range [0, 2pi), an angle slightly below 2pi is not considered null; use IsEqual(Angle, Angle) with 0.0 when that case matters.
public static bool IsNull(Angle a)
Parameters
aAnglethe angle to test
Returns
- bool
true if almost 0, false otherwise
IsNull(SweepAngle)
Determines whether the sweep angle is almost 0, i.e. its absolute value is less than epsa.
public static bool IsNull(SweepAngle sw)
Parameters
swSweepAnglethe sweep angle to test
Returns
- bool
true if almost 0, false otherwise
IsNull(double)
Determines whether the value is almost 0, i.e. its absolute value is less than eps. Intended for lengths and coordinates; for angles use IsNull(Angle) or IsNull(SweepAngle).
public static bool IsNull(double l)
Parameters
ldoublethe value to test
Returns
- bool
true if almost 0, false otherwise
IsNullVector(GeoVector)
Determins, whether the length of the given vector is almost 0, i.e. the length is less than eps
public static bool IsNullVector(GeoVector v)
Parameters
vGeoVectorthe vector to test
Returns
- bool
true if null-vector, false otherwise
IsNullVector(GeoVector2D)
Determines whether the length of the given 2d vector is almost 0, i.e. the length is less than eps.
public static bool IsNullVector(GeoVector2D v)
Parameters
vGeoVector2Dthe vector to test
Returns
- bool
true if null-vector, false otherwise
IsPerpendicular(GeoVector, GeoVector, bool)
Determines whether the two vectors are almost perpendicular, i.e. the cosine of the angle between them is less than epsa. Returns true if one of the vectors is shorter than eps, because a nullvector has no direction.
public static bool IsPerpendicular(GeoVector v1, GeoVector v2, bool VectorsAreNormalized)
Parameters
v1GeoVectorfirst vector
v2GeoVectorsecond vector
VectorsAreNormalizedboolnot used, the vectors are normalized internally
Returns
- bool
true: perpendicular, false: not perpendicular
IsPerpendicular(GeoVector2D, GeoVector2D, bool)
Determines whether the two 2d vectors are almost perpendicular, i.e. the cosine of the angle between them is less than epsa. Returns true if one of the vectors is shorter than eps, because a nullvector has no direction.
public static bool IsPerpendicular(GeoVector2D v1, GeoVector2D v2, bool VectorsAreNormalized)
Parameters
v1GeoVector2Dfirst vector
v2GeoVector2Dsecond vector
VectorsAreNormalizedboolnot used, the vectors are normalized internally
Returns
- bool
true: perpendicular, false: not perpendicular
IsPointOnAxis(GeoPoint, Axis)
Determines whether the point lies on the (infinite) axis, i.e. its distance to the axis is below eps.
public static bool IsPointOnAxis(GeoPoint testPoint, Axis axis)
Parameters
Returns
IsPointOnLine(GeoPoint, GeoPoint, GeoPoint)
Determines whether the point lies on the line segment from startPoint to
endPoint: its distance to the line must be less than eps and it must lie between
the two end points (within eps). Points on the extension of the segment are not on the line; use
IsPointOnAxis(GeoPoint, Axis) for the infinite line.
public static bool IsPointOnLine(GeoPoint testPoint, GeoPoint startPoint, GeoPoint endPoint)
Parameters
testPointGeoPointthe point to test
startPointGeoPointstart point of the segment
endPointGeoPointend point of the segment
Returns
- bool
true, if the point is on the segment
IsPointOnLine(GeoPoint2D, GeoPoint2D, GeoPoint2D)
Determines whether the 2d point lies on the line segment from startPoint to
endPoint: its distance to the line must be less than eps and it must lie between
the two end points (within eps). Points on the extension of the segment are not on the line.
public static bool IsPointOnLine(GeoPoint2D testPoint, GeoPoint2D startPoint, GeoPoint2D endPoint)
Parameters
testPointGeoPoint2Dthe point to test
startPointGeoPoint2Dstart point of the segment
endPointGeoPoint2Dend point of the segment
Returns
- bool
true, if the point is on the segment
IsPointOnPlane(GeoPoint, Plane)
Determins, whether the 3D point is on the plane. This is true when either the distance of the point to the plane is less than eps, or the elevation of the vector from the location of the plane to the point is less than epsa
public static bool IsPointOnPlane(GeoPoint p, Plane pl)
Parameters
Returns
- bool
true, if the point is on the plane
OppositeDirection(GeoVector, GeoVector)
Determines whether the two vectors point in opposite directions: they must be parallel within epsa and have opposite orientation. Same as SameNotOppositeDirection(GeoVector, GeoVector) with the second vector reversed.
public static bool OppositeDirection(GeoVector v1, GeoVector v2)
Parameters
Returns
- bool
true: opposite directions, false otherwise
OppositeDirection(GeoVector2D, GeoVector2D)
Determines whether the two 2d vectors point in opposite directions: they must be parallel within epsa and have opposite orientation. Same as SameNotOppositeDirection(GeoVector2D, GeoVector2D, bool) with the second vector reversed.
public static bool OppositeDirection(GeoVector2D v1, GeoVector2D v2)
Parameters
v1GeoVector2Dfirst vector
v2GeoVector2Dsecond vector
Returns
- bool
true: opposite directions, false otherwise
SameAxis(Axis, Axis)
Determines whether the two axes describe the same infinite line: the location of each axis lies on the other axis within eps and the directions are parallel within epsa. Opposite orientations count as the same axis. Like SameGeometry(Axis), but tests both locations.
public static bool SameAxis(Axis a1, Axis a2)
Parameters
Returns
- bool
true, if both axes are the same line
SameDirection(GeoVector, GeoVector, bool)
Determins, whether the directions of the given vectors are almost identical, i.e. the angular difference is less than epsa. This is also true for opposite directions.
public static bool SameDirection(GeoVector v1, GeoVector v2, bool VectorsAreNormalized)
Parameters
v1GeoVectorfirst vector
v2GeoVectorsecond vector
VectorsAreNormalizedbooltrue, if the vectors are already normalized, false if not or unknown
Returns
- bool
true: almost same direction, false: different directions
SameDirection(GeoVector2D, GeoVector2D, bool)
Determins, whether the directions of the given vectors are almost identical, i.e. the angular difference is less than epsa.
public static bool SameDirection(GeoVector2D v1, GeoVector2D v2, bool VectorsAreNormalized)
Parameters
v1GeoVector2Dfirst vector
v2GeoVector2Dsecond vector
VectorsAreNormalizedbooltrue, if the vectors are already normalized, false if not or unknown
Returns
- bool
true: almost same direction, false: different directions
SameNotOppositeDirection(GeoVector, GeoVector)
Determines whether the two vectors point in the same direction: they must be parallel within epsa and have the same orientation. SameDirection(GeoVector, GeoVector, bool) in contrast also accepts opposite vectors. The lengths of the vectors do not matter; the result is false if one of them is the nullvector.
public static bool SameNotOppositeDirection(GeoVector v1, GeoVector v2)
Parameters
Returns
- bool
true: same direction and orientation, false otherwise
SameNotOppositeDirection(GeoVector2D, GeoVector2D, bool)
Determines whether the two 2d vectors point in the same direction with the same orientation: their angles (see Angle) differ by less than epsa. SameDirection(GeoVector2D, GeoVector2D, bool) in contrast also accepts opposite vectors.
public static bool SameNotOppositeDirection(GeoVector2D v1, GeoVector2D v2, bool VectorsAreNormalized)
Parameters
v1GeoVector2Dfirst vector
v2GeoVector2Dsecond vector
VectorsAreNormalizedboolnot used, the lengths of the vectors do not matter
Returns
- bool
true: same direction and orientation, false otherwise
SetFromModel(Model)
Intended to derive eps from the size of a model. Not implemented: the call has no effect, the precision values stay as they are.
public static void SetFromModel(Model m)
Parameters
mModelthe model, not used