Support Board
Date/Time: Sun, 19 Jan 2025 00:18:51 +0000
Post From: ACSIL - WilliamsR
[2018-02-28 23:13:01] |
JoseyWales - Posts: 67 |
If you were asking about how the sc.WilliamsR() function operates, it calls WilliamsR2_S behind the scenes: float GetHighest(SCFloatArrayRef In, int StartIndex, int Length) { float High = -FLT_MAX; // Get the high from the last Length indexes in the In array for (int SrcIndex = StartIndex; SrcIndex > StartIndex - Length; --SrcIndex) { if (SrcIndex < 0 || SrcIndex >= In.GetArraySize()) continue; if (In[SrcIndex] > High) High = In[SrcIndex]; } return High; } float GetLowest(SCFloatArrayRef In, int StartIndex, int Length) { float Low = FLT_MAX; // Get the low from the last Length indexes in the In array for (int SrcIndex = StartIndex; SrcIndex > StartIndex - Length; --SrcIndex) { if (SrcIndex < 0 || SrcIndex >= In.GetArraySize()) continue; if (In[SrcIndex] < Low) Low = In[SrcIndex]; } return Low; } SCFloatArrayRef WilliamsR2_S(SCFloatArrayRef InputDataHigh, SCFloatArrayRef InputDataLow, SCFloatArrayRef InputDataLast, SCFloatArrayRef Out, int Index, int Length) { if(Index < Length) Out[Index]=0; else { float High = GetHighest(InputDataHigh,Index, Length); float Low = GetLowest(InputDataLow,Index,Length); Out[Index] = 100 * ( High-InputDataLast[Index]) / (High - Low); } return Out; } |