Helios++
Helios software for LiDAR simulations
SimpleLinearFunction.h
1 #pragma once
2 
3 #include <fluxionum/Function.h>
4 
5 namespace fluxionum{
6 
19 template <typename A, typename B>
20 class SimpleLinearFunction : public Function<A, B>{
21 protected:
22  // *** ATTRIBUTES *** //
23  // ******************** //
27  B slope;
32 
33 public:
34  // *** CONSTRUCTION / DESTRUCTION *** //
35  // ************************************ //
41  SimpleLinearFunction(B const slope, B const intercept) :
42  Function<A, B>(),
43  slope(slope),
45  {}
46  virtual ~SimpleLinearFunction() = default;
47 
48  // *** FUNCTION METHODS *** //
49  // ************************** //
61  B eval(A const &x) override{
62  return x*slope+intercept;
63  }
64 
65  // *** LINEAR FUNCTION *** //
66  // ************************* //
71  inline B getSlope() const {return slope;}
76  inline B getIntercept() const {return intercept;}
77 };
78 
79 }
Abstract class representing a function.
Definition: Function.h:27
Simple linear function.
Definition: SimpleLinearFunction.h:20
B intercept
The intercept of the linear function.
Definition: SimpleLinearFunction.h:31
B eval(A const &x) override
Calculate the image of by assuming a linear behavior where is the slope and is the intercept.
Definition: SimpleLinearFunction.h:61
SimpleLinearFunction(B const slope, B const intercept)
SimpleLinearFunction default constructor.
Definition: SimpleLinearFunction.h:41
B getSlope() const
Obtain the slope of the linear function.
Definition: SimpleLinearFunction.h:71
B slope
The slope of the linear function.
Definition: SimpleLinearFunction.h:27
B getIntercept() const
Obtain the intercept of the linear function.
Definition: SimpleLinearFunction.h:76