Need help naming a class that represents a value and its linear variation

When doing some refactoring, I found that I often use a pair or float to represent the initial value and how much this value changes linearly over time. I want to create a structure to hold both fields, but I just cannot find the correct name for it.

It should look something like this:

struct XXX
{
    float Value;
    float Slope; // or Delta? or Variation? 
}

Any suggestions would be highly appreciated.

+3
source share
7 answers

Since you have an initial value and a value indicating how “something” evolves, you can go with something like “Linear function”.

I would also add the necessary member functions:

struct LinearFunction {
    float constant;
    float slope;
    float increment( float delta ) const { return constant + delta*slope; }
    void add( const LinearFunction& other ) { constant += other.constant; slope += other.slope; }
    LinearFunction invert() const { 
        LinearFunction inv = { -constant/slope, 1./slope; };
        return inv;
    }
};

Or do I want here?

+1

, :

struct ValueDeltaDuplet
{
    float Value;
    float Delta;    
}
+1

+ : ?

+1
source

I like "Scale" ...

struct ValueScale
{
    float Value;
    float Slope;
}

or maybe

struct ScalableValue
{
    float Value;
    float Slope;
}
+1
source

It's like an arithmetic progression (or arithmetic sequence)

struct sequence_num_t {
    float value;
    float delta;
};

or

struct SequencePoint
{
   float Value;
   float Delta;
};
+1
source
struct ValueSlopePair
{
    float Value;
    float Slope;    
}
0
source
struct FloatPair
{
    float Value;
    float Slope;    
}
-1
source

Source: https://habr.com/ru/post/1711395/


All Articles