Skip to content

Overview

This is the documentation for the Double Precision Maths Library - a library of code for users of the Unity game engine.

The library is designed to offer classes that are instantly familiar to Unity users, as each class in this library has a corresponding equivalent class in the core UnityEngine API. However, the crucial difference is that while the Unity classes are built using single precision floating-point numbers, this library provides those same classes with double precision floating point numbers.

The classes provided by this library are:

Purpose Of This Package

Compared to the C# float type, the double type allows for calculations to be made with greater precision, and reduces the potential impact of floating-point rounding errors in long calculations.

For example, when simulating the orbital mechanics of the solar system you might have a satellite that is hundreds of millions of metres away from the Sun, but you would still like to know its location down to the centimetre. Single precision floats will struggle in this scenario without workarounds, while double precision floats will happily cover the extreme range of values.

This of course comes at the cost of some speed and doubled memory usage.

Installation

The package may installed from the Unity Asset Store for $5.

Style Of This Documentation

The classes of this library are intended to match their Unity equivalents as closely as possible. Because of this, the documentation provided by Unity can largely serve as the documentation for this library.

However, there are cases where the interfaces don't match. For example, there may be small differences in convention when returning values from some methods, or there are some methods which are simply not implemented by this library. This documentation seeks only to record those differences, no matter how big or small.

In general, methods were not implemented for one of two reasons:

  1. A double precision version of a method seemed to offer little practical benefit.
  2. I was unable to recreate the equivalent Unity method with enough accuracy.

If there is an unimplemented method that you wish was included, or you find a difference between the implementations that isn't recorded here, please get in touch and I can look into it!

Contact

RobboCode@pm.me