Class: SimpleUnit<F>
Defined in: src/sdk/math/NumberUnit.ts:785
A unit that can be converted to another unit of the same type via a fixed linear transformation.
Extends
AbstractUnit
<F
>
Type Parameters
Type Parameter |
---|
F extends string |
Implements
Constructors
Constructor
new SimpleUnit<
F
>(family
,name
,scaleFactor
,zeroOffset
):SimpleUnit
<F
>
Defined in: src/sdk/math/NumberUnit.ts:793
Constructor.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
family | F | undefined | The family to which this unit belongs. |
name | string | undefined | The name of this unit. |
scaleFactor | number | undefined | The relative linear scale of the new unit compared to the standard unit of the same family. |
zeroOffset | number | 0 | The zero offset of the new unit compared to the standard unit of the same family. |
Returns
SimpleUnit
<F
>
Overrides
Properties
family
readonly
family:F
Defined in: src/sdk/math/NumberUnit.ts:794
The family to which this unit belongs.
Implementation of
Inherited from
name
readonly
name:string
Defined in: src/sdk/math/NumberUnit.ts:757
The name of this unit.
Implementation of
Inherited from
scaleFactor
readonly
scaleFactor:number
Defined in: src/sdk/math/NumberUnit.ts:796
The relative linear scale of the new unit compared to the standard unit of the same family.
Implementation of
zeroOffset
readonly
zeroOffset:number
=0
Defined in: src/sdk/math/NumberUnit.ts:797
The zero offset of the new unit compared to the standard unit of the same family.
Methods
canConvert()
canConvert(
otherUnit
):boolean
Defined in: src/sdk/math/NumberUnit.ts:803
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.
Implementation of
Overrides
convertFrom()
convertFrom(
value
,fromUnit
):number
Defined in: src/sdk/math/NumberUnit.ts:817
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.
Implementation of
Overrides
convertTo()
convertTo(
value
,toUnit
):number
Defined in: src/sdk/math/NumberUnit.ts:808
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.
Implementation of
Overrides
createNumber()
createNumber(
value
):NumberUnit
<F
,SimpleUnit
<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
, SimpleUnit
<F
>>
A NumberUnit of this unit type.
Implementation of
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.