IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Angles.h
Go to the documentation of this file.
1 // Angles.h:
3 // ---------
4 //
14 
15 #ifndef __IPSDKMATH_ANGLES_H__
16 #define __IPSDKMATH_ANGLES_H__
17 
18 #include <IPSDKMath/Constants.h>
19 #include <IPSDKUtil/BaseTypes.h>
21 
22 namespace ipsdk {
23 namespace math {
24 
27 
30 IPSDK_FORCEINLINE ipReal64
31 degToRad(const ipReal64 angle)
32 {
33  return (M_PI / 180.) * angle;
34 }
35 IPSDK_FORCEINLINE ipReal64
36 radToDeg(const ipReal64 angle)
37 {
38  return (180. / M_PI) * angle;
39 }
41 
44 IPSDK_FORCEINLINE ipReal64
45 modulo(const ipReal64 angle, const ipReal64 modulo)
46 {
47  ipReal64 result = std::fmod(angle, modulo);
48  if (result < 0)
49  result += modulo;
50 
51  return result;
52 }
53 
56 IPSDK_FORCEINLINE ipReal64
57 centerModulo(const ipReal64 angle, const ipReal64 modulo)
58 {
59  ipReal64 result = std::fmod(angle, modulo);
60  if (result >= modulo / 2)
61  result -= modulo;
62  if (result < - modulo / 2)
63  result += modulo;
64 
65  return result;
66 }
67 
70 
71 } // end of namespace math
72 } // end of namespace ipsdk
73 
74 #endif // __IPSDKMATH_ANGLES_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
IPSDK_FORCEINLINE ipReal64 degToRad(const ipReal64 angle)
convertion functions between radians and degrees
Definition: Angles.h:31
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
Predefined constants for ipsdk math library.
IPSDK_FORCEINLINE ipReal64 modulo(const ipReal64 angle, const ipReal64 modulo)
function allowing to compute modulo of an angle
Definition: Angles.h:45
Base types for multiplatform compatibility.
IPSDK_FORCEINLINE ipReal64 radToDeg(const ipReal64 angle)
convertion functions between radians and degrees
Definition: Angles.h:36
IPSDK_FORCEINLINE ipReal64 centerModulo(const ipReal64 angle, const ipReal64 modulo)
function allowing to compute centered modulo of an angle
Definition: Angles.h:57