Debian Codegraph @

3rdparty/xspublic/xstypes/xsmath.h

raw
1
2 // Copyright (c) 2003-2019 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32
33 #ifndef XSMATH_H
34 #define XSMATH_H
35
36 #include "xstypesconfig.h"
37 #include "xstypedefs.h"
38 #include "pstdint.h"
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 XSTYPES_DLL_API extern const XsReal XsMath_e;
45 XSTYPES_DLL_API extern const XsReal XsMath_pi;
46 XSTYPES_DLL_API extern const XsReal XsMath_tinyValue;
47 XSTYPES_DLL_API extern const XsReal XsMath_hugeValue;
48 XSTYPES_DLL_API extern const XsReal XsMath_epsilon;
49 XSTYPES_DLL_API extern const XsReal XsMath_sqrtEpsilon;
50 XSTYPES_DLL_API extern const XsReal XsMath_denormalized;
51 XSTYPES_DLL_API extern const XsReal XsMath_sqrtDenormalized;
52 XSTYPES_DLL_API extern const XsReal XsMath_rad2degValue;
53 XSTYPES_DLL_API extern const XsReal XsMath_deg2radValue;
54 XSTYPES_DLL_API extern const XsReal XsMath_zero;
55 XSTYPES_DLL_API extern const XsReal XsMath_pt25;
56 XSTYPES_DLL_API extern const XsReal XsMath_pt5;
57 XSTYPES_DLL_API extern const XsReal XsMath_minusPt5;
58 XSTYPES_DLL_API extern const XsReal XsMath_one;
59 XSTYPES_DLL_API extern const XsReal XsMath_minusOne;
60 XSTYPES_DLL_API extern const XsReal XsMath_two;
61 XSTYPES_DLL_API extern const XsReal XsMath_four;
62 XSTYPES_DLL_API extern const XsReal XsMath_minusTwo;
63 XSTYPES_DLL_API extern const XsReal XsMath_minusHalfPi;
64 XSTYPES_DLL_API extern const XsReal XsMath_halfPi;
65 XSTYPES_DLL_API extern const XsReal XsMath_twoPi;
66 XSTYPES_DLL_API extern const XsReal XsMath_sqrt2;
67 XSTYPES_DLL_API extern const XsReal XsMath_sqrtHalf;
68 XSTYPES_DLL_API extern const XsReal XsMath_infinity;
69
70 XSTYPES_DLL_API XsReal XsMath_rad2deg(XsReal radians);
71 XSTYPES_DLL_API XsReal XsMath_deg2rad(XsReal degrees);
72 XSTYPES_DLL_API XsReal XsMath_pow2(XsReal a);
73 XSTYPES_DLL_API XsReal XsMath_pow3(XsReal a);
74 XSTYPES_DLL_API XsReal XsMath_asinClamped(XsReal x);
75 XSTYPES_DLL_API int XsMath_isFinite(XsReal x);
76 XSTYPES_DLL_API int32_t XsMath_doubleToLong(double d);
77 XSTYPES_DLL_API int32_t XsMath_floatToLong(float d);
78 #ifndef XSENS_NO_INT64
79 XSTYPES_DLL_API int64_t XsMath_doubleToInt64(double d);
80 XSTYPES_DLL_API int64_t XsMath_floatToInt64(float d);
81 #endif
82
83 #ifdef __cplusplus
84 } // extern "C"
85
86 namespace XsMath {
87 #ifdef __GNUC__
88 #pragma GCC diagnostic push
89 #pragma GCC diagnostic ignored "-Wunused-variable"
90 #endif
91 //! \brief The value e
92 static const XsReal& e = XsMath_e;
93 //! \brief The value pi
94 static const XsReal& pi = XsMath_pi;
95 //! \brief A really small value
96 static const XsReal& tinyValue = XsMath_tinyValue;
97 //! \brief A convincingly large number
98 static const XsReal& hugeValue = XsMath_hugeValue;
99 //! \brief A value related to the precision of floating point arithmetic (2.2204460492503131e-016)
100 static const XsReal& epsilon = XsMath_epsilon;
101 /*! \brief Square root of epsilon
102 \sa epsilon
103 */
104 static const XsReal& sqrtEpsilon = XsMath_sqrtEpsilon;
105 //! \brief Value that represents the subnormal number in floating point wizardry
106 static const XsReal& denormalized = XsMath_denormalized;
107 /*! \brief Square root of denormalized
108 \sa denormalized
109 */
110 static const XsReal& sqrtDenormalized = XsMath_sqrtDenormalized;
111 //! \brief Value to convert radians to degrees by multiplication
112 static const XsReal& rad2degValue = XsMath_rad2degValue;
113 //! \brief Value to convert degrees to radians by multiplication
114 static const XsReal& deg2radValue = XsMath_deg2radValue;
115 //! \brief 0
116 static const XsReal& zero = XsMath_zero;
117 //! \brief 0.25
118 static const XsReal& pt25 = XsMath_pt25;
119 //! \brief 0.5
120 static const XsReal& pt5 = XsMath_pt5;
121 //! \brief -0.5
122 static const XsReal& minusPt5 = XsMath_minusPt5;
123 //! \brief 1
124 static const XsReal& one = XsMath_one;
125 //! \brief -1
126 static const XsReal& minusOne = XsMath_minusOne;
127 //! \brief 2
128 static const XsReal& two = XsMath_two;
129 //! \brief 4
130 static const XsReal& four = XsMath_four;
131 //! \brief -2
132 static const XsReal& minusTwo = XsMath_minusTwo;
133 //! \brief -pi/2
134 static const XsReal& minusHalfPi = XsMath_minusHalfPi;
135 //! \brief pi/2
136 static const XsReal& halfPi = XsMath_halfPi;
137 //! \brief 2*pi
138 static const XsReal& twoPi = XsMath_twoPi;
139 //! \brief sqrt(2)
140 static const XsReal& sqrt2 = XsMath_sqrt2;
141 //! \brief sqrt(0.5)
142 static const XsReal& sqrtHalf = XsMath_sqrtHalf;
143 //! \brief infinity
144 static const XsReal& infinity = XsMath_infinity;
145 #ifdef __GNUC__
146 #pragma GCC diagnostic pop
147 #endif
148
149
150 //! \brief \copybrief XsMath_asinClamped
151 inline XsReal asinClamped(XsReal x)
152 {
153 return XsMath_asinClamped(x);
154 }
155 //! \brief \copybrief XsMath_rad2deg
156 inline XsReal rad2deg(XsReal radians)
157 {
158 return XsMath_rad2deg(radians);
159 }
160 //! \brief \copybrief XsMath_deg2rad
161 inline XsReal deg2rad(XsReal degrees)
162 {
163 return XsMath_deg2rad(degrees);
164 }
165 //! \brief \copybrief XsMath_pow2
166 inline XsReal pow2(XsReal a)
167 {
168 return XsMath_pow2(a);
169 }
170 //! \brief \copybrief XsMath_pow3
171 inline XsReal pow3(XsReal a)
172 {
173 return XsMath_pow3(a);
174 }
175 //! \brief \copybrief XsMath_doubleToLong
176 inline int32_t doubleToLong(double d)
177 {
178 return XsMath_doubleToLong(d);
179 }
180 #ifndef XSENS_NO_INT64
181 //! \brief \copybrief XsMath_doubleToInt64
182 inline int64_t doubleToInt64(double d)
183 {
184 return XsMath_doubleToInt64(d);
185 }
186 #endif
187 } // namespace
188 #endif
189
190 #endif