Skip to main content

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

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

ParameterTypeDefault valueDescription
familyFundefinedThe family to which this unit belongs.
namestringundefinedThe name of this unit.
scaleFactornumberundefinedThe relative linear scale of the new unit compared to the standard unit of the same family.
zeroOffsetnumber0The zero offset of the new unit compared to the standard unit of the same family.

Returns

SimpleUnit<F>

Overrides

AbstractUnit.constructor

Properties

family

readonly family: F

Defined in: src/sdk/math/NumberUnit.ts:794

The family to which this unit belongs.

Implementation of

CompoundableUnit.family

Inherited from

AbstractUnit.family


name

readonly name: string

Defined in: src/sdk/math/NumberUnit.ts:757

The name of this unit.

Implementation of

CompoundableUnit.name

Inherited from

AbstractUnit.name


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

CompoundableUnit.scaleFactor


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

ParameterTypeDescription
otherUnitUnit<string>The other unit.

Returns

boolean

Whether conversions between this unit and another unit are possible.

Implementation of

CompoundableUnit.canConvert

Overrides

AbstractUnit.canConvert


convertFrom()

convertFrom(value, fromUnit): number

Defined in: src/sdk/math/NumberUnit.ts:817

Converts a value of another unit to this unit.

Parameters

ParameterTypeDescription
valuenumberThe value to convert.
fromUnitUnit<F>The unit from which to convert.

Returns

number

The converted value.

Throws

Error if attempting an invalid conversion.

Implementation of

CompoundableUnit.convertFrom

Overrides

AbstractUnit.convertFrom


convertTo()

convertTo(value, toUnit): number

Defined in: src/sdk/math/NumberUnit.ts:808

Converts a value of this unit to another unit.

Parameters

ParameterTypeDescription
valuenumberThe value to convert.
toUnitUnit<F>The unit to which to convert.

Returns

number

The converted value.

Throws

Error if attempting an invalid conversion.

Implementation of

CompoundableUnit.convertTo

Overrides

AbstractUnit.convertTo


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

ParameterTypeDescription
valuenumberThe numeric value of the new NumberUnit.

Returns

NumberUnit<F, SimpleUnit<F>>

A NumberUnit of this unit type.

Implementation of

CompoundableUnit.createNumber

Inherited from

AbstractUnit.createNumber


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

ParameterTypeDescription
otherUnit<string>The other unit to which to compare.

Returns

boolean

Whether this unit is equal to the comparison.

Implementation of

CompoundableUnit.equals

Inherited from

AbstractUnit.equals