Bicubic value interpolator. Reference: http://mrl.nyu.edu/~perlin/java/Bicubic.html. More...
Public Member Functions | |
| Bicubic (double[,] G) | |
| Calculates bicubic coefficients from 16 grid values. | |
| double | Calc (double x, double y) |
| Calculate bicubic interpolate on a unit square. | |
Bicubic value interpolator. Reference: http://mrl.nyu.edu/~perlin/java/Bicubic.html.
Definition at line 15 of file Bicubic.cs.
| NewGamePhysics.Mathematics.Bicubic.Bicubic | ( | double | G[,] | ) |
Calculates bicubic coefficients from 16 grid values.
| G | Values at at [-1,0,1,2]x[-1,0,1,2]. |
Definition at line 35 of file Bicubic.cs.
00036 { 00037 if ((G == null) && (G.Length != 16)) 00038 { 00039 throw new ArgumentOutOfRangeException("G"); 00040 } 00041 00042 double[,] T = new double[4, 4]; 00043 00044 // T = G * MT 00045 for (int i = 0; i < 4; i++) 00046 { 00047 for (int j = 0; j < 4; j++) 00048 { 00049 for (int k = 0; k < 4; k++) 00050 { 00051 T[i, j] += G[i, k] * M[j, k]; 00052 } 00053 } 00054 } 00055 00056 // C = M * T 00057 for (int i = 0; i < 4; i++) 00058 { 00059 for (int j = 0; j < 4; j++) 00060 { 00061 for (int k = 0; k < 4; k++) 00062 { 00063 C[i, j] += M[i, k] * T[k, j]; 00064 } 00065 } 00066 } 00067 }
| double NewGamePhysics.Mathematics.Bicubic.Calc | ( | double | x, | |
| double | y | |||
| ) |
Calculate bicubic interpolate on a unit square.
| x | The x coordinate. | |
| y | The y coordinate. |
Definition at line 75 of file Bicubic.cs.
00076 { 00077 if ((x < 0.0) || (x > 1.0)) 00078 { 00079 throw new ArgumentOutOfRangeException("x"); 00080 } 00081 00082 if ((y < 0.0) || (y > 1.0)) 00083 { 00084 throw new ArgumentOutOfRangeException("y"); 00085 } 00086 00087 return x * (x * (x * (y * (y * (y * C[0, 0] + C[0, 1]) + C[0, 2]) + C[0, 3]) 00088 + (y * (y * (y * C[1, 0] + C[1, 1]) + C[1, 2]) + C[1, 3])) 00089 + (y * (y * (y * C[2, 0] + C[2, 1]) + C[2, 2]) + C[2, 3])) 00090 + (y * (y * (y * C[3, 0] + C[3, 1]) + C[3, 2]) + C[3, 3]); 00091 }
1.6.2