/*********************************************************************************************************
* XMeaPrivate.h
* 2023-10-01: init
*
*********************************************************************************************************/
#ifndef XXX_XMEAPRIVATE_H_
#define XXX_XMEAPRIVATE_H_

#include "XMea.h"
#include "../YoseenAlg_Calibrate.h"

inline s32 _pnpoly(int nvert, s32* vertx, s32* verty, s32 testx, s32 testy) {
    s32 i, j, c = 0;
    for (i = 0, j = nvert - 1; i < nvert; j = i++) {
        bool v = (verty[i] > testy) != (verty[j] > testy);
        if (v) {
            s32 a = (testx - vertx[i]) * (verty[j] - verty[i]);
            s32 b = (vertx[j] - vertx[i]) * (testy - verty[i]);
            if ((verty[j] - verty[i]) > 0) {
                v = a < b;
            }
            else {
                v = a > b;
            }
        }
        if (v) {
            c = !c;
        }
    }
    return c;
}

inline void _dfh_global(DataFrameHeader* dfh, float& globalEnvTemp, float& globalEmi, s32& globalIrType) {
    globalEnvTemp = dfh->GlobalEnvTemp;
    globalEmi = dfh->GlobalEmi;
    globalIrType = dfh->GlobalIrType;
    if (0 == globalEmi) {
        globalEnvTemp = 20;
        globalEmi = 0.97f;
        globalIrType = 0;
    }
}

#endif
