01-09-2023, 06:31 PM
I checked. it will work. You should record the depth data in the following way and it will be compatible with this.
I hope everything is understandable in the example! good luck !
I hope everything is understandable in the example! good luck !
Code: (Select All)
Dim Shared deep(4, 4)
deep(0, 0) = 10
deep(1, 0) = 20
deep(0, 1) = 30
deep(1, 1) = 40
'deep-array now
' 10 20 0 0 0
' 30 40 0 0 0
' 0 0 0 0 0
' 0 0 0 0 0
' 0 0 0 0 0
Print exact_deep(0, 0) '10
Print exact_deep(0.5, 0) 'between 10 and 20
Print exact_deep(.5, .5) 'between central 10,20,30,40 (central 25)
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