diff options
author | Samuel Fadel <samuelfadel@gmail.com> | 2016-01-25 19:51:19 +0100 |
---|---|---|
committer | Samuel Fadel <samuelfadel@gmail.com> | 2016-01-25 19:51:19 +0100 |
commit | 4b620a45ea7960dfe2833e78f92a5990a49927f5 (patch) | |
tree | 24bfdd0f44c2483a0081aaeae9f0bc24693f5187 | |
parent | d414b68cea008edc063e26133564d120a7430bd2 (diff) |
LinearScale: additional helper methods.
-rw-r--r-- | scale.h | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -18,6 +18,11 @@ public: virtual ~Scale() {} + T rangeMin() const { return m_rangeMin; } + T rangeMax() const { return m_rangeMax; } + T domainMin() const { return m_domainMin; } + T domainMax() const { return m_domainMax; } + void setRangeMin(T rangeMin) { m_rangeMin = rangeMin; valuesUpdated(); } void setRangeMax(T rangeMax) { m_rangeMax = rangeMax; valuesUpdated(); } void setDomainMin(T domainMin) { m_domainMin = domainMin; valuesUpdated(); } @@ -30,6 +35,11 @@ public: valuesUpdated(); } + void setRange(const Scale<T> &other) + { + setRange(other.m_rangeMin, other.m_rangeMax); + } + void setDomain(const T &domainMin, const T &domainMax) { m_domainMin = domainMin; @@ -37,6 +47,11 @@ public: valuesUpdated(); } + void setDomain(const Scale<T> &other) + { + setDomain(other.m_domainMin, other.m_domainMax); + } + void inverse() { std::swap(m_rangeMin, m_domainMin); @@ -70,6 +85,13 @@ public: return (value - Scale<T>::m_domainMin) * m_transformSlope + Scale<T>::m_rangeMin; } + T slope() const { return m_transformSlope; } + + T offset() const + { + return Scale<T>::m_rangeMin - Scale<T>::m_domainMin * m_transformSlope; + } + protected: virtual void valuesUpdated() { |