Skip to content

carnegie/vizlab-units

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Units

Dependencies

None!

How to use

You can use the Units static class to access any explicitly defined units:

Units.m;
Units.J;
// so on and so forth..

You can apply prefixes to any unit using standard operators for multiplication and division:

var km = Prefixes.k * Units.m // equals Units.km

You can also build complex units with the same rules:

var spectralUnit = (Prefixes.G*Units.yr)^1.5 // equals Gyr**(3/2)     

Finally, you are able to parse out FITS-standard units strings into the units system:

    var fitsString = "m";
    var tokens = FITSUnitTokenizer.Tokenize(fitsString);
    var parser = new UnitParser(tokens);
    ASTNode<Unit> node = parser.Parse();
    var unit = node.Evaluate();

About

Unity package containing a flexible AST-based units implementation for FITS files

Resources

License

Stars

Watchers

Forks