0

I got two data points, x axis is an integer, and y axis needs to be a float within a set limit, say from 0.00f to 1.00f.

I would love to plot an adjustable curve between the two points, with the default adjusting parameter (say at 1.0f) resulting in just a straight line.

So for example I got any two data points such as;

int x1 = 0; float y1 = 0.25f;
int x2 = 49; float y2 = 0.75f;

float yDiff = (y2 - y1) / (x2 - x1);

float dataPointArray[50];

for (int i = x1; i <= x2; i++)
{
  y1 += yDiff;

  dataPointArray[i] = y1; // This just plots a straight line

  dataPointArray[i] = atan (y1); // This plots a set curved line, although it 
                                 // does go out of bounds,
                                 // which I can easily adjust (center) after.

  dataPointArray[i] = pow (y1, ac); // Had hoped this would plot an adjustable
                                    // curve, with ac of 1 being no curve, 
                                    // and ac of 0.5f and ac of 2.0f being
                                    // curves, but float values goes WAY out of bounds
}

I figure I probably have to mathematically adjust the variable yDiff during the loop, with a "curve parameter" so it either starts to increment slow, then faster, and faster, or vice-versa, or starts slows, fast in the middle, then slow again, or vice-versa.

  • Are you just looking for an [interpolation Scheme](https://en.wikipedia.org/wiki/Interpolation)? Otherwise I do not fully understand what you are looking for. Given only two points linear interpolation is the only thing you can do unless one adds more information or more degrees of freedom. In that case the question is what you want to achieve/or what are the constraints. – Andreas H. Apr 07 '20 at 11:45
  • @AndreasH. This is not about interpolation. I figure I probably have to mathematically adjust the variable yDiff during the loop, with a "curve parameter" so it either starts to increment slow, then faster, and faster, or vice-versa. – DKDiveDude Apr 07 '20 at 11:51

0 Answers0