开发者

How to do value interpolations in a visual basic array?

开发者 https://www.devze.com 2023-01-25 18:05 出处:网络
HI If there is a uniform terrain with a specific degree of roughness (know contour interval), how an interpolation can be performed if the grid around a specific point is known?

HI

If there is a uniform terrain with a specific degree of roughness (know contour interval), how an interpolation can be performed if the grid around a specific point is known?

For example, if the starting elevation is 105m and the contour interval is 0.2m for example. Additionally, if a grid of 7x7 is available (which is an array in VB, TERR(6,6) ). If the location of 105 is in TERR(4,3) then the other values around it should decrease by the value of 0.2 and it will look like something like this:

104.2 104.2 104.2 104.2 104.2 104.2 104.2

104.4 104.4 104.4 104.4 104.4 104.4 104.4

104.4 104.6 104.6 104.6 104.6 104.6 104.4

104.4 104.6 104.8 104.8 104.8 104.6 104.4

104.4 104.6 104.8 105 104.8 104.6 104.4

104.4 104.6 104.8 104.8 104.8 104.6 104.4

104.4 104.6 104.6 104.6 104.6 104.6 104.4

The distribution of the numbers in the array will vary by changing the position of the starting elevation and the size of the array (grid).

I found many articles and interpolation methods (neighbourhood, cubic, bilinear…etc), but no one开发者_运维知识库 was close enough to this problem.

Thank you!


This is shaped like a pyramid, with corners.

If you want to make it look like a cone, you can calculate the value based on the direct distance rather than the x or y distance. In this example, the horizontal and vertical values (relative to 105) would be the same as they are now. But from TERR(4,3) to TERR(3,2) would be a "distance" of sqrt(1^2 + 1^2), or 1.414. So multiple 0.2 by 1.414 and assign TERR(3,2) a value of 105-.2828 = 102.7272

dx = x distance from known value dy = y distance from known value val = known value dval = difference in value over a distance of 1 TERR(dx, dy) = val + sqrt(dx^2+dy^2)

This is simple and linear. There are lots of ways to fit a smooth 3D curve over the points, but there needs to be more information input and there are lots of ways to do it.

0

精彩评论

暂无评论...
验证码 换一张
取 消