Show / Hide Table of Contents

    Class DomainExtensions

    Extension and utility methods for mathematical operations.

    Inheritance
    System.Object
    DomainExtensions
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Elements
    Assembly: Hypar.Elements.dll
    Syntax
    public static class DomainExtensions

    Methods

    ApproximatelyEquals(Double, Double, Double)

    Test if two values are approximately equal to each other with an optional tolerance value.

    Declaration
    public static bool ApproximatelyEquals(this double value, double other, double tolerance = 1E-05)
    Parameters
    Type Name Description
    System.Double value

    The first value to test.

    System.Double other

    The other value to test.

    System.Double tolerance

    The threshold for equality. If not supplied, the global tolerance will be used.

    Returns
    Type Description
    System.Boolean

    True if |other - value| < tolerance

    MapBetweenDomains(Double, Domain1d, Domain1d)

    Map/Scale a value from one domain to another. 3 mapped from (2,4) to (10, 20) would be 15.

    Declaration
    public static double MapBetweenDomains(this double value, Domain1d source, Domain1d target)
    Parameters
    Type Name Description
    System.Double value

    The value to map.

    Domain1d source

    The source domain to map from.

    Domain1d target

    The target domain to map to.

    Returns
    Type Description
    System.Double

    MapFromDomain(Double, Domain1d)

    Map/Normalize a value from a domain to the domain (0,1).

    Declaration
    public static double MapFromDomain(this double value, Domain1d domain)
    Parameters
    Type Name Description
    System.Double value

    The value to map

    Domain1d domain

    The domain to map from.

    Returns
    Type Description
    System.Double

    (value - domain.Min) / domain.Length

    MapToDomain(Double, Domain1d)

    Map/scale a value between 0-1 to a target domain. Will not reject values outside 0-1.

    Declaration
    public static double MapToDomain(this double value, Domain1d domain)
    Parameters
    Type Name Description
    System.Double value

    The value to map.

    Domain1d domain

    The domain to map to.

    Returns
    Type Description
    System.Double

    value * domain.Length + domain.Min