Simplifies tasks with linear functions, especially when creating a function from two given points.
In fact it just capsules a linear function with some nice methods.
For example get the function value, get inverse function value or control function parameters (gradient and y-axis-intersection).
The prototype looks like this:
Header (Linear.h):
namespace Functions
{
class Linear
{
public:
// Initializes with the zero function.
Linear();
Linear(float gradient, float yaxis);
Linear(Point const& p1, Point const& p2);
virtual ~Linear();
float GetGradient() const;
void SetGradient(float value);
float GetYAxis() const;
void SetYAxis(float value);
// Returns the value of the linear function f(x).
float FX(float x) const;
// Returns the inverse value of the linear function f^-1(y).
float FY(float y) const;
float operator ()(float x) const;
private:
float m_gradient;
float m_yaxis;
};
}
Simplifies tasks with linear functions, especially when creating a function from two given points. In fact it just capsules a linear function with some nice methods. For example get the function value, get inverse function value or control function parameters (gradient and y-axis-intersection).
The prototype looks like this:
Header (Linear.h):
and code (Linear.cpp):
Will be implemented inside the DrawLine() and DrawTriangle() functions for render.