public Tolerance GetProductTolerance() { double value = (double)numericUpDown1.Value; ToleranceUnit type = (ToleranceUnit)comboBox1.SelectedItem; return(new Tolerance(type, value)); }
public static Tolerance CalculatePrecursorMassError(double theoreticalMass, double observedMass, out int nominalMassOffset, out double adjustedObservedMass, double difference = Constants.C13C12Difference, ToleranceUnit type = ToleranceUnit.PPM) { double massError = observedMass - theoreticalMass; nominalMassOffset = (int)Math.Round(massError / difference); double massOffset = nominalMassOffset * difference; adjustedObservedMass = observedMass - massOffset; return(new Tolerance(type, adjustedObservedMass, theoreticalMass)); }
public static double GetTolerance(double experimental, double theoretical, ToleranceUnit type) { switch (type) { case ToleranceUnit.PPM: return(Math.Abs((experimental - theoretical) / theoretical * 1e6)); default: return(Math.Abs(experimental - theoretical)); } }
public static double GetTolerance(double experimental, double theoretical, ToleranceUnit type) { switch (type) { case ToleranceUnit.MMU: return((experimental - theoretical) * 1000.0); case ToleranceUnit.PPM: return((experimental - theoretical) / theoretical * 1e6); default: return(experimental - theoretical); } }
public Tolerance(ToleranceUnit unit, double experimental, double theoretical, ToleranceType type = ToleranceType.PlusAndMinus) : this(unit, GetTolerance(experimental, theoretical, unit), type) { }
public Tolerance(ToleranceUnit unit, double value, ToleranceType type = ToleranceType.PlusAndMinus) { Unit = unit; Value = value; Type = type; }
/// <summary> /// Creates a new tolerance given a unit, two points (one experimental and one theoretical), and whether the tolerance is ± /// </summary> /// <param name="unit">The units for this tolerance</param> /// <param name="experimental">The experimental value</param> /// <param name="theoretical">The theoretical value</param> /// <param name="type">Whether the tolerance is full or half width</param> public Tolerance(ToleranceUnit unit, double experimental, double theoretical, ToleranceType type = ToleranceType.PlusAndMinus) : this(unit, GetTolerance(experimental, theoretical, unit), type) { }
/// <summary> /// Creates a new tolerance given a unit, value, and whether the tolerance is ± /// </summary> /// <param name="unit">The units for this tolerance</param> /// <param name="value">The numerical value of the tolerance</param> /// <param name="type">Whether the tolerance is full or half width</param> public Tolerance(ToleranceUnit unit, double value, ToleranceType type = ToleranceType.PlusAndMinus) { Unit = unit; Value = value; Type = type; }
public static double GetTolerance(double experimental, double theoretical, ToleranceUnit type) { switch (type) { case ToleranceUnit.MMU: return (experimental - theoretical)*1000.0; case ToleranceUnit.PPM: return (experimental - theoretical)/theoretical*1e6; default: return experimental - theoretical; } }
public static Tolerance CalculatePrecursorMassError(double theoreticalMass, double observedMass, out int nominalMassOffset, out double adjustedObservedMass, double difference = Constants.C13C12Difference, ToleranceUnit type = ToleranceUnit.PPM) { double massError = observedMass - theoreticalMass; nominalMassOffset = (int) Math.Round(massError/difference); double massOffset = nominalMassOffset*difference; adjustedObservedMass = observedMass - massOffset; return new Tolerance(type, adjustedObservedMass, theoreticalMass); }
public Tolerance(double value, ToleranceUnit unit) { _value = value; _unit = unit; }
/// <summary> /// Creates a new tolerance given a unit, two points (one experimental and one theoretical), and whether the tolerance is ± /// </summary> /// <param name="unit">The units for this tolerance</param> /// <param name="experimental">The experimental value</param> /// <param name="theoretical">The theoretical value</param> public Tolerance(ToleranceUnit unit, double experimental, double theoretical) : this(unit, GetTolerance(experimental, theoretical, unit)) { }
/// <summary> /// Creates a new tolerance given a unit, value, and whether the tolerance is ± /// </summary> /// <param name="unit">The units for this tolerance</param> /// <param name="value">The numerical value of the tolerance</param> public Tolerance(ToleranceUnit unit, double value) { Unit = unit; Value = Math.Abs(value); }