//
// Generated by dtk
// Translation Unit: c_m2d_g_box.cpp
//

#include "SSystem/SComponent/c_m2d_g_box.h"
#include "MSL_C/math.h"
#include "dolphin/types.h"

/* 8024A0E0-8024A104       .text Set__8cM2dGBoxFR3cXyR3cXy */
void cM2dGBox::Set(cXy& p0, cXy& p1) {
    mP0 = p0;
    mP1 = p1;
}

/* 8024A104-8024A400       .text GetLen__8cM2dGBoxCFRC3cXy */
f32 cM2dGBox::GetLen(const cXy& p) const {
    // inside the box
    if (p.x >= mP0.x && p.x <= mP1.x && p.y >= mP0.y && p.y <= mP1.y)
        return 0.0f;

    // TODO: other checks
    
    float distX = abs(mP0.x - p.x);
    float distY = abs(mP0.y - p.y);
    return distX < distY ? distX : distY;
}
