Anonymous user
Bilinear interpolation: Difference between revisions
→{{header|J}}: generalization
m (→{{header|J}}) |
(→{{header|J}}: generalization) |
||
Line 105:
<lang J>
Note 'FEA'
Here we develop a general method to generate isoparametric interpolants.
The interpolant is the dot product of the four function values with the values at the nodes.▼
Sum of four linear functions of two variables (xi, eta) is one at each of 4 nodes.▼
▲ The interpolant is the dot product of the four shape function values
Let the base element have nodal coordinates (corners) (x,y) with at +/-1.▼
at the coordinates within the element with the known values at the nodes.
▲
Line 115 ⟶ 118:
| |
| (0,0) |
| * |
| |
| |
| |
+---------------+
Line 126 ⟶ 129:
f1( 1,-1) = 1, f1(all other corners) is 0.
...
)▼
Choose a shape function.
Given (xi,eta) as the vector y form a vector of the
coefficients of the constants (1, xi, eta, and their product)
shape_function =: 1 , {. , {: , */
CORNERS NB. are the ordered coordinates of the corners
CORNERS =: 21 A. -.+:#:i.4▼
_1 _1
1 _1
_1 1
1 1
(=i.4) NB. rows of the identity matrix are the values of each shape functions at each corner
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
(=i.4x) %. shape_function"1 x: CORNERS NB. Compute the values of the constants as rational numbers.
1r4 1r4 1r4 1r4
_1r4 1r4 _1r4 1r4
_1r4 _1r4 1r4 1r4
1r4 _1r4 _1r4 1r4
This method extends to higher order interpolants having more nodes or to other dimensions.
interpolate =: (+/ .*) functions▼
▲)
mp =: +/ .* NB. matrix product
shape_function =: 1 , {. , {: , */
COEFFICIENTS =: (=i.4) %. shape_function"1 CORNERS
shape_functions =: COEFFICIENTS mp shape_function
</lang>
<pre>
Note
lower left has value 1,
lower right: 2
upper left: 2.2
upper right: 0.7
)
Line 158 ⟶ 178:
viewmat SADDLE
</pre>
[[Image:J_bilinear_interpolant.jpg
=={{header|Racket}}==
|