ConOpSys V2970  P004.07
ANVILEX control operating system
Math_Defines.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file Math_Defines.h
3 //! @brief Diverse mathematical defines header file.
4 //! @attention No special attention requered.
5 //! @copyright (C) 2017-2020 ANVILEX LLC
6 //! $HeadURL: https://192.168.3.4:8443/svn/P004_07/ConOpSys/Defines/Math_Defines.h $
7 //! $Revision: 2877 $
8 //! $Date: 2021-10-18 23:04:26 +0500 (Mo, 18 Okt 2021) $
9 //! $Author: minch $
10 //------------------------------------------------------------------------------
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are met:
14 //
15 // 1. Redistributions of source code must retain the above copyright notice,
16 // this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright notice,
19 // this list of conditions and the following disclaimer in the documentation
20 // and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of ANVILEX nor the names of its contributors may be
23 // used to endorse or promote products derived from this software without
24 // specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
30 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 // POSSIBILITY OF SUCH DAMAGE.
37 //------------------------------------------------------------------------------
38 
39 #pragma once
40 
41 //------------------------------------------------------------------------------
42 
43 #include "Defines.h"
44 
45 #include <math.h>
46 
47 //------------------------------------------------------------------------------
48 // Pi constanant defines
49 //------------------------------------------------------------------------------
50 
51 //! @brief Definition of Pi as F32
52 const F32 f32_Pi = (F32)3.141592653589793238f;
53 
54 //! @brief Definition of Pi as F64
55 const F64 f64_Pi = (F64)3.141592653589793238;
56 
57 //! @brief Definition of Pi as F80
58 const F80 f80_Pi = (F80)3.141592653589793238L;
59 
60 //------------------------------------------------------------------------------
61 // Pi related constants
62 //------------------------------------------------------------------------------
63 
64 // X * Pi - constants
65 #define f32_Pi_MUL_2 (F32)( (F32)2.0f * f32_Pi )
66 #define f32_Pi_MUL_3 (F32)( (F32)3.0f * f32_Pi )
67 
68 // 1 / ( X * Pi ) - constants
69 #define f32_1_DIV_Pi_MUL_2 (F32)( (F32)1.0f / ( (F32)2.0f * f32_Pi ) )
70 
71 // X / Pi - constants
72 #define f32_2_DIV_Pi (F32)( (F32)2.0f / f32_Pi )
73 
74 // Pi / X - constants
75 #define f32_Pi_DIV_2 (F32)( f32_Pi / (F32)2.0f )
76 #define f32_Pi_DIV_3 (F32)( f32_Pi / (F32)3.0f )
77 #define f32_Pi_DIV_4 (F32)( f32_Pi / (F32)4.0f )
78 #define f32_Pi_DIV_5 (F32)( f32_Pi / (F32)5.0f )
79 #define f32_Pi_DIV_6 (F32)( f32_Pi / (F32)6.0f )
80 #define f32_Pi_DIV_7 (F32)( f32_Pi / (F32)7.0f )
81 #define f32_Pi_DIV_8 (F32)( f32_Pi / (F32)8.0f )
82 #define f32_Pi_DIV_9 (F32)( f32_Pi / (F32)9.0f )
83 #define f32_Pi_DIV_10 (F32)( f32_Pi / (F32)10.0f )
84 #define f32_Pi_DIV_11 (F32)( f32_Pi / (F32)11.0f )
85 #define f32_Pi_DIV_12 (F32)( f32_Pi / (F32)12.0f )
86 
87 #define f32_Pi_MUL_2_DIV_3 (F32)( f32_Pi * ( (F32)2.0f / (F32)3.0f ) )
88 
89 //--------------------------------------------------------------------------------
90 // Other common used constants
91 //--------------------------------------------------------------------------------
92 
93 #define f32_1_DIV_3 (F32)( (F32)1.0f / (F32)3.0f )
94 #define f32_2_DIV_3 (F32)( (F32)2.0f / (F32)3.0f )
95 
96 #define f32_1_DIV_SQRT_2 (F32)( (F32)1.0f / sqrtf( (F32)2.0f ) )
97 #define f32_1_DIV_SQRT_3 (F32)( (F32)1.0f / sqrtf( (F32)3.0f ) )
98 #define f32_2_DIV_SQRT_3 (F32)( (F32)2.0f / sqrtf( (F32)3.0f ) )
99 
100 #define f32_SQRT_2 (F32)1.414213562373095f
101 
102 //#define f32_SQRT_3_DIV_2 (F32)( sqrtf( (F32)3.0f ) * (F32)0.5f )
103 #define f32_SQRT_3_DIV_2 (F32)( (F32)1.732050807568877f * (F32)0.5f )
104 
105 //------------------------------------------------------------------------------
106 // End of file
107 //------------------------------------------------------------------------------
ConOpSys data type definitions header file.
long double F80
IEEE-754 80-Bit extended presession floating point numbers datatype defenition.
Definition: Defines.h:330
float F32
IEEE-754 32-Bit single presession floating point numbers datatype defenition.
Definition: Defines.h:324
double F64
IEEE-754 64-Bit double presession floating point numbers datatype defenition.
Definition: Defines.h:327
const F80 f80_Pi
Definition of Pi as F80.
Definition: Math_Defines.h:58
const F64 f64_Pi
Definition of Pi as F64.
Definition: Math_Defines.h:55
const F32 f32_Pi
Definition of Pi as F32.
Definition: Math_Defines.h:52