// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // // Project: Talina Gaming System (TgS) (∂) // File: TgS Collision - Circle-Linear.inl // Author: Andrew Aye (EMail: andrew.aye@gmail.com, Web: http://www.andrewaye.com) // Version: 3.11 // // ------------------------------------------------------------------------------------------------------------------------------ // // // Copyright: © 2002-2008, 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". // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // #if !defined(_TGS_COLLISION_CIRCLE_LINEAR_INL_) #define _TGS_COLLISION_CIRCLE_LINEAR_INL_ #pragma once // ============================================================================================================================== // // Functions used for internal use - primitive based functions should be the primary system calls. // A linear is a generic term used to describe the set of 1D primitives. To avoid code duplication these functions are normally // created through templates where two boolean template parameters are used to indicate if the free variable is closed on a // particular side of the number line. // tgCI0 Circle (Input) // tvCIS0 Circle Origin (Input) // tvCIN0 Circle Plane Normal (Input) // tyRad Circle Radius (Input) // tvS0 Point (Input) // tvD0 Direction (Input) // tvCI0 The point of closest proximity on the circle. (Output) // tvLN0 The point of closest proximity on the line. (Output) // tyLN0 Parametric parameter to generate point of interest #1 based on the line. (Output) // ============================================================================================================================== // namespace TGS { // START TGS /////////////////////////////////////////////////////////////////////////////////////////////////////// namespace COL { // START COL /////////////////////////////////////////////////////////////////////////////////////////////////////// // ============================================================================================================================== // template <typename TYPE, int DIM, bool bC0, bool bC1> TgFORCEINLINE TYPE TTgCSQ_CILN<TYPE,DIM,bC0,bC1>::DO( PC_(VECTOR,DIM) ptvCI0, TYPE *ptyLN0, CR_(CIRCLE,DIM) tgCI0, M_(VECTOR,DIM) tvS0, M_(VECTOR,DIM) tvD0 ) { const TYPE tyDistSq = DO( ptvCI0, ptyLN0, tgCI0.Query_Origin(), tgCI0.Query_Normal(), tgCI0.Query_Radius(), tvS0, tvD0 ); return (P::FSEL( tyDistSq, tyDistSq, -LIMITS<TYPE>::MAX )); }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // template <typename TYPE, int DIM, bool bC0, bool bC1> TgFORCEINLINE TYPE TTgCSQ_CILN<TYPE,DIM,bC0,bC1>::DO( PC_(VECTOR,DIM) ptvCI0, PC_(VECTOR,DIM) ptvLN0, M_(VECTOR,DIM) tvCIS0, M_(VECTOR,DIM) tvCIN0, const TYPE tyRad, M_(VECTOR,DIM) tvS0, M_(VECTOR,DIM) tvD0 ) { TYPE tyLN0; const TYPE tyDistSq = DO( ptvCI0,&tyLN0, tvCIS0,tvCIN0,tyRad, tvS0,tvD0 ); *ptvLN0 = MATH::F_ADD( tvS0, MATH::F_MUL( tyLN0, tvD0 ) ); return (P::FSEL( tyDistSq, tyDistSq, -LIMITS<TYPE>::MAX )); }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // template <typename TYPE, int DIM, bool bC0, bool bC1> TgFORCEINLINE TYPE TTgCSQ_CILN<TYPE,DIM,bC0,bC1>::DO( PC_(VECTOR,DIM) ptvCI0, PC_(VECTOR,DIM) ptvLN0, CR_(CIRCLE,DIM) tgCI0, M_(VECTOR,DIM) tvS0, M_(VECTOR,DIM) tvD0 ) { TYPE tyLN0; const TYPE tyDistSq = DO( ptvCI0,&tyLN0, tgCI0.Query_Origin(),tgCI0.Query_Normal(),tgCI0.Query_Radius(), tvS0,tvD0 ); *ptvLN0 = MATH::F_ADD( tvS0, MATH::F_MUL( tyLN0, tvD0 ) ); return (P::FSEL( tyDistSq, tyDistSq, -LIMITS<TYPE>::MAX )); }; // ============================================================================================================================== // }; // END COL ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }; // END TGS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #endif // END ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////