Class ostk::physics::Unit¶
- class Unit¶
Unit.
A unit of measurement is a definite magnitude of a quantity, defined and adopted by convention or by law, that is used as a standard for measurement of the same kind of quantity. Any other quantity of that kind can be expressed as a multiple of the unit of measurement.
https://en.wikipedia.org/wiki/Unit_of_measurement
Public Types
Public Functions
- Unit() = delete¶
Deleted default constructor.
- Unit(const Unit &aUnit)¶
Copy constructor.
Unit unit(Unit::Length(unit::Length::Unit::Meter));
- Parameters:
aUnit -- [in] A unit to copy
- Unit &operator=(const Unit &aUnit)¶
Copy assignment operator.
Unit unit = Unit::Length(unit::Length::Unit::Meter);
- Parameters:
aUnit -- [in] A unit to copy
- Returns:
A reference to this unit
- bool operator==(const Unit &aUnit) const¶
Equal to operator.
Unit::Length(unit::Length::Unit::Meter) == Unit::Length(unit::Length::Unit::Meter); // True
- Parameters:
aUnit -- [in] A unit to compare with
- Returns:
True if units are equal
- bool operator!=(const Unit &aUnit) const¶
Not equal to operator.
Unit::Length(unit::Length::Unit::Meter) != Unit::None(); // True
- Parameters:
aUnit -- [in] A unit to compare with
- Returns:
True if units are not equal
- bool isDefined() const¶
Check if the unit is defined.
Unit::Length(unit::Length::Unit::Meter).isDefined(); // True
- Returns:
True if defined
- bool isNone() const¶
Check if the unit is none.
Unit::None().isNone(); // True
- Returns:
True if none
- Unit::Type getType() const¶
Get the unit type.
Unit::Length(unit::Length::Unit::Meter).getType(); // Unit::Type::Length
- Returns:
The unit type
- Real ratioTo(const Unit &aUnit) const¶
Get the conversion ratio to another unit.
Unit::Length(unit::Length::Unit::Meter).ratioTo(Unit::Length(unit::Length::Unit::Meter)); // 1.0
- Parameters:
aUnit -- [in] A unit to convert to
- Returns:
The conversion ratio
- String toString() const¶
Convert to string representation.
Unit::Length(unit::Length::Unit::Meter).toString();
- Returns:
A string representation
Public Static Functions
- static Unit Undefined()¶
Construct an undefined unit.
Unit unit = Unit::Undefined();
- Returns:
An undefined unit
- static Unit None()¶
Construct a dimensionless (none) unit.
Unit unit = Unit::None();
- Returns:
A dimensionless unit
- static Unit Length(const unit::Length::Unit &aLengthUnit)¶
Construct a length unit.
Unit unit = Unit::Length(unit::Length::Unit::Meter);
- Parameters:
aLengthUnit -- [in] A length unit
- Returns:
A unit
- Unit() = delete¶