source: trunk/src/lol/math/math.h @ 1513

Last change on this file since 1513 was 1513, checked in by sam, 8 years ago

core: replace usage of sin() or std::sin() with lol::sin() where appropriate.

  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11//
12// Various maths functions
13// -----------------------
14//
15
16#if !defined __LOL_MATH_MATH_H__
17#define __LOL_MATH_MATH_H__
18
19#include <cmath>
20#include <cstdio>
21#include <stdint.h>
22
23namespace lol
24{
25
26/* Standard cmath functions */
27static inline double sqrt(double const &x) { return std::sqrt(x); }
28static inline float sqrt(float const &x) { return std::sqrt(x); }
29
30static inline double sin(double const &x) { return std::sin(x); }
31static inline double cos(double const &x) { return std::cos(x); }
32static inline double tan(double const &x) { return std::tan(x); }
33static inline float sin(float const &x) { return std::sin(x); }
34static inline float cos(float const &x) { return std::cos(x); }
35static inline float tan(float const &x) { return std::tan(x); }
36
37static inline double asin(double const &x) { return std::asin(x); }
38static inline double acos(double const &x) { return std::acos(x); }
39static inline double atan(double const &x) { return std::atan(x); }
40static inline float asin(float const &x) { return std::asin(x); }
41static inline float acos(float const &x) { return std::acos(x); }
42static inline float atan(float const &x) { return std::atan(x); }
43
44static inline double atan2(double const &y, double const &x)
45{
46    return std::atan2(y, x);
47}
48
49static inline float atan2(float const &y, float const &x)
50{
51    return std::atan2(y, x);
52}
53
54/* Our extensions */
55static inline void sincos(double const &x, double *s, double *c)
56{
57    *s = std::sin(x);
58    *c = std::cos(x);
59}
60
61static inline void sincos(float const &x, float *s, float *c)
62{
63    *s = std::sin(x);
64    *c = std::cos(x);
65}
66
67/* These accelerated functions will be merged into the above, one day */
68double lol_sin(double);
69double lol_cos(double);
70double lol_tan(double);
71void lol_sincos(double, double*, double*);
72void lol_sincos(float, float*, float*);
73double lol_asin(double);
74double lol_acos(double);
75double lol_atan(double);
76double lol_atan2(double, double);
77
78} /* namespace lol */
79
80#endif // __LOL_MATH_MATH_H__
81
Note: See TracBrowser for help on using the repository browser.