Class: CompoundUnit<F>
Defined in: src/sdk/math/NumberUnit.ts:829
A unit of measure composed of the multiplicative combination of multiple elementary units.
Extends
AbstractUnit
<F
>
Type Parameters
Type Parameter |
---|
F extends string |
Constructors
Constructor
new CompoundUnit<
F
>(family
,numerator
,denominator
,name?
):CompoundUnit
<F
>
Defined in: src/sdk/math/NumberUnit.ts:843
Constructor.
Parameters
Parameter | Type | Description |
---|---|---|
family | F | The family to which this unit belongs. |
numerator | CompoundableUnit <string >[] | An array of CompoundableUnits containing all the units in the numerator of the compound unit. |
denominator | CompoundableUnit <string >[] | An array of CompoundableUnits containing all the units in the denominator of the compound unit. |
name? | string | The name of this unit. If not defined, one will be automatically generated. |
Returns
CompoundUnit
<F
>
Overrides
Properties
family
readonly
family:F
Defined in: src/sdk/math/NumberUnit.ts:830
This unit's family.
Overrides
name
readonly
name:string
Defined in: src/sdk/math/NumberUnit.ts:757
The name of this unit.
Inherited from
scaleFactor
protected
readonly
scaleFactor:number
Defined in: src/sdk/math/NumberUnit.ts:834
Methods
canConvert()
canConvert(
otherUnit
):boolean
Defined in: src/sdk/math/NumberUnit.ts:888
Checks whether conversions between this unit and another unit are possible.
Parameters
Parameter | Type | Description |
---|---|---|
otherUnit | Unit <string > | The other unit. |
Returns
boolean
Whether conversions between this unit and another unit are possible.
Overrides
convertFrom()
convertFrom(
value
,fromUnit
):number
Defined in: src/sdk/math/NumberUnit.ts:902
Converts a value of another unit to this unit.
Parameters
Parameter | Type | Description |
---|---|---|
value | number | The value to convert. |
fromUnit | Unit <F > | The unit from which to convert. |
Returns
number
The converted value.
Throws
Error if attempting an invalid conversion.
Overrides
convertTo()
convertTo(
value
,toUnit
):number
Defined in: src/sdk/math/NumberUnit.ts:893
Converts a value of this unit to another unit.
Parameters
Parameter | Type | Description |
---|---|---|
value | number | The value to convert. |
toUnit | Unit <F > | The unit to which to convert. |
Returns
number
The converted value.
Throws
Error if attempting an invalid conversion.
Overrides
createNumber()
createNumber(
value
):NumberUnit
<F
,CompoundUnit
<F
>>
Defined in: src/sdk/math/NumberUnit.ts:772
Creates a NumberUnit with a specified initial value of this unit type.
Parameters
Parameter | Type | Description |
---|---|---|
value | number | The numeric value of the new NumberUnit. |
Returns
NumberUnit
<F
, CompoundUnit
<F
>>
A NumberUnit of this unit type.
Inherited from
equals()
equals(
other
):boolean
Defined in: src/sdk/math/NumberUnit.ts:777
Checks whether this unit is equal to another unit. Returns true if and only if the other unit belongs to the same family and has the same name as this unit.
Parameters
Parameter | Type | Description |
---|---|---|
other | Unit <string > | The other unit to which to compare. |
Returns
boolean
Whether this unit is equal to the comparison.