summaryrefslogtreecommitdiff
path: root/src/glm/gtx/fast_square_root.hpp
blob: c9ded29c4142c4286cf1fb0c7a7b80492f979440 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2006-01-04
// Updated : 2008-10-07
// Licence : This source is under MIT License
// File    : glm/gtx/fast_square_root.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependency:
// - GLM core
///////////////////////////////////////////////////////////////////////////////////////////////////
// Note:
// - Sqrt optimisation based on Newton's method, 
// www.gamedev.net/community/forums/topic.asp?topic id=139956
///////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef glm_gtx_fast_square_root
#define glm_gtx_fast_square_root

// Dependency:
#include "../glm.hpp"

#if(defined(GLM_MESSAGES) && !defined(glm_ext))
#	pragma message("GLM: GLM_GTX_fast_square_root extension included")
#endif

namespace glm{
namespace gtx{
namespace fast_square_root 	///< GLM_GTX_fast_square_root extension: Fast but less accurate implementations of square root based functions.
{
	/// \addtogroup gtx_fast_square_root
	/// @{

	//! Faster than the common sqrt function but less accurate.
	//! From GLM_GTX_fast_square_root extension.
	template <typename genType> 
	genType fastSqrt(genType const & x);

	//! Faster than the common inversesqrt function but less accurate.
	//! From GLM_GTX_fast_square_root extension.
	template <typename genType> 
	genType fastInverseSqrt(genType const & x);
		
	//! Faster than the common length function but less accurate.
	//! From GLM_GTX_fast_square_root extension.
	template <typename genType> 
	typename genType::value_type fastLength(genType const & x);

	//! Faster than the common distance function but less accurate.
	//! From GLM_GTX_fast_square_root extension.
	template <typename genType> 
	typename genType::value_type fastDistance(genType const & x, genType const & y);

	//! Faster than the common normalize function but less accurate.
	//! From GLM_GTX_fast_square_root extension.
	template <typename genType> 
	genType fastNormalize(genType const & x);

	/// @}
}// namespace fast_square_root
}// namespace gtx
}// namespace glm

#include "fast_square_root.inl"

namespace glm{using namespace gtx::fast_square_root;}

#endif//glm_gtx_fast_square_root