artkpFixedBase_gpp.h
Go to the documentation of this file.
1 /* ========================================================================
2  * PROJECT: ARToolKitPlus
3  * ========================================================================
4  * This work is based on the original ARToolKit developed by
5  * Hirokazu Kato
6  * Mark Billinghurst
7  * HITLab, University of Washington, Seattle
8  * http://www.hitl.washington.edu/artoolkit/
9  *
10  * Copyright of the derived and new portions of this work
11  * (C) 2006 Graz University of Technology
12  *
13  * This framework is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This framework is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this framework; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26  *
27  * For further information please contact
28  * Dieter Schmalstieg
29  * <schmalstieg@icg.tu-graz.ac.at>
30  * Graz University of Technology,
31  * Institut for Computer Graphics and Vision,
32  * Inffeldgasse 16a, 8010 Graz, Austria.
33  * ========================================================================
34  ** @author Daniel Wagner
35  *
36  * $Id$
37  * @file
38  * ======================================================================== */
39 
40 
41 #ifndef __ARTKPFIXEDBASE_GPP_HEADERFILE__
42 #define __ARTKPFIXEDBASE_GPP_HEADERFILE__
43 
44 
45 #include <gpp.h>
46 #ifdef DEBUG
47  #pragma comment( lib, "gpp_WMMX40_d.lib" )
48 #else
49  #pragma comment( lib, "gpp_WMMX40_r.lib" )
50 #endif //DEBUG
51 
52 
53 template <int PBITS_>
55 {
56 public:
57  enum {
58  PBITS = PBITS_,
59  CHECK = 0
60  };
61 
62  static float floatFromFixed(int nFixed)
63  {
64  return nFixed/(float)(1 << PBITS);
65  }
66 
67  static double doubleFromFixed(int nFixed)
68  {
69  return nFixed/(double)(1 << PBITS);
70  }
71 
72  static int fixedFromInt(int nV)
73  {
74  return nV<<PBITS;
75  }
76 
77  static int fixedFromFloat(float nV)
78  {
79  return (int)(nV * (float)(1 << PBITS) + 0.5f);
80  }
81 
82  static int fixedFromDouble(double nV)
83  {
84  return (int)(nV * (double)(1 << PBITS) + 0.5f);
85  }
86 
87  static int inverse(int nFixed)
88  {
89  int ret=0;
90  gppInvHP_n_32s(nFixed, &ret, PBITS);
91  return ret;
92  }
93 
94  static int multiply(int nLeftFixed, int nRightFixed)
95  {
96  int ret;
97  gppMul_n_32s(nLeftFixed, nRightFixed, &ret, PBITS);
98  return ret;
99  }
100 
101  static int divide(int nLeftFixed, int nRightFixed)
102  {
103  int ret;
104  gppDiv_n_32s(nLeftFixed, nRightFixed, &ret, PBITS);
105  return ret;
106  }
107 
108  static int cos(int nFixed)
109  {
110  int ret;
111  gppCosHP_n_32s(nFixed, &ret, PBITS);
112  return ret;
113  }
114 
115  static int sin(int nFixed)
116  {
117  int ret;
118  gppSinHP_n_32s(nFixed, &ret, PBITS);
119  return ret;
120  }
121 
122  static int fabs(int nFixed)
123  {
124  return nFixed<0 ? -nFixed : nFixed;
125  }
126 
127  static int sqrt(int nFixed)
128  {
129  unsigned int ret;
130  gppSqrtHP_n_32s(nFixed, &ret, PBITS);
131  return (int)ret;
132  }
133 
134  static int inverseSqrt(int nFixed)
135  {
136  unsigned int ret;
137  gppInvSqrtHP_n_32s(nFixed, &ret, PBITS);
138  return (int)ret;
139  }
140 
141  static int ceil(int nFixed)
142  {
143  int ret = (nFixed>>PBITS)<<PBITS;
144 
145  if(nFixed>=0 && ret<nFixed)
146  ret += fixedFromInt(1);
147 
148  return ret;
149  }
150 };
151 
152 
153 #endif //__ARTKPFIXEDBASE_GPP_HEADERFILE__
static int fabs(int nFixed)
static double doubleFromFixed(int nFixed)
static int inverseSqrt(int nFixed)
static int fixedFromInt(int nV)
static int fixedFromDouble(double nV)
static float floatFromFixed(int nFixed)
static int multiply(int nLeftFixed, int nRightFixed)
static int sin(int nFixed)
static int ceil(int nFixed)
static int fixedFromFloat(float nV)
static int inverse(int nFixed)
static int cos(int nFixed)
static int sqrt(int nFixed)
static int divide(int nLeftFixed, int nRightFixed)


tuw_artoolkitplus
Author(s): Markus Bader
autogenerated on Sun Sep 4 2016 03:24:33