UtilitiesConvertUnits Method

Convert from one set of speed / temperature / pressure rain rate units to another

Definition

Namespace: ASCOM.Tools
Assembly: ASCOM.Tools (in ASCOM.Tools.dll) Version: 3.0.0-rc.1+86c25ce733aebb4d8b1b8a62e84770ea5e972bea
C#
public static double ConvertUnits(
	double InputValue,
	Unit FromUnits,
	Unit ToUnits
)

Parameters

InputValue  Double
Value to convert
FromUnits  Unit
Integer value from the Units enum indicating the value's current units
ToUnits  Unit
Integer value from the Units enum indicating the units to which the input value should be converted

Return Value

Double
Input value expressed in the new units

Remarks

Conversions available:

  • metres per second <==> miles per hour <==> knots
  • Celsius <==> Fahrenheit <==> Kelvin
  • hecto Pascals (hPa) <==> milli bar(mbar) <==> mm of mercury <==> inches of mercury
  • mm per hour <==> inches per hour

Knots conversions use the international nautical mile definition (1 nautical mile = 1852m) rather than the original UK or US Admiralty definitions.

For convenience, milli bar and hecto Pascals are shown as separate units even though they have numerically identical values and there is a 1:1 conversion between them.

Exceptions

InvalidOperationExceptionWhen the specified from and to units can not refer to the same value. e.g. attempting to convert miles per hour to degrees Celsius

Version Information

.NET Standard

Supported in: 2.0

See Also