Image Component Library (ICL)
LinearTransform1D.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLMath/src/ICLMath/LinearTransform1D.h **
10 ** Module : ICLMath **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLUtils/Range.h>
35 
36 namespace icl{
37  namespace math{
38 
42  float m;
43 
45  float b;
46 
48  inline LinearTransform1D(float m=0, float b=0):m(m),b(b){}
49 
51  template<class T>
53  m(d.getLength()/s.getLength()), b(-m*s.minVal + d.minVal){
54  }
55 
57  float operator()(float x) const { return m*x+b; }
58  };
59 
60  } // namespace math
61 }
62 
float b
offset
Definition: LinearTransform1D.h:45
class representing a range defined by min and max value
Definition: Range.h:49
undocument this line if you encounter any issues!
Definition: Any.h:37
A standard linear mapping class for the 1D case f(x) = m * x + b.
Definition: LinearTransform1D.h:40
float m
slope
Definition: LinearTransform1D.h:42
LinearTransform1D(const utils::Range< T > &s, const utils::Range< T > &d)
spedical constructor template with given source and destination range
Definition: LinearTransform1D.h:52
float operator()(float x) const
applies the mapping to a given x -> f(x) = m * x + b
Definition: LinearTransform1D.h:57
LinearTransform1D(float m=0, float b=0)
base constructor with given parameters m and b
Definition: LinearTransform1D.h:48