logo separator

[mkgmap-dev] HGT - getElevation()

From Frank Stinner Frank.Stinner at kabelmail.de on Tue Jan 9 19:35:13 GMT 2018

Hi Andrzej and Gerd,

for your examples

1 0
0 7

0 1
7 0

is 2 for the middlepoint mathematical correct: (h1 + h2 + h3 + h4) / 4.


My interpolation is the that:

We live in a world with "triangular" surface (like in a computergame).

We looking for a point p for the "surrounding" 4 points from the hgt. They form a rectangle (or square).

The 4 point form 2 triangles (for me):

hlt    hrt (height right top)
    +---+
    |  /|
    | / |
    |/  |
    +---+
hlb    hrb

We looking in which triangle our point p is.

A triangle define a plane and we can use a "3-Punkt-Gleichung" (don't know the english word).

For the left triangle:
use hlt as coordinate origin
             hrt -= hlt;
             hlb -= hlt;
             qy -= 1;
and calculate hlt + qx * hrt - qy * hlb

For the right triangle:
use hrb as coordinate origin
             hrt -= hrb;
             hlb -= hrb;
             qx -= 1;
and calculate hrb - qx * hlb + qy * hrt


This principle can be a little extend:

hlt    hrt
    +---+
    |\ /|
    | x |
    |/ \|
    +---+
hlb    hrb

It's easy to calculate the middlepoint and then we have 4 triangles. Then we have to decide, which triangle we need.

Just we have 4 triangles. (So we have our "triangular" surface.)

And so on ...


Frank

---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus




More information about the mkgmap-dev mailing list