// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
//  »Project«   Talina Gaming System (TgS) (∂)
//  »File«      TgS Common - Geometry 2D - Rectangle.i_inc
//  »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
//  »Version«   4.0
// ------------------------------------------------------------------------------------------------------------------------------ //
//  Copyright: © 2002-2010, Andrew Aye.  All Rights Reserved.
//  This software is free for non-commercial use. Redistribution and use in source and binary forms, with or without modification,
//  are permitted provided that the following conditions are met: 
//    Redistributions of source code must retain this copyright notice, this list of conditions and the following disclaimers. 
//    Redistributions in binary form must reproduce this copyright notice, this list of conditions and the following
//      disclaimers in the documentation and other materials provided with the distribution. 
//  Neither the names of the copyright owner nor the names of its contributors may be used to endorse or promote products derived
//  from this software without specific prior written permission. 
//  The intellectual property rights of the algorithms used reside with Andrew Aye.  You may not use this software, in whole or
//  in part, in support of any commercial product without the express written consent of the author.
//  There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //

TgINLINE TgBOOL V(tgGM_Is_Valid_RT2D)( V(CPCU_TgRECT2D) ptgRT0 )
{
    return (!F(tgCM_NaN)( ptgRT0->m_tyX0 ) && !F(tgCM_NaN)( ptgRT0->m_tyY0 ) &&
        !F(tgCM_NaN)( ptgRT0->m_tyX1 ) && !F(tgCM_NaN)( ptgRT0->m_tyY1 ));
}


TgINLINE TgVOID V(tgGM_TX_RT2D)( V(PCU_TgRECT2D) ptgRT0, const TYPE tyX, const TYPE tyY )
{
    TgGEOM_ASSERT_PARAM(!F(tgCM_NaN)( tyX ) && !F(tgCM_NaN)( tyY ));

    ptgRT0->m_tyX0 += tyX;
    ptgRT0->m_tyX1 += tyX;
    ptgRT0->m_tyY0 += tyY;
    ptgRT0->m_tyY1 += tyY;
}


TgINLINE TgVOID V(tgGM_Copy_TX_RT2D)( V(PCU_TgRECT2D) ptgRT0, V(CPCU_TgRECT2D) ptgRT1, const TYPE tyX, const TYPE tyY )
{
    TgGEOM_ASSERT_PARAM(V(tgGM_Is_Valid_RT2D)( ptgRT1 ) && !F(tgCM_NaN)( tyX ) && !F(tgCM_NaN)( tyY ));

    ptgRT0->m_tyX0 = ptgRT1->m_tyX0 + tyX;
    ptgRT0->m_tyX1 = ptgRT1->m_tyX1 + tyX;
    ptgRT0->m_tyY0 = ptgRT1->m_tyY0 + tyY;
    ptgRT0->m_tyY1 = ptgRT1->m_tyY1 + tyY;
}


TgINLINE TgVOID V(tgGM_Init_RT2D)(
    V(PCU_TgRECT2D) ptgRT0, const TYPE tyX0, const TYPE tyY0, const TYPE tyX1, const TYPE tyY1 )
{
    TgGEOM_ASSERT_PARAM(!F(tgCM_NaN)( tyX0 ) && !F(tgCM_NaN)( tyY0 ) && !F(tgCM_NaN)( tyX1 ) && !F(tgCM_NaN)( tyY1 ));

    ptgRT0->m_tyX0 = tyX0;
    ptgRT0->m_tyY0 = tyY0;
    ptgRT0->m_tyX1 = tyX1;
    ptgRT0->m_tyY1 = tyY1;
}


TgINLINE TgVOID V(tgGM_Init_X0_RT2D)( V(PCU_TgRECT2D) ptgRT0, const TYPE tyX0 )
{
    TgGEOM_ASSERT_PARAM(!F(tgCM_NaN)( tyX0 ));
    ptgRT0->m_tyX0 = tyX0;
}


TgINLINE TgVOID V(tgGM_Init_X1_RT2D)( V(PCU_TgRECT2D) ptgRT0, const TYPE tyX1 )
{
    TgGEOM_ASSERT_PARAM(!F(tgCM_NaN)( tyX1 ));
    ptgRT0->m_tyX1 = tyX1;
}


TgINLINE TgVOID V(tgGM_Init_Y0_RT2D)( V(PCU_TgRECT2D) ptgRT0, const TYPE tyY0 )
{
    TgGEOM_ASSERT_PARAM(!F(tgCM_NaN)( tyY0 ));
    ptgRT0->m_tyY0 = tyY0;
}


TgINLINE TgVOID V(tgGM_Init_Y1_RT2D)( V(PCU_TgRECT2D) ptgRT0, const TYPE tyY1 )
{
    TgGEOM_ASSERT_PARAM(!F(tgCM_NaN)( tyY1 ));
    ptgRT0->m_tyY1 = tyY1;
}


TgINLINE TgVOID V(tgGM_Copy_RT2D)( V(PCU_TgRECT2D) ptgRT0, V(CPCU_TgRECT2D) ptgRT1 )
{
    TgGEOM_ASSERT_PARAM(V(tgGM_Is_Valid_RT2D)( ptgRT1 ));

    ptgRT0->m_tyX0 = ptgRT1->m_tyX0;
    ptgRT0->m_tyX1 = ptgRT1->m_tyX1;
    ptgRT0->m_tyY0 = ptgRT1->m_tyY0;
    ptgRT0->m_tyY1 = ptgRT1->m_tyY1;
}


TgINLINE TYPE V(tgGM_Query_X0_RT2D)( V(CPCU_TgRECT2D) ptgRT0 )
{
    return (ptgRT0->m_tyX0);
}


TgINLINE TYPE V(tgGM_Query_X1_RT2D)( V(CPCU_TgRECT2D) ptgRT0 )
{
    return (ptgRT0->m_tyX1);
}


TgINLINE TYPE V(tgGM_Query_Y0_RT2D)( V(CPCU_TgRECT2D) ptgRT0 )
{
    return (ptgRT0->m_tyY0);
}


TgINLINE TYPE V(tgGM_Query_Y1_RT2D)( V(CPCU_TgRECT2D) ptgRT0 )
{
    return (ptgRT0->m_tyY1);
}


TgINLINE TYPE V(tgGM_Query_Width_RT2D)( V(CPCU_TgRECT2D) ptgRT0 )
{
    return (F(tgPM_ABS)( ptgRT0->m_tyX1 - ptgRT0->m_tyX0 ));
}


TgINLINE TYPE  V(tgGM_Query_Height_RT2D)( V(CPCU_TgRECT2D) ptgRT0 )
{
    return (F(tgPM_ABS)( ptgRT0->m_tyY1 - ptgRT0->m_tyY0 ));
}