• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1///////////////////////////////////////////////////////////////////////////////////
2/// OpenGL Mathematics (glm.g-truc.net)
3///
4/// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
5/// Permission is hereby granted, free of charge, to any person obtaining a copy
6/// of this software and associated documentation files (the "Software"), to deal
7/// in the Software without restriction, including without limitation the rights
8/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9/// copies of the Software, and to permit persons to whom the Software is
10/// furnished to do so, subject to the following conditions:
11///
12/// The above copyright notice and this permission notice shall be included in
13/// all copies or substantial portions of the Software.
14///
15/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21/// THE SOFTWARE.
22///
23/// @ref gtc_reciprocal
24/// @file glm/gtc/reciprocal.inl
25/// @date 2008-10-09 / 2012-04-07
26/// @author Christophe Riccio
27///////////////////////////////////////////////////////////////////////////////////
28
29#include "../trigonometric.hpp"
30#include <limits>
31
32namespace glm
33{
34	// sec
35	template <typename genType>
36	GLM_FUNC_QUALIFIER genType sec
37	(
38		genType const & angle
39	)
40	{
41		GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sec' only accept floating-point values");
42
43		return genType(1) / glm::cos(angle);
44	}
45
46	VECTORIZE_VEC(sec)
47
48	// csc
49	template <typename genType>
50	GLM_FUNC_QUALIFIER genType csc
51	(
52		genType const & angle
53	)
54	{
55		GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csc' only accept floating-point values");
56
57		return genType(1) / glm::sin(angle);
58	}
59
60	VECTORIZE_VEC(csc)
61
62	// cot
63	template <typename genType>
64	GLM_FUNC_QUALIFIER genType cot
65	(
66		genType const & angle
67	)
68	{
69		GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'cot' only accept floating-point values");
70
71		return genType(1) / glm::tan(angle);
72	}
73
74	VECTORIZE_VEC(cot)
75
76	// asec
77	template <typename genType>
78	GLM_FUNC_QUALIFIER genType asec
79	(
80		genType const & x
81	)
82	{
83		GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asec' only accept floating-point values");
84
85		return acos(genType(1) / x);
86	}
87
88	VECTORIZE_VEC(asec)
89
90	// acsc
91	template <typename genType>
92	GLM_FUNC_QUALIFIER genType acsc
93	(
94		genType const & x
95	)
96	{
97		GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsc' only accept floating-point values");
98
99		return asin(genType(1) / x);
100	}
101
102	VECTORIZE_VEC(acsc)
103
104	// acot
105	template <typename genType>
106	GLM_FUNC_QUALIFIER genType acot
107	(
108		genType const & x
109	)
110	{
111		GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acot' only accept floating-point values");
112
113		genType const pi_over_2 = genType(3.1415926535897932384626433832795 / 2.0);
114		return pi_over_2 - atan(x);
115	}
116
117	VECTORIZE_VEC(acot)
118
119	// sech
120	template <typename genType>
121	GLM_FUNC_QUALIFIER genType sech
122	(
123		genType const & angle
124	)
125	{
126		GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'sech' only accept floating-point values");
127
128		return genType(1) / glm::cosh(angle);
129	}
130
131	VECTORIZE_VEC(sech)
132
133	// csch
134	template <typename genType>
135	GLM_FUNC_QUALIFIER genType csch
136	(
137		genType const & angle
138	)
139	{
140		GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'csch' only accept floating-point values");
141
142		return genType(1) / glm::sinh(angle);
143	}
144
145	VECTORIZE_VEC(csch)
146
147	// coth
148	template <typename genType>
149	GLM_FUNC_QUALIFIER genType coth
150	(
151		genType const & angle
152	)
153	{
154		GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'coth' only accept floating-point values");
155
156		return glm::cosh(angle) / glm::sinh(angle);
157	}
158
159	VECTORIZE_VEC(coth)
160
161	// asech
162	template <typename genType>
163	GLM_FUNC_QUALIFIER genType asech
164	(
165		genType const & x
166	)
167	{
168		GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'asech' only accept floating-point values");
169
170		return acosh(genType(1) / x);
171	}
172
173	VECTORIZE_VEC(asech)
174
175	// acsch
176	template <typename genType>
177	GLM_FUNC_QUALIFIER genType acsch
178	(
179		genType const & x
180	)
181	{
182		GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acsch' only accept floating-point values");
183
184		return asinh(genType(1) / x);
185	}
186
187	VECTORIZE_VEC(acsch)
188
189	// acoth
190	template <typename genType>
191	GLM_FUNC_QUALIFIER genType acoth
192	(
193		genType const & x
194	)
195	{
196		GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'acoth' only accept floating-point values");
197
198		return atanh(genType(1) / x);
199	}
200
201	VECTORIZE_VEC(acoth)
202}//namespace glm
203