Code Monkey home page Code Monkey logo

abacus's Introduction

Abacus

Build Status License Nuget Version Chat

Overview

Abacus is a zero-dependency cross-precision 3D maths library for .NET, Mono and .NET Core, built with a primary focus on performance and efficiency. Abacus is ideal for use developing real-time 3D applications and deterministic network simulations.

Documentation for Abacus can be found here.

Why?

Microsoft's XNA was a popular framework for building games and 3D applications using C#; part of the framework consisted of an excellent maths library for use with floating point numbers.

On a number of occasions I found myself wanting to use XNA's maths library in C# projects of my own, yet I didn't want to be tied to the prerequisites imposed by XNA. I also wanted the ability to use the same set of functionality with with differing levels of precision, i.e. a library that would expose the same API for working with 32-bit floating point numbers as it did for working with 64-bit floating point numbers and even 64-bit fixed point numbers.

Abacus aims to provide all of the features of the XNA maths library whilst also supporting multiple levels of precision.

Getting started

Abacus is available as a stand-alone library via nuget. Here's an example nuget packages.config file that pulls in Abacus:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Abacus" version="0.9.2"/>
</packages>

Alternatively, as all code associated with each of Abacus' supported levels of precision gets generated into a single C# source file, it is easy to simply copy the appropriate Abacus.XYZ.cs file for the precision you need straight into your project.

So, what types are actually supported?

Abacus provides implementations of the following data types:

  • Vector2
  • Vector3
  • Vector4
  • Matrix44
  • Quaternion

consistently across the following precisions:

  • Single (float)
  • Double (double)
  • Fixed32 (proof of concept)

Status

Is Abacus ready to be used? Yes indeed.

Abacus currently runs 638 unit tests with each build and has complete test coverage over both 32-bit and 64-bit floating point precision (float and double).

One goal of the project is for Abacus to consistently support mathematical operations and data types for more than just float and double precision numbers. Abacus is being built to provide it's own implementations for various fixed point number formats and additional floating point number formats:

  • Fixed32
  • Fixed64
  • Fixed128
  • Half
  • Quadruple

Currently full support for these types with full unit test coverage is the next step on the roadmap.

At this stage a working Fixed32 type is provided as a proof of concept, however, the unit tests associated with the type are currently disabled as in their present form they do not .

Example usage

/**
 * Choose which level of precision to use simply by
 * commenting out all but the appropriate 'using'
 * statement:
 */

// using Abacus.SinglePrecision;
using Abacus.DoublePrecision;
// using Abacus.Fixed32Precision;

class Program
{
    public static void Main (string[] args)
    {
        var a = new Vector2 (-100, +50);
        var b = new Vector2 (+90, -70);

        var c = new Vector2 (-20, +5);
        var d = new Vector2 (+30, -5);
        
        Vector2 result;
        double amount = 0.4;
        
        Vector2.CatmullRom (ref a, ref b, ref c, ref d, ref amount, out result);
        
        System.Console.WriteLine ("result: " + result);
    }
}

Roadmap

This roadmap gives some insight into what's next for the project. We'd like to spend more time working on this project and get Abacus to version 1.6.x; if this is something you'd like to see happen too please show your support for the project by giving it a Github star and let us know on Gitter.

Version 0.9.x [COMPLETE]

MVP release.

  • Full support for float and double.
  • Full test coverage.
  • Proof of concept - Fixed 32 bit precision number data type (Fixed32).

Version 1.0.x

Full, tested support for a single fixed point real number.

  • Finalised Fixed 32 bit precision number data type (Fixed32).
  • Full unit test coverage configured with appropriate margins of error.

Version 1.2.x

New data types

  • Plane type (Plane).
  • Ray type (Ray).
  • Full unit test coverage.

Version 1.3.x

New 3D bounding data types.

  • Box type (Box).
  • Sphere type (Sphere).
  • Frustum type (Frustum).
  • Full unit test coverage.

Version 1.4.x

New 2D bounding data types.

  • Triangle type (Triangle).
  • Quad type (Quad).
  • Full unit test coverage.

Version 1.5.x

Increased support for fixed point.

  • Fixed 64 bit precision number data type (Fixed64).
  • Fixed 128 bit precision number data type (Fixed128).
  • Full unit test coverage configured with appropriate margins of error.

Version 1.6.x

Additional support for floating point.

  • Half precision floating point number data type (Float16).
  • Quadruple precision floating point number data type (Float128).
  • Full unit test coverage configured with appropriate margins of error.

Technical Details

Authoring a consistent API for Abacus across multiple levels of precision presents techinical challenge because the C# language has limited support for experessing constraints for generics; for this reason Abacus has been built using a templatization mechanism to ensure a consitent API across precisions, this can be a little cumbersome to work with from an author's perspective, however, as a user it works well and brings the added benefit that the entire libary is generated into a small set of files (one for each level of precision), making Abacus easy to embed into any C# project.

Contributing

If you find a bug or have an issue please reach out via the GitHub Issue tracking system. If you are using Abacus in a project of you own please show your support and let us know on Gitter.

About the name

Abacus is named after a maths library that Ash worked with in the past when he was a programmer at Black Rock Studio.

License

Abacus is licensed under the MIT License; you may not use this software except in compliance with the License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

abacus's People

Contributors

sungiant avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.