What is the best algorithm for scaling a curve line made up of points? For example:
Curve line (A):
o
o
o o o
o o o o o
o o o o o
o o o o o
o o
If Curve Line (A) is scaled "Smaller" by 5% then it looks like this.
Output:
o
o o o
o o o o o
o o o o o
o o
If Curve Line (A) is scaled "Bigger" by 10% then it looks like this.
o
o
o
o
o o o
o o o o o
o o o o o
o o o o o
o o
o o
o o
I just want to know the algorithm, concept or the idea on how to solve it but to make it more clearer here are some java codes I want to achieved.
class CurveLine
{
public static ArrayList<float[]> getScaledCurveLine
(float[][] curveLine, float percentage, bool enlarged)
{
ArrayList<float[]> scaledCurveLine = new ArrayList<float[]>();
/*
Some Algorithm for Scaling Curve Line
*/
return scaledCurveLine; //new set of points
}
public static void main (string args[])
{
float [][] curveLine = new float[20][2]; //set of points
curveLine[0][0] = 0; //x1
curveLine[0][1] = 5; //y1
curveLine[1][0] = 1; //x2
//and so on..
ArrayList<float[]> largerCurveLine = getScaledCurveLine(curveLine, 20, true);
ArrayList<float[]> smallerCurveLine = getScaledCurveLine(curveLine, 20, false);
}
}
I read some algorithm such as "Nearest Neighbor Interpolation" in scaling points but I'm not sure if I'm on the right path :(.
I badly need to know how to do it guys :( thanks in advance.