Combines two input numbers in some proportion.

   
 

//http://isotopescreencapture.codeplex.com/
//The MIT License (MIT)
namespace Isotope.Math
{
    public static class MathUtil
    {
        /// <summary>
        /// Combines two input numbers in some proportion. 
        /// ratio=0.0 the first number is not used at all, 
        /// ratio=0.5 they are weight equally
        /// ratio=1.0 the first number completely dominates the value
        /// </summary>
        /// <param name="val0"></param>
        /// <param name="val1"></param>
        /// <param name="ratio"></param>
        /// <returns></returns>
        public static double Blend_0_1(double val0, double val1, double ratio)
        {
            var cratio = ClampToRange_0_1(ratio);
            var v0 = val0*cratio;
            var v1 = val1*(1.0 - cratio);
            return v0 + v1;
        }
        /// <summary>
        /// Given an input value will force the value to fit within the range (min,max) inclusive
        /// </summary>
        /// <param name="v"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns></returns>
        public static double ClampToRange(double v, double min, double max)
        {
            if (v < min)
            {
                v = min;
            }
            else if (v > max)
            {
                v = max;
            }
            return v;
        }

        /// <summary>
        /// Given an input value, will limit it to the range 0.0 and 1.0 inclusive
        /// </summary>
        /// <param name="v"></param>
        /// <returns>the clamped value</returns>
        public static double ClampToRange_0_1(double v)
        {
            return ClampToRange(v, 0.0, 1.0);
        }

    }
}

   
     


rounds val to the nearest fractional value

//http://isotopescreencapture.codeplex.com/
//The MIT License (MIT)
namespace Isotope.Math
{
public static class MathUtil
{
public static double Round(double val, double snap_val)
{
return Round(val, System.MidpointRounding.AwayFromZero, snap_val);
}
///

/// rounds val to the nearest fractional value
///

/// the value tp round /// what kind of rounding /// round to this value (must be greater than 0.0) /// the rounded value
public static double Round(double val, System.MidpointRounding rounding, double frac)
{
/*
if (frac <= 0) { throw new ArgumentOutOfRangeException("frac","must be greater than or equal to 0.0"); }*/ double retval = System.Math.Round((val/frac), rounding)*frac; return retval; } public static double RoundUp(double v, double amount) { const System.MidpointRounding rounding = System.MidpointRounding.ToEven; var result = Round(v + (amount/2.0), rounding, amount); return result; } } } [/csharp]

Returns the minimum value of three numbers

   
 

//http://isotopescreencapture.codeplex.com/
//The MIT License (MIT)
namespace Isotope.Math
{
    public static class MathUtil
    {
        /// <summary>
        /// Returns the minimum value of three numbers
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="c"></param>
        /// <returns></returns>
        public static double Min(double a, double b, double c)
        {
            return (System.Math.Min(System.Math.Min(a, b), c));
        }
   }
}

   
     


Returns the maximum value of three numbers

   
 

//http://isotopescreencapture.codeplex.com/
//The MIT License (MIT)
namespace Isotope.Math
{
    public static class MathUtil
    {
        /// <summary>
        /// Returns the maximum value of three numbers
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="c"></param>
        /// <returns></returns>
        public static double Max(double a, double b, double c)
        {
            return (System.Math.Max(System.Math.Max(a, b), c));
        }

    }
}

   
     


The Method converts the temperature in Celcius to Fahrenheit

   
 

//Microsoft Public License (Ms-PL)
//http://c4fdevkit.codeplex.com/license
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace C4F.DevKit.WebServices
{
    /// <summary>
    /// Provides useful methods like conversion methods.
    /// </summary>
    public static class Utility
    {

        /// <summary>
        /// The Method converts the temperature in Celcius to Fahrenheit
        /// </summary>
        /// <param name="temperature">Temperature in Celcius</param>
        /// <returns>Temperature in Fahrenheit</returns>
        public static double CelciusToFahrenheit(double temperature)
        {
            return (9.0 / 5.0) * temperature + 32;
        }
       
    }
}

   
     


The Method converts the temperature in Fahrenheit to Celcius

   
 

//Microsoft Public License (Ms-PL)
//http://c4fdevkit.codeplex.com/license

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace C4F.DevKit.WebServices
{
    /// <summary>
    /// Provides useful methods like conversion methods.
    /// </summary>
    public static class Utility
    {
        /// <summary>
        /// The Method converts the temperature in Fahrenheit to Celcius
        /// </summary>
        /// <param name="temperature">Temperature in Fahrenheit</param>
        /// <returns>Temperature in Celcius</returns>
        public static double FahrenheitToCelcius(double temperature)
        {
            return (5.0 / 9.0) * (temperature - 32);
        }

       
    }
}