// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // »Project« Teikitu Gaming System (TgS) (∂) // »File« TgS Collision - F - Parallelogram-Triangle.i_inc // »Author« Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com) // »Version« 4.0 // »Keywords« Collision;Distance;Closest;Intersect;Penetrate;Sweep;Parallelogram; // ------------------------------------------------------------------------------------------------------------------------------ // // 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". // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // == Collision ================================================================================================================= // TgINLINE TYPE V(tgCO_F_DistSq_PE_ST)( V(CPCU_TgPARALLELOGRAM) psPE0, V(CPCU_TgSTRI) psST0 ) { TYPE fPE00, fPE01, fET10, fET11; return (V(tgCO_F_ParamSq_PE_ST)( &fPE00,&fPE01, &fET10,&fET11, psPE0, psST0 )); } TgINLINE TYPE V(tgCO_F_Dist_PE_ST)( V(CPCU_TgPARALLELOGRAM) psPE0, V(CPCU_TgSTRI) psST0 ) { const TYPE fDistSq = V(tgCO_F_DistSq_PE_ST)( psPE0, psST0 ); return (F(tgPM_FSEL)( fDistSq, F(tgPM_SQRT)( fDistSq ), -F(KTgMAX) )); } TgINLINE TYPE V(tgCO_F_ClosestSq_PE_ST)( V(PCU_TgVEC) pvPE0, V(PCU_TgVEC) pvST0, V(CPCU_TgPARALLELOGRAM) psPE0, V(CPCU_TgSTRI) psST0 ) { TYPE fPE0,fPE1, fST0,fST1; const TYPE fDistSq = V(tgCO_F_ParamSq_PE_ST)( &fPE0,&fPE1, &fST0,&fST1, psPE0, psST0 ); V(C_TgVEC) vK0 = V(F_MUL_SV)( fPE0, psPE0->m_avEdge + 0 ); V(C_TgVEC) vK1 = V(F_MUL_SV)( fPE1, psPE0->m_avEdge + 1 ); V(C_TgVEC) vK2 = V(F_MUL_SV)( fST0, psST0->m_sCT.m_sET.m_avEdge + 0 ); V(C_TgVEC) vK3 = V(F_MUL_SV)( fST1, psST0->m_sCT.m_sET.m_avEdge + 2 ); V(C_TgVEC) vK4 = V(F_ADD_VV)( &psPE0->m_vOrigin, &vK0 ); V(C_TgVEC) vK5 = V(F_ADD_VV)( psST0->m_sCT.m_sET.m_sPT.m_avPoint, &vK2 ); *pvPE0 = V(F_ADD_VV)( &vK4, &vK1 ); *pvST0 = V(F_SUB_VV)( &vK5, &vK3 ); return (fDistSq); } TgINLINE TYPE V(tgCO_F_Closest_PE_ST)( V(PCU_TgVEC) pvPE0, V(PCU_TgVEC) pvST0, V(CPCU_TgPARALLELOGRAM) psPE0, V(CPCU_TgSTRI) psST0 ) { const TYPE fDistSq = V(tgCO_F_ClosestSq_PE_ST)( pvPE0, pvST0, psPE0, psST0 ); return (F(tgPM_FSEL)( fDistSq, F(tgPM_SQRT)( fDistSq ), -F(KTgMAX) )); } TgINLINE TYPE V(tgCO_F_Param_PE_ST)( PCU_TYPE pfPE0, PCU_TYPE pfPE1, PCU_TYPE pfST0, PCU_TYPE pfST1, V(CPCU_TgPARALLELOGRAM) psPE0, V(CPCU_TgSTRI) psST0 ) { const TYPE fDistSq = V(tgCO_F_ParamSq_PE_ST)( pfPE0,pfPE1, pfST0,pfST1, psPE0, psST0 ); return (F(tgPM_FSEL)( fDistSq, F(tgPM_SQRT)( fDistSq ), -F(KTgMAX) )); }