source: trunk/src/lol/math/trig.h @ 1512

Last change on this file since 1512 was 1512, checked in by sam, 9 years ago

build: fix the PS3 port by using our trig.h everywhere instead of stdlib
functions; also remove a lot of idiotic "using namespace std" from the
codebase.

  • Property svn:keywords set to Id
File size: 2.1 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// Trigonometry functions
13// ----------------------
14//
15
16#if !defined __LOL_MATH_TRIG_H__
17#define __LOL_MATH_TRIG_H__
18
19#include <cstdio>
20#include <stdint.h>
21
22namespace lol
23{
24
25/* Standard cmath functions */
26static inline double sin(double const &x) { return std::sin(x); }
27static inline double cos(double const &x) { return std::cos(x); }
28static inline double tan(double const &x) { return std::tan(x); }
29static inline double asin(double const &x) { return std::asin(x); }
30static inline double acos(double const &x) { return std::acos(x); }
31static inline double atan(double const &x) { return std::atan(x); }
32
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); }
36static inline float asin(float const &x) { return std::asin(x); }
37static inline float acos(float const &x) { return std::acos(x); }
38static inline float atan(float const &x) { return std::atan(x); }
39
40static inline double atan2(double const &y, double const &x)
41{
42    return std::atan2(y, x);
43}
44
45static inline float atan2(float const &y, float const &x)
46{
47    return std::atan2(y, x);
48}
49
50/* Our extensions */
51static inline void sincos(double const &x, double *s, double *c)
52{
53    *s = std::sin(x);
54    *c = std::cos(x);
55}
56
57static inline void sincos(float const &x, float *s, float *c)
58{
59    *s = std::sin(x);
60    *c = std::cos(x);
61}
62
63/* These accelerated functions will be merged into the above, one day */
64double lol_sin(double);
65double lol_cos(double);
66double lol_tan(double);
67void lol_sincos(double, double*, double*);
68void lol_sincos(float, float*, float*);
69double lol_asin(double);
70double lol_acos(double);
71double lol_atan(double);
72double lol_atan2(double, double);
73
74} /* namespace lol */
75
76#endif // __LOL_MATH_TRIG_H__
77
Note: See TracBrowser for help on using the repository browser.