libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo es el conjunto de objetos y funciones, que permiten ejecutar las operaciones básicas de la plataforma Moldeo, y que compone su núcleo.
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Amigas 'defines' Grupos Páginas
moMath.cpp
Ir a la documentación de este archivo.
1 /*******************************************************************************
2 
3  moMath.cpp
4 
5  ****************************************************************************
6  * *
7  * This source is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This code is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15  * General Public License for more details. *
16  * *
17  * A copy of the GNU General Public License is available on the World *
18  * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19  * obtain it by writing to the Free Software Foundation, *
20  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  * *
22  ****************************************************************************
23 
24  Copyright(C) 2006 Fabricio Costa
25 
26  Authors:
27  Fabricio Costa
28  Andrés Colubri
29 
30  Portions taken from
31  Wild Magic Source Code
32  David Eberly
33  http://www.geometrictools.com
34  Copyright (c) 1998-2007
35 
36 *******************************************************************************/
37 
38 #include "moMath.h"
39 
40 #ifndef MO_USING_VCX
41 template<> const MOlong moMath<MOlong>::EPSILON = FLT_EPSILON;
42 template<> const MOlong moMath<MOlong>::ZERO_TOLERANCE = 1e-06f;
43 template<> const MOlong moMath<MOlong>::MAX_REAL = (MOlong)FLT_MAX;
44 template<> const MOlong moMath<MOlong>::PI = (MOlong)(4.0*atan(1.0));
48 template<> const MOlong moMath<MOlong>::INV_TWO_PI = 1.0f/moMath<MOlong>::TWO_PI;
53 template<> const MOlong moMath<MOlong>::INV_LN_2 = 1.0f/moMath<MOlong>::LN_2;
54 template<> const MOlong moMath<MOlong>::INV_LN_10 = 1.0f/moMath<MOlong>::LN_10;
55 
56 template<> const MOfloat moMath<MOfloat>::EPSILON = FLT_EPSILON;
58 template<> const MOfloat moMath<MOfloat>::MAX_REAL = FLT_MAX;
59 template<> const MOfloat moMath<MOfloat>::PI = (MOfloat)(4.0*atan(1.0));
60 template<> const MOfloat moMath<MOfloat>::TWO_PI = 2.0f*moMath<MOfloat>::PI;
61 template<> const MOfloat moMath<MOfloat>::HALF_PI = 0.5f*moMath<MOfloat>::PI;
62 template<> const MOfloat moMath<MOfloat>::INV_PI = 1.0f/moMath<MOfloat>::PI;
63 template<> const MOfloat moMath<MOfloat>::INV_TWO_PI = 1.0f/moMath<MOfloat>::TWO_PI;
64 template<> const MOfloat moMath<MOfloat>::DEG_TO_RAD = moMath<MOfloat>::PI/180.0f;
65 template<> const MOfloat moMath<MOfloat>::RAD_TO_DEG = 180.0f/moMath<MOfloat>::PI;
68 template<> const MOfloat moMath<MOfloat>::INV_LN_2 = 1.0f/moMath<MOfloat>::LN_2;
69 template<> const MOfloat moMath<MOfloat>::INV_LN_10 = 1.0f/moMath<MOfloat>::LN_10;
70 
71 template<> const MOdouble moMath<MOdouble>::EPSILON = DBL_EPSILON;
73 template<> const MOdouble moMath<MOdouble>::MAX_REAL = DBL_MAX;
74 template<> const MOdouble moMath<MOdouble>::PI = 4.0*atan(1.0);
75 template<> const MOdouble moMath<MOdouble>::TWO_PI = 2.0*moMath<MOdouble>::PI;
76 template<> const MOdouble moMath<MOdouble>::HALF_PI = 0.5*moMath<MOdouble>::PI;
77 template<> const MOdouble moMath<MOdouble>::INV_PI = 1.0/moMath<MOdouble>::PI;
78 template<> const MOdouble moMath<MOdouble>::INV_TWO_PI = 1.0/moMath<MOdouble>::TWO_PI;
79 template<> const MOdouble moMath<MOdouble>::DEG_TO_RAD = moMath<MOdouble>::PI/180.0;
80 template<> const MOdouble moMath<MOdouble>::RAD_TO_DEG = 180.0/moMath<MOdouble>::PI;
83 template<> const MOdouble moMath<MOdouble>::INV_LN_2 = 1.0/moMath<MOdouble>::LN_2;
84 template<> const MOdouble moMath<MOdouble>::INV_LN_10 = 1.0/moMath<MOdouble>::LN_10;
85 
86 template <>
88 {
89 
90  return fValue;
91 }
92 
93 template <>
95 {
96  MOfloat fHalf = 0.5f*fValue;
97  int i;
98  i = *(int*)&fValue;
99  i = 0x5f3759df - (i >> 1);
100  fValue = *(MOfloat*)&i;
101  fValue = fValue*(1.5f - fHalf*fValue*fValue);
102  return fValue;
103 }
104 
105 template <>
107 {
108  MOdouble dHalf = 0.5*dValue;
109  MOlonglong i = *(MOlonglong*)&dValue;
110 #if defined(WM4_USING_VC70) || defined(WM4_USING_VC6)
111  i = 0x5fe6ec85e7de30da - (i >> 1);
112 #else
113  i = 0x5fe6ec85e7de30daLL - (i >> 1);
114 #endif
115  dValue = *(MOdouble*)&i;
116  dValue = dValue*(1.5 - dHalf*dValue*dValue);
117  return dValue;
118 }
119 
120 #endif
121 
f
Definition: jquery.js:71
static Real Log(Real fValue)
Definition: moMath.h:220
#define MOfloat
Definition: moTypes.h:403
#define MOlong
Definition: moTypes.h:391
moTypes MOint moText moParamIndex moParamReference int iRow int int i int i
Definition: all_f.js:18
function e
Definition: jquery.js:71
static Real FastInvSqrt(Real fValue)
#define MOdouble
Definition: moTypes.h:404
#define MOlonglong
Definition: moTypes.h:393
Definition: moMath.h:64