class utils::Interval — HIRO 0.7.0 documentation

# class utils::Interval

## Overview

Holds float interval and performs operations on it. More…

    #include <Interval.h>

    class Interval {
    public:
        // construction

        Interval();
        Interval(const float a, const float b, const float epsilon);
        Interval(const float left, const float right);

        // methods

        bool operator==(const Interval& o) const;
        bool operator!=(const Interval& o) const;
        float GetClamped(const float val) const;
        float NormToValue(const float t) const;
        float ValueToNorm(const float val) const;
        float GetRange() const;
        bool IsEmpty() const;
        float GetMin() const;
        float GetMax() const;
        float GetEpsilon() const;

    protected:
        // fields

        float min_;
        float max_;
        float epsilon_;
    };

## Detailed Documentation

Holds float interval and performs operations on it.

### Construction

    Interval()

Creates a default interval <0,1>.

    Interval(const float a, const float b, const float epsilon)

Creates an interval <a,b> with custom numerical precision (epsilon).

    Interval(const float left, const float right)

Creates an interval <a,b>.

### Methods

    bool operator==(const Interval& o) const

Compares if two intervals are identical.

    bool operator!=(const Interval& o) const

Compares if two intervals are different.

    float GetClamped(const float val) const

Clamps a value to the interval endpoints.

    float NormToValue(const float t) const

Returns real value from the normalized interval parameter.

    float ValueToNorm(const float val) const

Returns normalized interval parameter from the real value.

    float GetRange() const

Returns a distance between interval endpoints.

    bool IsEmpty() const

Check whether the range of interval is zero.

    float GetMin() const

Returns value of a minimal endpoint of the interval.

    float GetMax() const

Returns value of a maximal endpoint of the interval.

    float GetEpsilon() const

Returns numerical precision of the interval.