GithubHelp home page GithubHelp logo

pedro-borges / unified-world-units Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 1.33 MB

A generic library of world units.

License: Apache License 2.0

Kotlin 100.00%
java units type-safe physics finance si imperial generic-library

unified-world-units's Introduction

units

A generic library of world units for type-safe calculation of amounts.

Work in progress since Oct 2017. Fully functional but not ready for use in production.

Use at own risk, contribute at own heart.

Quick example:

Length distance = new Meters(10, Magnitude.KILO);
Time duration = new Hours(2);
Speed speed = distance.div(duration, MathContext.UNLIMITED);
Pace pace = duration.div(distance, MathContext.UNLIMITED);

System.out.println(speed.getAmount() + " " + speed.getUnit());
System.out.println(pace.getAmount() + " " + pace.getUnit());

5000 h⁻¹⋅m

0.0002 h⋅m⁻¹

Soon to be:

 Length distance = new Meters(10, Magnitude.KILO);
 Time duration = new Hours(2);
 Speed speed = distance.div(duration);
 Pace pace = duration.div(distance);
 
 System.out.println(speed.getAmount(MathContext.UNLIMITED) + " " + speed.getUnit());
 System.out.println(pace.getAmount(MathContext.UNLIMITED) + " " + pace.getUnit());

unified-world-units's People

Contributors

pedro-borges avatar

Stargazers

 avatar  avatar

Watchers

 avatar

unified-world-units's Issues

Make amounts generic again

  • Make Amount a generic interface for algebraic calculations
  • Move back Amount implementation to BigDecimalAmount

Create ComposedUnit that implements Unit

Make use of the ObjectCounter to track the order of individual units in a formula.

For example:

speed = space / time:
ObjectCounter {
    space = +1
    time = -1
}
acceleration = space / time^2:
ObjectCounter {
    space = +1
    time = -2
}

Add Energy

And then there was light! oh wait that's a different ticket

Implement abstract composition

The api should allow the user to navigate between unnamed composite units, just because meter * second * volt doesn't make apparent sense that doesn't make it less a unit.

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.