/******************************************************************/ public double SubUnitFactor(SiSpeed_SubUnits SubUnit) { double factor = 1.0; switch (SubUnit) { case SiSpeed_SubUnits.Meter_per_Second: factor = 1.0; break; case SiSpeed_SubUnits.KiloMeter_per_Hour: factor = 3600.0 / 1000.0; break; case SiSpeed_SubUnits.Centimeter_per_Second: factor = 100.0; break; } return(factor); }
/****************************************************************/ /******************************************************************/ public string SubUnitString(SiSpeed_SubUnits SubUnit) { string sub_unit_name = ""; switch (SubUnit) { case SiSpeed_SubUnits.Meter_per_Second: sub_unit_name = "m/s"; break; case SiSpeed_SubUnits.KiloMeter_per_Hour: sub_unit_name = "km/h"; break; case SiSpeed_SubUnits.Centimeter_per_Second: sub_unit_name = "cm/s"; break; } return(sub_unit_name); }
/****************** constructors ******************************/ /**@brief A constructor where the value unit's is specified. */ /**@param "x" The internal value is assigned to it. It is assumed x is speeds */ /**@param "SubUnit" The units in wich 'x' is expressed. */ public SiSpeed(double x, SiSpeed_SubUnits SubUnit) { this.the_value = 0.0; this.the_value = x / SubUnitFactor(SubUnit); }
/**@brief Returns the value converted to the selected units. */ public double ToSubUnits(SiSpeed_SubUnits SubUnit) { return(this.Value * SubUnitFactor(SubUnit)); }