API Reference v9.2.0

UnitTableclass

Module: ZaberMotion

Helper for working with units of measure.

To use this type, add import ZaberMotion to the top of your source code.

Methods

s

convertFromNativeUnits()

throws
try UnitTable.convertFromNativeUnits(conversion, value, toUnit)
Converts a value from native units to the specified unit given unit conversion descriptor.
Arguments
NameTypeDescription
conversionUnitConversionDescriptorThe unit conversion data retrieved from device or axis.
valueDoubleThe value to be converted.
toUnitUnitsThe unit which the value is being converted to.
Return Value
Double The converted value. Throws ConversionFailedException if unit is incompatible.
s

convertFromNativeUnitsBatch()

throws
try UnitTable.convertFromNativeUnitsBatch(conversion, values, toUnit)
Converts values from native units to the specified unit given unit conversion descriptor.
Arguments
NameTypeDescription
conversionUnitConversionDescriptorThe unit conversion data retrieved from device or axis.
values[Double]The value to be converted.
toUnitUnitsThe unit which the value is being converted to.
Return Value
[Double] The converted values. Throws ConversionFailedException if unit is incompatible.
s

convertToNativeUnits()

throws
try UnitTable.convertToNativeUnits(conversion, value, fromUnit, round = false)
Converts a value from one unit to native units given unit conversion descriptor.
Arguments
NameTypeDescription
conversionUnitConversionDescriptorThe unit conversion data retrieved from device or axis.
valueDoubleThe value to be converted.
fromUnitUnitsThe unit which the value is being converted from.
roundBoolIf true, round the result to the descriptor's native decimal places.
Return Value
Double The converted value. Throws ConversionFailedException if unit is incompatible.
s

convertToNativeUnitsBatch()

throws
try UnitTable.convertToNativeUnitsBatch(conversion, values, fromUnit, round = false)
Converts values from one unit to native units given unit conversion descriptor.
Arguments
NameTypeDescription
conversionUnitConversionDescriptorThe unit conversion data retrieved from device or axis.
values[Double]The value to be converted.
fromUnitUnitsThe unit which the value is being converted from.
roundBoolIf true, round the results to the descriptor's native decimal places.
Return Value
[Double] The converted values. Throws ConversionFailedException if unit is incompatible.
s

convertUnits()

throws
try UnitTable.convertUnits(value, fromUnit, toUnit)
Converts a value from one unit to a different unit of the same dimension. Note that this function does not support native unit conversions.
Arguments
NameTypeDescription
valueDoubleThe value to be converted.
fromUnitUnitsThe unit which the value is being converted from.
toUnitUnitsThe unit which the value is being converted to.
Return Value
Double The converted value. Throws ConversionFailedException if unit is incompatible.
s

getSymbol()

throws
try UnitTable.getSymbol(unit)
Gets the standard symbol associated with a given unit.
Arguments
NameTypeDescription
unitUnitsUnit of measure.
Return Value
String Symbols corresponding to the given unit. Throws NoValueForKey if no symbol is defined.
s

getUnit()

throws
try UnitTable.getUnit(symbol)
Gets the unit enum value associated with a standard symbol. Note not all units can be retrieved this way.
Arguments
NameTypeDescription
symbolStringSymbol to look up.
Return Value
Units The unit enum value with the given symbols. Throws NoValueForKey if the symbol is not supported for lookup.