Skip to content

Implement composite units #2

Description

@ronaldtse

A benefit of UnitsML is the dynamic composition of new units based on root units.

This functionality is implemented in https://github.com/plurimath/asciimath2unitsml already as described by unitsml/unitsdb#27 (comment) .

e.g. To support AsciiUnits syntax:

unitsml(
  composite: watt * meter^-1 * steradian^-1, 
  quantity: radiance
)

We need to be able to do such composition in Ruby like:

Unitsml::Unit.new(
  units: [
  {
    unit: Unitsml::Unit::Watt,
    power: 1
  },
  {
    unit: Unitsml::Unit::Meter,
    power: -1
  },
  {
    unit: Unitsml::Unit::Steradian,
    power: -1
  }
  ],
  quantity: Unitsml::Quantity::Radiance
}

Or in short "chained" form:

Unitsml::Unit.new.
  add_root(Unitsml::Unit::Watt, 1).
  add_root(Unitsml::Unit::Meter, -1).
  add_root(Unitsml::Unit::Steradian, -1).
  set_quantity(Unitsml::Quantity::Radiance)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions