Table of Contents

Class Unit

Namespace
Cryville.Measure
Assembly
Cryville.Measure.dll
Unit.
public record Unit : IEquatable<Unit>
Inheritance
Unit
Implements
Derived
Inherited Members

Remarks

Scale define the mapping to the coherent SI unit of the dimension. Given the value in the current unit x and the scale k, the value in the coherent unit y = k * x.

Constructors

Unit(Dimension, double)

Unit.
public Unit(Dimension Dimension, double Scale = 1)

Parameters

Dimension Dimension
The dimension.
Scale double
The scale.

Remarks

Scale define the mapping to the coherent SI unit of the dimension. Given the value in the current unit x and the scale k, the value in the coherent unit y = k * x.

Properties

Dimension

The dimension.
public Dimension Dimension { get; init; }

Property Value

Dimension

Scale

The scale.
public double Scale { get; init; }

Property Value

double

Methods

Divide(Unit, Unit)

Returns the division of a unit divided by another.
public static Unit Divide(Unit left, Unit right)

Parameters

left Unit
The divided unit.
right Unit
The dividing unit.

Returns

Unit
The division of left divided by right.

From(double, Unit)

Converts the specified value in the specified unit to a value in the current unit.
public double From(double value, Unit unit)

Parameters

value double
The value in unit.
unit Unit
The source unit.

Returns

double
A value in the current unit.

Exceptions

ArgumentNullException
unit is null.

FromCoherent(double)

Converts the specified value in the coherent unit to a value in the current unit.
public virtual double FromCoherent(double value)

Parameters

value double
The value in the coherent unit.

Returns

double
A value in the current unit.

Multiply(Unit, Unit)

Returns the multiplication of two units.
public static Unit Multiply(Unit left, Unit right)

Parameters

left Unit
The first unit.
right Unit
The second unit.

Returns

Unit
The multiplication of the two units.

To(double, Unit)

Converts the specified value in the current unit to a value in the specified unit.
public double To(double value, Unit unit)

Parameters

value double
The value in the current unit.
unit Unit
The target unit.

Returns

double
A value in unit.

Exceptions

ArgumentNullException
unit is null.

ToCoherent(double)

Converts the specified value in the current unit to a value in the corresponding coherent unit.
public virtual double ToCoherent(double value)

Parameters

value double
The value in the current unit.

Returns

double
A value in the corresponding coherent unit.

ToString()

Returns a string that represents the current object.
public override string ToString()

Returns

string
A string that represents the current object.

WithPrefix(double)

Creates a unit based on the current unit modified by the specified prefix.
public Unit WithPrefix(double prefix)

Parameters

prefix double
The prefix.

Returns

Unit
The new unit.

Operators

operator /(Unit, Unit)

Returns the division of a unit divided by another.
public static Unit operator /(Unit left, Unit right)

Parameters

left Unit
The divided unit.
right Unit
The dividing unit.

Returns

Unit
The division of left divided by right.

operator *(Unit, Unit)

Returns the multiplication of two units.
public static Unit operator *(Unit left, Unit right)

Parameters

left Unit
The first unit.
right Unit
The second unit.

Returns

Unit
The multiplication of the two units.