~mir-team/mir/in-process-egl+input-conglomeration

« back to all changes in this revision

Viewing changes to 3rd_party/glm/glm/core/func_trigonometric.inl

Merged trunk and fixed issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
///////////////////////////////////////////////////////////////////////////////////
2
 
/// OpenGL Mathematics (glm.g-truc.net)
3
 
///
4
 
/// Copyright (c) 2005 - 2012 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 core
24
 
/// @file glm/core/func_trigonometric.inl
25
 
/// @date 2008-08-03 / 2011-06-15
26
 
/// @author Christophe Riccio
27
 
///////////////////////////////////////////////////////////////////////////////////
28
 
 
29
 
#include "_vectorize.hpp"
30
 
 
31
 
namespace glm
32
 
{
33
 
        // radians
34
 
        template <typename genType>
35
 
        GLM_FUNC_QUALIFIER genType radians
36
 
        (
37
 
                genType const & degrees
38
 
        )
39
 
        {
40
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'radians' only accept floating-point input");
41
 
 
42
 
                genType const pi = genType(3.1415926535897932384626433832795);
43
 
                return degrees * (pi / genType(180));
44
 
        }
45
 
 
46
 
        VECTORIZE_VEC(radians)
47
 
        
48
 
        // degrees
49
 
        template <typename genType>
50
 
        GLM_FUNC_QUALIFIER genType degrees
51
 
        (
52
 
                genType const & radians
53
 
        )
54
 
        {
55
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'degrees' only accept floating-point input");
56
 
 
57
 
                const genType pi = genType(3.1415926535897932384626433832795);
58
 
                return radians * (genType(180) / pi);
59
 
        }
60
 
 
61
 
        VECTORIZE_VEC(degrees)
62
 
 
63
 
        // sin
64
 
        template <typename genType>
65
 
        GLM_FUNC_QUALIFIER genType sin
66
 
        (
67
 
                genType const & angle
68
 
        )
69
 
        {
70
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sin' only accept floating-point input");
71
 
 
72
 
                return ::std::sin(angle);
73
 
        }
74
 
 
75
 
        VECTORIZE_VEC(sin)
76
 
 
77
 
        // cos
78
 
        template <typename genType>
79
 
        GLM_FUNC_QUALIFIER genType cos(genType const & angle)
80
 
        {
81
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'cos' only accept floating-point input");
82
 
 
83
 
                return ::std::cos(angle);
84
 
        }
85
 
 
86
 
        VECTORIZE_VEC(cos)
87
 
 
88
 
        // tan
89
 
        template <typename genType>
90
 
        GLM_FUNC_QUALIFIER genType tan
91
 
        (
92
 
                genType const & angle
93
 
        )
94
 
        {
95
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'tan' only accept floating-point input");
96
 
 
97
 
                return ::std::tan(angle);
98
 
        }
99
 
 
100
 
        VECTORIZE_VEC(tan)
101
 
 
102
 
        // asin
103
 
        template <typename genType>
104
 
        GLM_FUNC_QUALIFIER genType asin
105
 
        (
106
 
                genType const & x
107
 
        )
108
 
        {
109
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asin' only accept floating-point input");
110
 
 
111
 
                return ::std::asin(x);
112
 
        }
113
 
 
114
 
        VECTORIZE_VEC(asin)
115
 
 
116
 
        // acos
117
 
        template <typename genType>
118
 
        GLM_FUNC_QUALIFIER genType acos
119
 
        (
120
 
                genType const & x
121
 
        )
122
 
        {
123
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acos' only accept floating-point input");
124
 
 
125
 
                return ::std::acos(x);
126
 
        }
127
 
 
128
 
        VECTORIZE_VEC(acos)
129
 
 
130
 
        // atan
131
 
        template <typename genType>
132
 
        GLM_FUNC_QUALIFIER genType atan
133
 
        (
134
 
                genType const & y, 
135
 
                genType const & x
136
 
        )
137
 
        {
138
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'atan' only accept floating-point input");
139
 
 
140
 
                return ::std::atan2(y, x);
141
 
        }
142
 
 
143
 
        VECTORIZE_VEC_VEC(atan)
144
 
 
145
 
        template <typename genType>
146
 
        GLM_FUNC_QUALIFIER genType atan
147
 
        (
148
 
                genType const & x
149
 
        )
150
 
        {
151
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'atan' only accept floating-point input");
152
 
 
153
 
                return ::std::atan(x);
154
 
        }
155
 
 
156
 
        VECTORIZE_VEC(atan)
157
 
 
158
 
        // sinh
159
 
        template <typename genType> 
160
 
        GLM_FUNC_QUALIFIER genType sinh
161
 
        (
162
 
                genType const & angle
163
 
        )
164
 
        {
165
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'sinh' only accept floating-point input");
166
 
 
167
 
                return std::sinh(angle);
168
 
        }
169
 
 
170
 
        VECTORIZE_VEC(sinh)
171
 
 
172
 
        // cosh
173
 
        template <typename genType> 
174
 
        GLM_FUNC_QUALIFIER genType cosh
175
 
        (
176
 
                genType const & angle
177
 
        )
178
 
        {
179
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'cosh' only accept floating-point input");
180
 
 
181
 
                return std::cosh(angle);
182
 
        }
183
 
 
184
 
        VECTORIZE_VEC(cosh)
185
 
 
186
 
        // tanh
187
 
        template <typename genType>
188
 
        GLM_FUNC_QUALIFIER genType tanh
189
 
        (
190
 
                genType const & angle
191
 
        )
192
 
        {
193
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'tanh' only accept floating-point input");
194
 
 
195
 
                return std::tanh(angle);
196
 
        }
197
 
 
198
 
        VECTORIZE_VEC(tanh)
199
 
 
200
 
        // asinh
201
 
        template <typename genType> 
202
 
        GLM_FUNC_QUALIFIER genType asinh
203
 
        (
204
 
                genType const & x
205
 
        )
206
 
        {
207
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'asinh' only accept floating-point input");
208
 
                
209
 
                return (x < genType(0) ? genType(-1) : (x > genType(0) ? genType(1) : genType(0))) * log(abs(x) + sqrt(genType(1) + x * x));
210
 
        }
211
 
 
212
 
        VECTORIZE_VEC(asinh)
213
 
 
214
 
        // acosh
215
 
        template <typename genType> 
216
 
        GLM_FUNC_QUALIFIER genType acosh
217
 
        (
218
 
                genType const & x
219
 
        )
220
 
        {
221
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'acosh' only accept floating-point input");
222
 
 
223
 
                if(x < genType(1))
224
 
                        return genType(0);
225
 
                return log(x + sqrt(x * x - genType(1)));
226
 
        }
227
 
 
228
 
        VECTORIZE_VEC(acosh)
229
 
 
230
 
        // atanh
231
 
        template <typename genType>
232
 
        GLM_FUNC_QUALIFIER genType atanh
233
 
        (
234
 
                genType const & x
235
 
        )
236
 
        {
237
 
                GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'atanh' only accept floating-point input");
238
 
                
239
 
                if(abs(x) >= genType(1))
240
 
                        return 0;
241
 
                return genType(0.5) * log((genType(1) + x) / (genType(1) - x));
242
 
        }
243
 
 
244
 
        VECTORIZE_VEC(atanh)
245
 
 
246
 
}//namespace glm