# include <stdlib.h>
# include <stdio.h>
# include <time.h>
# include "blend.h"
/******************************************************************************/
double blend_101 ( double r, double x0, double x1 )
/******************************************************************************/
/*
Purpose:
BLEND_0D1 extends scalar data at endpoints to a line.
Diagram:
0-----r-----1
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
23 October 2018
Author:
John Burkardt
Parameters:
Input, double R, the coordinate where an interpolated value is desired.
Input, double X0, X1, the data values at the ends of the line.
Output, double BLEND_101, the interpolated data value at (R).
*/
{
double x;
x = ( 1.0 - r ) * x0 + r * x1;
return x;
}
/******************************************************************************/
double blend_102 ( double r, double s, double x00, double x01, double x10,
double x11 )
/******************************************************************************/
/*
Purpose:
BLEND_102 extends scalar point data into a square.
Diagram:
01------------11
| . |
| . |
|.....rs......|
| . |
| . |
00------------10
Formula:
Written in terms of R and S, the map has the form:
X(R,S) =
1 * ( + x00 )
+ r * ( - x00 + x10 )
+ s * ( - x00 + x01 )
+ r * s * ( + x00 - x10 - x01 + x11 )
Written in terms of the coefficients, the map has the form:
X(R,S) = x00 * ( 1 - r - s + r * s )
+ x01 * ( s - r * s )
+ x10 * ( r - r * s )
+ x11 * ( r * s )
= x00 * ( 1 - r ) * ( 1 - s )
+ x01 * ( 1 - r ) * s
+ x10 * r * ( 1 - s )
+ x11 * r s
The nonlinear term ( r * s ) has an important role:
If ( x01 + x10 - x00 - x11 ) is zero, then the input data lies in
a plane, and the mapping is affine. All the interpolated data
will lie on the plane defined by the four corner values. In
particular, on any line through the square, data values at
intermediate points will lie between the values at the endpoints.
If ( x01 + x10 - x00 - x11 ) is not zero, then the input data does
not lie in a plane, and the interpolation map is nonlinear. On
any line through the square, data values at intermediate points
may lie above or below the data values at the endpoints. The
size of the coefficient of r * s will determine how severe this
effect is.
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
23 October 2018
Author:
John Burkardt
Reference:
William Gordon,
Blending-Function Methods of Bivariate and Multivariate Interpolation
and Approximation,
SIAM Journal on Numerical Analysis,
Volume 8, Number 1, March 1971, pages 158-177.
William Gordon and Charles Hall,
Transfinite Element Methods: Blending-Function Interpolation over
Arbitrary Curved Element Domains,
Numerische Mathematik,
Volume 21, Number 1, 1973, pages 109-129.
William Gordon and Charles Hall,
Construction of Curvilinear Coordinate Systems and Application to
Mesh Generation,
International Journal of Numerical Methods in Engineering,
Volume 7, 1973, pages 461-477.
Joe Thompson, Bharat Soni, Nigel Weatherill,
Handbook of Grid Generation,
CRC Press, 1999.
Parameters:
Input, double R, S, the coordinates where an
interpolated value is desired.
Input, double X00, X01, X10, X11, the data values
at the corners.
Output, double BLEND_102, the interpolated data value at (R,S).
*/
{
double x;
x = + x00
+ r * ( - x00 + x10 )
+ s * ( - x00 + x01 )
+ r * s * ( + x00 - x10 - x01 + x11 );
return x;
}
/******************************************************************************/
double blend_103 ( double r, double s, double t, double x000, double x001,
double x010, double x011, double x100, double x101, double x110, double x111 )
/******************************************************************************/
/*
Purpose:
BLEND_103 extends scalar point data into a cube.
Diagram:
011--------------111
| |
| |
| |
| |
| |
001--------------101
*---------------*
| |
| |
| rst |
| |
| |
*---------------*
010--------------110
| |
| |
| |
| |
| |
000--------------100
Formula:
Written as a polynomial in R, S and T, the interpolation map has the
form
X(R,S,T) =
1 * ( + x000 )
+ r * ( - x000 + x100 )
+ s * ( - x000 + x010 )
+ t * ( - x000 + x001 )
+ r * s * ( + x000 - x100 - x010 + x110 )
+ r * t * ( + x000 - x100 - x001 + x101 )
+ s * t * ( + x000 - x010 - x001 + x011 )
+ r * s * t * ( - x000 + x100 + x010 + x001 - x011 - x101 - x110 + x111 )
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
23 October 2018
Author:
John Burkardt
Reference:
William Gordon,
Blending-Function Methods of Bivariate and Multivariate Interpolation
and Approximation,
SIAM Journal on Numerical Analysis,
Volume 8, Number 1, March 1971, pages 158-177.
William Gordon and Charles Hall,
Transfinite Element Methods: Blending-Function Interpolation over
Arbitrary Curved Element Domains,
Numerische Mathematik,
Volume 21, Number 1, 1973, pages 109-129.
William Gordon and Charles Hall,
Construction of Curvilinear Coordinate Systems and Application to
Mesh Generation,
International Journal of Numerical Methods in Engineering,
Volume 7, 1973, pages 461-477.
Joe Thompson, Bharat Soni, Nigel Weatherill,
Handbook of Grid Generation,
CRC Press, 1999.
Parameters:
Input, double R, S, T, the coordinates where an
interpolated value is desired.
Input, double X000, X001, X010, X011, X100, X101, X110,
X111, the data values at the corners.
Output, double BLEND_103, the interpolated data value at (R,S,T).
*/
{
double x;
/*
Interpolate the interior point.
*/
x =
1.0 * ( + x000 )
+ r * ( - x000 + x100 )
+ s * ( - x000 + x010 )
+ t * ( - x000 + x001 )
+ r * s * ( + x000 - x100 - x010 + x110 )
+ r * t * ( + x000 - x100 - x001 + x101 )
+ s * t * ( + x000 - x010 - x001 + x011 )
+ r * s * t * ( - x000 + x100 + x010 + x001 - x011 - x101 - x110 + x111 );
return x;
}
/******************************************************************************/
double blend_112 ( double r, double s, double x00, double x01, double x10,
double x11, double xr0, double xr1, double x0s, double x1s )
/******************************************************************************/
/*
Purpose:
BLEND_112 extends scalar data along the boundary into a square.
Diagram:
01-----r1-----11
| . |
| . |
0s.....rs.....1s
| . |
| . |
00-----r0-----10
Formula:
Written as a polynomial in R and S, the interpolation map has the form
X(R,S) =
1 * ( x0s + xr0 - x00 )
+ r * ( x00 + x1s - x0s - x10 )