### Split TIN Triangle - Elevation Range Point

In the last post I showed a snippet of code to calculate the area of a TIN Triangle for the entire triangle. This post will show a way to calculate the point where the elevation range splits a side of a TIN Triangle. The code checks both cases of the elevation range splitting the triangle length. The If Then statement checks the item in brackets first and then compares the Or statement.

Dim dPt(0 to 2) As Double ' X,Y,Z

Dim dElev As Double

dElev = 38

' Check to see if the TIN Triangle sides are split by an Elevation Range.

If (dOT(i + 2) > dElev And dOT(i + 5) < dElev) Or (dOT(i + 2) < dElev And dOT(i + 5) > dElev) Then

dPt(0) = dOT(i) - ((dOT(i + 2) - dElev) * (dOT(i) - dOT(i + 3)) / (dOT(i + 2) - dOT(i + 5))) ' X

dPt(1) = dOT(i + 1) - ((dOT(i + 2) - dElev) * (dOT(i + 1) - dOT(i + 4)) / (dOT(i + 2) - dOT(i + 5))) ' Y

dPt(2) = dElev ' Z

End If

...

The equations show the first side of the triangle, the other two sides are similar. To help you out here are the equations reduced to X,Y,Z notation.

If (Z1 > dElev And Z2 < dElev) Or (Z1 < dElev And Z2 > dElev) Then

X' = X1 - ((Z1 - dElev) * (X1 - X2) / (Z1 - Z2))

Y' = Y1 - ((Z1 - dElev) * (Y1 - Y2) / (Z1 - Z2))

Z' = dElev ' Z

End If

So that's one way to calculate the point where the elevation range crosses the TIN Triangle. If you do use the code you'll want to make sure that the denominator does not equal to 0, since it isn't possible.

## No comments:

Post a Comment