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.
Index
Methods
s
try UnitTable.convertFromNativeUnits(conversion, value, toUnit)Converts a value from native units to the specified unit given unit conversion descriptor.
Arguments
| Name | Type | Description |
|---|---|---|
| conversion | UnitConversionDescriptor | The unit conversion data retrieved from device or axis. |
| value | Double | The value to be converted. |
| toUnit | Units | The unit which the value is being converted to. |
Return Value
Double The converted value. Throws ConversionFailedException if unit is incompatible.s
try UnitTable.convertFromNativeUnitsBatch(conversion, values, toUnit)Converts values from native units to the specified unit given unit conversion descriptor.
Arguments
| Name | Type | Description |
|---|---|---|
| conversion | UnitConversionDescriptor | The unit conversion data retrieved from device or axis. |
| values | [Double] | The value to be converted. |
| toUnit | Units | The unit which the value is being converted to. |
Return Value
[Double] The converted values. Throws ConversionFailedException if unit is incompatible.s
try UnitTable.convertToNativeUnits(conversion, value, fromUnit, round = false)Converts a value from one unit to native units given unit conversion descriptor.
Arguments
| Name | Type | Description |
|---|---|---|
| conversion | UnitConversionDescriptor | The unit conversion data retrieved from device or axis. |
| value | Double | The value to be converted. |
| fromUnit | Units | The unit which the value is being converted from. |
| round | Bool | If true, round the result to the descriptor's native decimal places. |
Return Value
Double The converted value. Throws ConversionFailedException if unit is incompatible.s
try UnitTable.convertToNativeUnitsBatch(conversion, values, fromUnit, round = false)Converts values from one unit to native units given unit conversion descriptor.
Arguments
| Name | Type | Description |
|---|---|---|
| conversion | UnitConversionDescriptor | The unit conversion data retrieved from device or axis. |
| values | [Double] | The value to be converted. |
| fromUnit | Units | The unit which the value is being converted from. |
| round | Bool | If true, round the results to the descriptor's native decimal places. |
Return Value
[Double] The converted values. Throws ConversionFailedException if unit is incompatible.s
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
| Name | Type | Description |
|---|---|---|
| value | Double | The value to be converted. |
| fromUnit | Units | The unit which the value is being converted from. |
| toUnit | Units | The unit which the value is being converted to. |
Return Value
Double The converted value. Throws ConversionFailedException if unit is incompatible.s
try UnitTable.getSymbol(unit)Gets the standard symbol associated with a given unit.
Arguments
| Name | Type | Description |
|---|---|---|
| unit | Units | Unit of measure. |
Return Value
String Symbols corresponding to the given unit. Throws NoValueForKey if no symbol is defined.s
try UnitTable.getUnit(symbol)Gets the unit enum value associated with a standard symbol. Note not all units can be retrieved this way.
Arguments
| Name | Type | Description |
|---|---|---|
| symbol | String | Symbol to look up. |
Return Value
Units The unit enum value with the given symbols. Throws NoValueForKey if the symbol is not supported for lookup.