Difference between pages "GenerateRealParametersFromDblArray" and "GetClosestIndex MEL"
From scripting
(Difference between pages)
(Created page with " Function GenerateRealParametersFromDblArray(ParmList As Parameters, DblArr As Variant) As Variant Dim ParmArr() ReDim ParmArr(UBound(DblArr)) For X = 0 To UBound(DblArr)...") |
(Created page with " global proc int GetClosestIndex(string $LocArr[], vector $XYZArr[], vector $CurVec, int $Skip[]) { //0001D LLC 2015 Nick Pisca float $WinDist = 1000000.0; int $WinInt =...") |
||
Line 1: | Line 1: | ||
− | + | global proc int GetClosestIndex(string $LocArr[], vector $XYZArr[], vector $CurVec, int $Skip[]) { | |
− | + | //0001D LLC 2015 Nick Pisca | |
− | + | float $WinDist = 1000000.0; | |
− | + | int $WinInt = -1; | |
− | + | for ($x=0;$x<size($LocArr);$x++) { | |
− | + | if ([[IsInIntArray_MEL|IsInIntArray]]($Skip, $x) == 0) { | |
− | + | vector $Diff = $XYZArr[$x] - $CurVec; | |
− | + | float $Dmag = mag($Diff); | |
+ | if ($Dmag < $WinDist) { | ||
+ | $WinDist = $Dmag; | ||
+ | $WinInt = $x; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | return $x; | ||
+ | } | ||
− | [[Category: | + | |
+ | ''More information on strings and arrays, read pages 28-37 in [http://stores.lulu.com/nickpisca YSYT]. | ||
+ | |||
+ | [[Category:MEL]] |
Latest revision as of 05:41, 22 April 2017
global proc int GetClosestIndex(string $LocArr[], vector $XYZArr[], vector $CurVec, int $Skip[]) { //0001D LLC 2015 Nick Pisca float $WinDist = 1000000.0; int $WinInt = -1; for ($x=0;$x<size($LocArr);$x++) { if (IsInIntArray($Skip, $x) == 0) { vector $Diff = $XYZArr[$x] - $CurVec; float $Dmag = mag($Diff); if ($Dmag < $WinDist) { $WinDist = $Dmag; $WinInt = $x; } } } return $x; }
More information on strings and arrays, read pages 28-37 in YSYT.