**Namespace:**
ceometric.VectorGeometry

**Assembly:**
ceometric.VectorGeometry (in ceometric.VectorGeometry.dll) Version: 1.8.0.0 (1.8.0.0)

# Syntax

C# |
---|

public struct Global |

Visual Basic (Declaration) |
---|

Public Structure Global |

Visual C++ |
---|

public value class Global |

# Remarks

- finite precision
- round off errors

public void TestPlaneContainsPoint() { Global.AbsoluteEpsilon = 0; // set all error bound to zero to Global.RelativeEpsilon = 0; // enforce exact comparison Global.MaxRandom = 1e0; // produce random values between [0...1] int err = 0; int n = 100000 for ( int i = n; i > 0; i-- ) { Plane pl = Plane.RandomPlane(); Point p = pl.RandomPointOnPlane(); // this point should always lie on the plane! if ( !pl.Contains(p) ) err++; } Console.WriteLine(err + " of " + n + " tests failed!"); }

This library addresses this problem in three ways by

- implementing robust algorithms
- normalizing data when advantageous
- implementing an absolute AND a relative delta comparison

The absolute delta comparison has the form Math.Abs(a - b) > AbsoluteEpsilon

The relative delta comparison has the form

Math.Abs((a - b) / a) > RelativeEpsilon for a > b

or

Math.Abs((a - b) / b) > RelativeEpsilon else.Let's give TestPlaneContainsPoint a second chance:

... Global.AbsoluteEpsilon = 1e-12; Global.RelativeEpsilon = 0; // set this value zero for absolute epsilon comparison only! Global.MaxRandom = 1e0; // produce random values between [0...1] ...

... Global.AbsoluteEpsilon = 1e-12; Global.RelativeEpsilon = 0; // set this value zero for absolute epsilon comparison only! Global.MaxRandom = 1e9; // produce random values between [0...1000000000] ...

... Global.AbsoluteEpsilon = 1e-12; Global.RelativeEpsilon = 1e-12; Global.MaxRandom = 1e9; // produce random values between [0...1000000000] ...

**The AlmostEquals method**

In your own computations, you can easily benefit from the absolute and relative comparison concept of this library. When comparing two double precision values a and b, write

```
...
if (Global.AlmostEquals(a, b)) ...
...
```

```
...
if (a == b) ...
...
```