Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ToyMaker::RangeMapperLinear Class Reference

A simple linear interpolation implementation between a fixed input and output range. More...

#include <util.hpp>

Public Member Functions

 RangeMapperLinear (double inputLowerBound, double inputUpperBound, double outputLowerBound, double outputUpperBound)
 Constructs a range mapper with a fixed pair of input and output ranges.
 
double operator() (double value) const
 The operation that actually converts a value from its input range into its output range.
 

Private Attributes

double mInputLowerBound
 The start of the input range.
 
double mInputUpperBound
 The end of the input range.
 
double mOutputLowerBound
 The start of the output range.
 
double mOutputUpperBound
 The end of the output range.
 

Detailed Description

A simple linear interpolation implementation between a fixed input and output range.

Usage:

axisValue = RangeMapperLinear{
// NOTE: extremes of the input range.
0.f, static_cast<double>(windowWidth),
// NOTE: extremes of the output range.
0.f, 1.f
// NOTE: the value mapped from the input range to the output range.
}(inputEvent.motion.x);
RangeMapperLinear(double inputLowerBound, double inputUpperBound, double outputLowerBound, double outputUpperBound)
Constructs a range mapper with a fixed pair of input and output ranges.
Definition util.cpp:17
Todo
Does this really need to be a class when it seems as though every usage instantiates and calls this "functor" in the same step? What was I thinking?

Constructor & Destructor Documentation

◆ RangeMapperLinear()

RangeMapperLinear::RangeMapperLinear ( double inputLowerBound,
double inputUpperBound,
double outputLowerBound,
double outputUpperBound )

Constructs a range mapper with a fixed pair of input and output ranges.

Parameters
inputLowerBoundThe start of the input range.
inputUpperBoundThe end of the input range.
outputLowerBoundThe start of the output range.
outputUpperBoundThe end of the output range.

Member Function Documentation

◆ operator()()

double RangeMapperLinear::operator() ( double value) const

The operation that actually converts a value from its input range into its output range.

Parameters
valueThe value in the input range.
Returns
double The same value mapped to the output range.

The documentation for this class was generated from the following files: