Difference between revisions of "GetXYZFromArray"
From scripting
(Created page with " Function GetXYZFromArray(PtArr As Variant, XVal As Double, YVal As Double, ZVal As Double, Closest1Farthest0 As Integer) As Integer Dim WinningVal As Double If Closest1Fart...") |
(No difference)
|
Latest revision as of 06:02, 22 April 2017
Function GetXYZFromArray(PtArr As Variant, XVal As Double, YVal As Double, ZVal As Double, Closest1Farthest0 As Integer) As Integer Dim WinningVal As Double If Closest1Farthest0 = 1 Then WinningVal = 1000000023 Else WinningVal = -1000000023 End If Dim WinningInt As Integer WinningInt = 0 For X = 0 To UBound(PtArr) Dim CurDistVal As Double CurDistVal = find3DDistance(XVal, YVal, ZVal, PtArr(X)(0), PtArr(X)(1), PtArr(X)(2)) If Closest1Farthest0 = 1 Then If WinningVal > CurDistVal Then WinningVal = CurDistVal WinningInt = X End If Else If WinningVal < CurDistVal Then WinningVal = CurDistVal WinningInt = X End If End If Next X GetXYZFromArray = WinningInt End Function