GetCOGFromArray

From scripting
Revision as of 05:39, 22 April 2017 by Nickpisca (talk | contribs) (Created page with " Function GetCOGFromArray(ObjArr As Variant) As Variant Dim TotArr(2) Dim TotCounter As Integer TotCounter = 0 For X = 0 To UBound(ObjArr) If IsEmpty(ObjArr(X)) = Fal...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function GetCOGFromArray(ObjArr As Variant) As Variant
Dim TotArr(2)
Dim TotCounter As Integer
TotCounter = 0
For X = 0 To UBound(ObjArr)
    If IsEmpty(ObjArr(X)) = False Then
        Dim CurObj
        Set CurObj = ObjArr(X)
        Dim COMeas
        Set COMeas = TheSPAWorkbench.GetMeasurable(CurObj)
        Dim COGCoords(2)
        COMeas.GetCOG COGCoords
         
        TotCounter = TotCounter + 1
        TotArr(0) = TotArr(0) + COGCoords(0)
        TotArr(1) = TotArr(1) + COGCoords(1)
        TotArr(2) = TotArr(2) + COGCoords(2)
    End If
Next X
TotArr(0) = TotArr(0) / TotCounter
TotArr(1) = TotArr(1) / TotCounter
TotArr(2) = TotArr(2) / TotCounter
GetCOGFromArray = TotArr
End Function