I have the following curve (example data that's somewhat sparse, but should get the point across). There are four points along this curve (indicated by the arrows), that I'd like to use as reference points. These points need to be shifted by specified amounts (x1
, x2
, x3
, and x4
respectively) in the direction the arrow species. It will always be these four locations that need to be shifted by specific amounts. However, it's not as easy as shifting those specific points, because I need to maintain the overall shape of the curve.
There are constraints that will always be maintained. The arrow associated with x2
will never overlap with the arrow specified by x1. The arrow associated with x3
will never surpass that of x2
. The arrow associated with x4
will never surpass that associated with x3
. The curve will always have this general shape and will always be shifted at these 4 points.
In other words, the arrows in the image below are representative examples of the way that this curve should be shifted.
How can I do this? One idea I had was to fit some sort of spline and then somehow transform that spline in an elegant way based on these points. But I'm really not sure.
Here is the data from this example in Matlab
x = [6; 7; 7.2; 7.3; 7.5; 7.7; 7.9; 8; 8.13; 8.2; 8.21; 8.31; 8.4; 8.41; 8.45; 8.47; 8.5; 8.6; 8.8; 9; 9.6; 10];
y = [0; 0.01; 0.02; 0.1; 1; 1.1; 0.9; 0.6; 0; -0.5; -1; -1.1; -0.93; -0.9; -0.7; -0.6; -0.2; 0; 0.1; 0.12; 0; 0];
plot(x,y);
Example of end-goal You can see how the entire curve has shifted by the specified amounts but the whole shape is maintained.
I assume you want to stretch the parts individually by moving the four points. Therefore it is a simple operation of adjusting all the points within the bounds. The overall shape of the curve is maintained as long as your constraint of non-overlapping is fulfilled.
Of course it is not as easy as shifting only the points. But you can do the following for each part of the curve.
Here is an implementation doing exactly this. The indexes of the «moving points» are specified in
ind
and the amount to be moved in respect to the x-axis is specified inval
.This will give you the following result:
On request: For a better understanding what happens, the following code is a simplified version, only shifting the last point by the given amount of
value
.This will give you the following result: