Home | History | Annotate | Download | only in gtx
      1 //////////////////////////////////////////////////////////////////////////////////
      2 // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
      3 //////////////////////////////////////////////////////////////////////////////////
      4 // Created : 2007-09-28
      5 // Updated : 2008-10-07
      6 // Licence : This source is under MIT License
      7 // File    : glm/gtx/normalize_dot.inl
      8 //////////////////////////////////////////////////////////////////////////////////
      9 
     10 namespace glm
     11 {
     12 	template <typename genType> 
     13 	GLM_FUNC_QUALIFIER genType normalizeDot
     14 	(
     15 		genType const & x, 
     16 		genType const & y
     17 	)
     18 	{
     19 		return 
     20 			glm::dot(x, y) * 
     21 			glm::inversesqrt(glm::dot(x, x) * 
     22 			glm::dot(y, y));
     23 	}
     24 
     25 	template <typename T, precision P>
     26 	GLM_FUNC_QUALIFIER T normalizeDot
     27 	(
     28 		detail::tvec2<T, P> const & x, 
     29 		detail::tvec2<T, P> const & y
     30 	)
     31 	{
     32 		return 
     33 			glm::dot(x, y) * 
     34 			glm::inversesqrt(glm::dot(x, x) * 
     35 			glm::dot(y, y));
     36 	}
     37 
     38 	template <typename T, precision P>
     39 	GLM_FUNC_QUALIFIER T normalizeDot
     40 	(
     41 		detail::tvec3<T, P> const & x, 
     42 		detail::tvec3<T, P> const & y
     43 	)
     44 	{
     45 		return 
     46 			glm::dot(x, y) * 
     47 			glm::inversesqrt(glm::dot(x, x) * 
     48 			glm::dot(y, y));
     49 	}
     50 
     51 	template <typename T, precision P>
     52 	GLM_FUNC_QUALIFIER T normalizeDot
     53 	(
     54 		detail::tvec4<T, P> const & x, 
     55 		detail::tvec4<T, P> const & y
     56 	)
     57 	{
     58 		return 
     59 			glm::dot(x, y) * 
     60 			glm::inversesqrt(glm::dot(x, x) * 
     61 			glm::dot(y, y));
     62 	}
     63 
     64 	template <typename genType> 
     65 	GLM_FUNC_QUALIFIER genType fastNormalizeDot
     66 	(
     67 		genType const & x, 
     68 		genType const & y
     69 	)
     70 	{
     71 		return 
     72 			glm::dot(x, y) * 
     73 			fastInverseSqrt(glm::dot(x, x) * 
     74 			glm::dot(y, y));
     75 	}
     76 
     77 	template <typename T, precision P>
     78 	GLM_FUNC_QUALIFIER T fastNormalizeDot
     79 	(
     80 		detail::tvec2<T, P> const & x, 
     81 		detail::tvec2<T, P> const & y
     82 	)
     83 	{
     84 		return 
     85 			glm::dot(x, y) * 
     86 			fastInverseSqrt(glm::dot(x, x) * 
     87 			glm::dot(y, y));
     88 	}
     89 
     90 	template <typename T, precision P>
     91 	GLM_FUNC_QUALIFIER T fastNormalizeDot
     92 	(
     93 		detail::tvec3<T, P> const & x, 
     94 		detail::tvec3<T, P> const & y
     95 	)
     96 	{
     97 		return 
     98 			glm::dot(x, y) * 
     99 			fastInverseSqrt(glm::dot(x, x) * 
    100 			glm::dot(y, y));
    101 	}
    102 
    103 	template <typename T, precision P>
    104 	GLM_FUNC_QUALIFIER T fastNormalizeDot
    105 	(
    106 		detail::tvec4<T, P> const & x, 
    107 		detail::tvec4<T, P> const & y
    108 	)
    109 	{
    110 		return 
    111 			glm::dot(x, y) * 
    112 			fastInverseSqrt(glm::dot(x, x) * 
    113 			glm::dot(y, y));
    114 	}
    115 }//namespace glm
    116