• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1///////////////////////////////////////////////////////////////////////////////////////////////////
2// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
3///////////////////////////////////////////////////////////////////////////////////////////////////
4// Created : 2006-01-08
5// Updated : 2011-10-14
6// Licence : This source is under MIT License
7// File    : glm/gtx/fast_trigonometry.inl
8///////////////////////////////////////////////////////////////////////////////////////////////////
9
10namespace glm
11{
12	// sin
13	template <typename T>
14	GLM_FUNC_QUALIFIER T fastSin(T const & x)
15	{
16		return x - ((x * x * x) / T(6)) + ((x * x * x * x * x) / T(120)) - ((x * x * x * x * x * x * x) / T(5040));
17	}
18
19	VECTORIZE_VEC(fastSin)
20
21	// cos
22	template <typename T>
23	GLM_FUNC_QUALIFIER T fastCos(T const & x)
24	{
25		return T(1) - (x * x * T(0.5)) + (x * x * x * x * T(0.041666666666)) - (x * x * x * x * x * x * T(0.00138888888888));
26	}
27
28	VECTORIZE_VEC(fastCos)
29
30	// tan
31	template <typename T>
32	GLM_FUNC_QUALIFIER T fastTan(T const & x)
33	{
34		return x + (x * x * x * T(0.3333333333)) + (x * x * x * x * x * T(0.1333333333333)) + (x * x * x * x * x * x * x * T(0.0539682539));
35	}
36
37	VECTORIZE_VEC(fastTan)
38
39	// asin
40	template <typename T>
41	GLM_FUNC_QUALIFIER T fastAsin(T const & x)
42	{
43		return x + (x * x * x * T(0.166666667)) + (x * x * x * x * x * T(0.075)) + (x * x * x * x * x * x * x * T(0.0446428571)) + (x * x * x * x * x * x * x * x * x * T(0.0303819444));// + (x * x * x * x * x * x * x * x * x * x * x * T(0.022372159));
44	}
45
46	VECTORIZE_VEC(fastAsin)
47
48	// acos
49	template <typename T>
50	GLM_FUNC_QUALIFIER T fastAcos(T const & x)
51	{
52		return T(1.5707963267948966192313216916398) - fastAsin(x); //(PI / 2)
53	}
54
55	VECTORIZE_VEC(fastAcos)
56
57	// atan
58	template <typename T>
59	GLM_FUNC_QUALIFIER T fastAtan(T const & y, T const & x)
60	{
61		T sgn = sign(y) * sign(x);
62		return abs(fastAtan(y / x)) * sgn;
63	}
64
65	VECTORIZE_VEC_VEC(fastAtan)
66
67	template <typename T>
68	GLM_FUNC_QUALIFIER T fastAtan(T const & x)
69	{
70		return x - (x * x * x * T(0.333333333333)) + (x * x * x * x * x * T(0.2)) - (x * x * x * x * x * x * x * T(0.1428571429)) + (x * x * x * x * x * x * x * x * x * T(0.111111111111)) - (x * x * x * x * x * x * x * x * x * x * x * T(0.0909090909));
71	}
72
73	VECTORIZE_VEC(fastAtan)
74
75}//namespace glm
76