// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
//  »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 TgVOID V(tgGM_Constructor_DT)( V(PCU_TgDELTA) ptgDT0 )
{
    V(tgGM_Reset_DT)( ptgDT0 );
}


TgINLINE TgVOID V(tgGM_Reset_DT)( V(PCU_TgDELTA) ptgDT0 )
{
    ptgDT0->m_tvUDT = V(F_SET1)( MKL(0.0) );
    ptgDT0->m_tvDT = V(F_SET1)( MKL(0.0) );
    ptgDT0->m_fDT = MKL(0.0);
    ptgDT0->m_fDT_DT = MKL(0.0);
    ptgDT0->m_fInv_DT = MKL(0.0);
}


TgINLINE TgBOOL V(tgGM_Is_Valid_DT)( V(CPCU_TgDELTA) ptgDT )
{
    return (
        F(tgCM_NR1)( V(F_LSQ)( &ptgDT->m_tvUDT ) ) && V(F_Is_Vector_Valid)( &ptgDT->m_tvUDT ) &&
        V(F_Is_Vector_Valid)( &ptgDT->m_tvDT ) &&
        !F(tgCM_NaN)( ptgDT->m_fDT ) &&
        !F(tgCM_NaN)( ptgDT->m_fDT_DT ) &&
        !F(tgCM_NaN)( ptgDT->m_fInv_DT )
    );
}


TgINLINE TgVOID V(tgGM_TX_DT)( V(PCU_TgDELTA) ptgDT0, M34(CPCU_TgMAT) ptmM0 )
{
    ptgDT0->m_tvUDT = V(F_TX_V_34)( ptmM0, &ptgDT0->m_tvUDT );
    ptgDT0->m_tvDT = V(F_TX_V_34)( ptmM0, &ptgDT0->m_tvDT );
}


TgINLINE TgVOID V(tgGM_Copy_TX_DT)( V(PCU_TgDELTA) ptgDT0, V(CPCU_TgDELTA) ptgDT1, M34(CPCU_TgMAT) ptmM0 )
{
    ptgDT0->m_tvUDT = V(F_TX_V_34)( ptmM0, &ptgDT1->m_tvUDT );
    ptgDT0->m_tvDT = V(F_TX_V_34)( ptmM0, &ptgDT1->m_tvDT );
    ptgDT0->m_fDT = ptgDT1->m_fDT;
    ptgDT0->m_fDT_DT = ptgDT1->m_fDT_DT;
    ptgDT0->m_fInv_DT = ptgDT1->m_fInv_DT;
}


TgINLINE TgVOID V(tgGM_Set_DT)( V(PCU_TgDELTA) ptgDT0, V(CPCU_TgVEC) ptvDT )
{
    ptgDT0->m_tvUDT = V(F_NORM_LEN)( &ptgDT0->m_fDT, ptvDT );
    ptgDT0->m_tvDT = *ptvDT;
    ptgDT0->m_fDT_DT = ptgDT0->m_fDT*ptgDT0->m_fDT;
    ptgDT0->m_fInv_DT = F(tgPM_FSEL)( F(tgPM_ABS)( ptgDT0->m_fDT ) - F(TgEPS), MKL(1.0) / ptgDT0->m_fDT, MKL(0.0) );
}