01-09-2023, 03:24 PM
I rewrote it to universal. in this example, the DEEP array records the height values. The height value can be easily read.
1 square grid = 2 triangles. He counts with the one that falls into a triangle.
1 square grid = 2 triangles. He counts with the one that falls into a triangle.
Code: (Select All)
Function exact_deep (x, y)
x1 = Int(x): x2 = x1 + 1: aposx = (x - x1)
y1 = Int(y): y2 = y1 + 1: aposy = (y - y1)
p1 = deep(x2, y1)
p2 = deep(x1, y2)
If aposx * aposx + aposy * aposy < (1 - aposx) * (1 - aposx) + (1 - aposy) * (1 - aposy) Then
p0 = deep(x1, y1)
q = p0 + aposx * (p1 - p0) + aposy * (p2 - p0)
Else
p3 = deep(x2, y2)
q = p3 + (1 - aposy) * (p1 - p3) + (1 - aposx) * (p2 - p3)
End If
exact_deep = q
End Function