OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 #endif // COMPILER(MSVC) | 201 #endif // COMPILER(MSVC) |
202 | 202 |
203 inline double deg2rad(double d) { return d * piDouble / 180.0; } | 203 inline double deg2rad(double d) { return d * piDouble / 180.0; } |
204 inline double rad2deg(double r) { return r * 180.0 / piDouble; } | 204 inline double rad2deg(double r) { return r * 180.0 / piDouble; } |
205 inline double deg2grad(double d) { return d * 400.0 / 360.0; } | 205 inline double deg2grad(double d) { return d * 400.0 / 360.0; } |
206 inline double grad2deg(double g) { return g * 360.0 / 400.0; } | 206 inline double grad2deg(double g) { return g * 360.0 / 400.0; } |
207 inline double turn2deg(double t) { return t * 360.0; } | 207 inline double turn2deg(double t) { return t * 360.0; } |
208 inline double deg2turn(double d) { return d / 360.0; } | 208 inline double deg2turn(double d) { return d / 360.0; } |
209 inline double rad2grad(double r) { return r * 200.0 / piDouble; } | 209 inline double rad2grad(double r) { return r * 200.0 / piDouble; } |
210 inline double grad2rad(double g) { return g * piDouble / 200.0; } | 210 inline double grad2rad(double g) { return g * piDouble / 200.0; } |
| 211 inline double turn2grad(double t) { return t * 400.0; } |
| 212 inline double grad2turn(double g) { return g / 400.f; } |
211 | 213 |
212 inline float deg2rad(float d) { return d * piFloat / 180.0f; } | 214 inline float deg2rad(float d) { return d * piFloat / 180.0f; } |
213 inline float rad2deg(float r) { return r * 180.0f / piFloat; } | 215 inline float rad2deg(float r) { return r * 180.0f / piFloat; } |
214 inline float deg2grad(float d) { return d * 400.0f / 360.0f; } | 216 inline float deg2grad(float d) { return d * 400.0f / 360.0f; } |
215 inline float grad2deg(float g) { return g * 360.0f / 400.0f; } | 217 inline float grad2deg(float g) { return g * 360.0f / 400.0f; } |
216 inline float turn2deg(float t) { return t * 360.0f; } | 218 inline float turn2deg(float t) { return t * 360.0f; } |
217 inline float deg2turn(float d) { return d / 360.0f; } | 219 inline float deg2turn(float d) { return d / 360.0f; } |
218 inline float rad2grad(float r) { return r * 200.0f / piFloat; } | 220 inline float rad2grad(float r) { return r * 200.0f / piFloat; } |
219 inline float grad2rad(float g) { return g * piFloat / 200.0f; } | 221 inline float grad2rad(float g) { return g * piFloat / 200.0f; } |
| 222 inline float turn2grad(float t) { return t * 400.0f; } |
| 223 inline float grad2turn(float g) { return g / 400.f; } |
220 | 224 |
221 // std::numeric_limits<T>::min() returns the smallest positive value for floatin
g point types | 225 // std::numeric_limits<T>::min() returns the smallest positive value for floatin
g point types |
222 template<typename T> inline T defaultMinimumForClamp() { return std::numeric_lim
its<T>::min(); } | 226 template<typename T> inline T defaultMinimumForClamp() { return std::numeric_lim
its<T>::min(); } |
223 template<> inline float defaultMinimumForClamp() { return -std::numeric_limits<f
loat>::max(); } | 227 template<> inline float defaultMinimumForClamp() { return -std::numeric_limits<f
loat>::max(); } |
224 template<> inline double defaultMinimumForClamp() { return -std::numeric_limits<
double>::max(); } | 228 template<> inline double defaultMinimumForClamp() { return -std::numeric_limits<
double>::max(); } |
225 template<typename T> inline T defaultMaximumForClamp() { return std::numeric_lim
its<T>::max(); } | 229 template<typename T> inline T defaultMaximumForClamp() { return std::numeric_lim
its<T>::max(); } |
226 | 230 |
227 template<typename T> inline T clampTo(double value, T min = defaultMinimumForCla
mp<T>(), T max = defaultMaximumForClamp<T>()) | 231 template<typename T> inline T clampTo(double value, T min = defaultMinimumForCla
mp<T>(), T max = defaultMaximumForClamp<T>()) |
228 { | 232 { |
229 if (value >= static_cast<double>(max)) | 233 if (value >= static_cast<double>(max)) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 if (i >> 2) | 324 if (i >> 2) |
321 log2 += 2, i >>= 2; | 325 log2 += 2, i >>= 2; |
322 if (i >> 1) | 326 if (i >> 1) |
323 log2 += 1; | 327 log2 += 1; |
324 return log2; | 328 return log2; |
325 } | 329 } |
326 | 330 |
327 } // namespace WTF | 331 } // namespace WTF |
328 | 332 |
329 #endif // #ifndef WTF_MathExtras_h | 333 #endif // #ifndef WTF_MathExtras_h |
OLD | NEW |