Class: SimpleUnit<F>
A unit that can be converted to another unit of the same type via a fixed linear transformation.
Type parameters
Name | Type |
---|---|
F | extends string |
Hierarchy
AbstractUnit
<F
>↳
SimpleUnit
Implements
Constructors
constructor
• new SimpleUnit<F
>(family
, name
, scaleFactor
, zeroOffset?
): SimpleUnit
<F
>
Constructor.
Type parameters
Name | Type |
---|---|
F | extends string |
Parameters
Name | 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
Defined in
src/sdk/math/NumberUnit.ts:792
Properties
family
• Readonly
family: F
The family to which this unit belongs.
Implementation of
Inherited from
Defined in
src/sdk/math/NumberUnit.ts:793
name
• Readonly
name: string
The name of this unit.
Implementation of
Inherited from
Defined in
src/sdk/math/NumberUnit.ts:756
scaleFactor
• Readonly
scaleFactor: number
The relative linear scale of the new unit compared to the standard unit of the same family.
Implementation of
Defined in
src/sdk/math/NumberUnit.ts:795
zeroOffset
• Readonly
zeroOffset: number
= 0
The zero offset of the new unit compared to the standard unit of the same family.
Defined in
src/sdk/math/NumberUnit.ts:796
Methods
canConvert
▸ canConvert(otherUnit
): boolean
Checks whether conversions between this unit and another unit are possible.
Parameters
Name | Type | Description |
---|---|---|
otherUnit | Unit <string > | The other unit. |
Returns
boolean
Whether conversions between this unit and another unit are possible.
Implementation of
Overrides
Defined in
src/sdk/math/NumberUnit.ts:802
convertFrom
▸ convertFrom(value
, fromUnit
): number
Converts a value of another unit to this unit.
Parameters
Name | 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
Defined in
src/sdk/math/NumberUnit.ts:816
convertTo
▸ convertTo(value
, toUnit
): number
Converts a value of this unit to another unit.
Parameters
Name | 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
Defined in
src/sdk/math/NumberUnit.ts:807
createNumber
▸ createNumber(value
): NumberUnit
<F
, SimpleUnit
<F
>>
Creates a NumberUnit with a specified initial value of this unit type.
Parameters
Name | 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
Defined in
src/sdk/math/NumberUnit.ts:771
equals
▸ equals(other
): boolean
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
Name | Type | Description |
---|---|---|
other | Unit <string > | The other unit to which to compare. |
Returns
boolean
Whether this unit is equal to the comparison.
Implementation of
Inherited from
Defined in
src/sdk/math/NumberUnit.ts:776