Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu 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.51 / »GUID« A9981407-3EC9-42AF-8B6F-8BE6DD919615                                                                                                        */
/*   -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/*  Copyright: © 2002-2017, 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:
        Redistribution of source code must retain this copyright notice, this list of conditions and the following disclaimers.
        Redistribution 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.
    The name of the author may not 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".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/* == Common ============================================================================================================================================================ */

/* ---- V(tgGM_Is_Valid_RT2D) ------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgBOOL V(tgGM_Is_Valid_RT2D)( V(CPCU_TgRECT2D) psRT0 )
{
    return (TgTRUE != F(tgPM_NAN)(psRT0->m_fX0) && TgTRUE != F(tgPM_NAN)( psRT0->m_fY0 ) && TgTRUE != F(tgPM_NAN)( psRT0->m_fX1)  && TgTRUE != F(tgPM_NAN)( psRT0->m_fY1 ) ? TgTRUE : TgFALSE);
}


/* ---- V(tgGM_TX_RT2D) ------------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgVOID V(tgGM_TX_RT2D)( V(PCU_TgRECT2D) psRT0, const TYPE fX, const TYPE fY )
{
    TgGEOM_ASSERT_PARAM(TgTRUE != F(tgPM_NAN)(fX) && TgTRUE != F(tgPM_NAN)(fY));

    psRT0->m_fX0 += fX;
    psRT0->m_fX1 += fX;
    psRT0->m_fY0 += fY;
    psRT0->m_fY1 += fY;
}


/* ---- V(tgGM_Copy_TX_RT2D) -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgVOID V(tgGM_Copy_TX_RT2D)( V(PCU_TgRECT2D) psRT0, V(CPCU_TgRECT2D) psRT1, const TYPE fX, const TYPE fY )
{
    TgGEOM_ASSERT_PARAM(TgTRUE == V(tgGM_Is_Valid_RT2D)(psRT1) && TgTRUE != F(tgPM_NAN)(fX) && TgTRUE != F(tgPM_NAN)(fY));

    psRT0->m_fX0 = psRT1->m_fX0 + fX;
    psRT0->m_fX1 = psRT1->m_fX1 + fX;
    psRT0->m_fY0 = psRT1->m_fY0 + fY;
    psRT0->m_fY1 = psRT1->m_fY1 + fY;
}


/* ---- V(tgGM_Init_RT2D) ----------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgVOID V(tgGM_Init_RT2D)( V(PCU_TgRECT2D) psRT0, const TYPE fX0, const TYPE fY0, const TYPE fX1, const TYPE fY1 )
{
    TgGEOM_ASSERT_PARAM(TgTRUE != F(tgPM_NAN)(fX0) && TgTRUE != F(tgPM_NAN)(fY0) && TgTRUE != F(tgPM_NAN)(fX1) && TgTRUE != F(tgPM_NAN)(fY1));

    psRT0->m_fX0 = fX0;
    psRT0->m_fY0 = fY0;
    psRT0->m_fX1 = fX1;
    psRT0->m_fY1 = fY1;
}


/* ---- V(tgGM_Init_X0_RT2D) -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgVOID V(tgGM_Init_X0_RT2D)( V(PCU_TgRECT2D) psRT0, const TYPE fX0 )
{
    TgGEOM_ASSERT_PARAM(TgTRUE != F(tgPM_NAN)(fX0));
    psRT0->m_fX0 = fX0;
}


/* ---- V(tgGM_Init_X1_RT2D) -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgVOID V(tgGM_Init_X1_RT2D)( V(PCU_TgRECT2D) psRT0, const TYPE fX1 )
{
    TgGEOM_ASSERT_PARAM(TgTRUE != F(tgPM_NAN)(fX1));
    psRT0->m_fX1 = fX1;
}


/* ---- V(tgGM_Init_Y0_RT2D) -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgVOID V(tgGM_Init_Y0_RT2D)( V(PCU_TgRECT2D) psRT0, const TYPE fY0 )
{
    TgGEOM_ASSERT_PARAM(TgTRUE != F(tgPM_NAN)(fY0));
    psRT0->m_fY0 = fY0;
}


/* ---- V(tgGM_Init_Y1_RT2D) -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgVOID V(tgGM_Init_Y1_RT2D)( V(PCU_TgRECT2D) psRT0, const TYPE fY1 )
{
    TgGEOM_ASSERT_PARAM(TgTRUE != F(tgPM_NAN)(fY1));
    psRT0->m_fY1 = fY1;
}


/* ---- V(tgGM_Copy_RT2D) ----------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TgVOID V(tgGM_Copy_RT2D)( V(PCU_TgRECT2D) psRT0, V(CPCU_TgRECT2D) psRT1 )
{
    TgGEOM_ASSERT_PARAM(TgTRUE == V(tgGM_Is_Valid_RT2D)(psRT1));

    psRT0->m_fX0 = psRT1->m_fX0;
    psRT0->m_fX1 = psRT1->m_fX1;
    psRT0->m_fY0 = psRT1->m_fY0;
    psRT0->m_fY1 = psRT1->m_fY1;
}


/* ---- V(tgGM_Query_X0_RT2D) ------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TYPE V(tgGM_Query_X0_RT2D)( V(CPCU_TgRECT2D) psRT0 )
{
    return (psRT0->m_fX0);
}


/* ---- V(tgGM_Query_X1_RT2D) ------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TYPE V(tgGM_Query_X1_RT2D)( V(CPCU_TgRECT2D) psRT0 )
{
    return (psRT0->m_fX1);
}


/* ---- V(tgGM_Query_Y0_RT2D) ------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TYPE V(tgGM_Query_Y0_RT2D)( V(CPCU_TgRECT2D) psRT0 )
{
    return (psRT0->m_fY0);
}


/* ---- V(tgGM_Query_Y1_RT2D) ------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TYPE V(tgGM_Query_Y1_RT2D)( V(CPCU_TgRECT2D) psRT0 )
{
    return (psRT0->m_fY1);
}


/* ---- V(tgGM_Query_Width_RT2D) ---------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TYPE V(tgGM_Query_Width_RT2D)( V(CPCU_TgRECT2D) psRT0 )
{
    return (F(tgPM_ABS)( psRT0->m_fX1 - psRT0->m_fX0) );
}


/* ---- V(tgGM_Query_Height_RT2D) --------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgINLINE TYPE  V(tgGM_Query_Height_RT2D)( V(CPCU_TgRECT2D) psRT0 )
{
    return (F(tgPM_ABS)( psRT0->m_fY1 - psRT0->m_fY0) );
}