CHDK_DE Vorschauversion  Trunk Rev. 6014
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
cordic_math.h-Dateireferenz
#include "limits.h"
+ Include-Abhängigkeitsdiagramm für cordic_math.h:
+ Dieser Graph zeigt, welche Datei direkt oder indirekt diese Datei enthält:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define FIXED(X)   (floatToFixed((X)))
 
#define FLOAT(X)   ((X) / (double)CORDIC_SCALE)
 
#define INT2FIXED(X)   (intToFixed((X), 0))
 
#define INT2FIXEDR(X)   (intToFixed((X), 1))
 
#define FIXED2INT(X)   (fixedToInt((X), 0))
 
#define FIXED2INTR(X)   (fixedToInt((X), 1))
 

Typdefinitionen

typedef long fixed
 
typedef int int4b
 
typedef int fcordic
 
typedef int tangle
 

Aufzählungen

enum  { ROTATE, VECTOR }
 
enum  { RAD, DEG }
 
enum  {
  FRACTIONBITS = 17, N = 17, M = 9, CORDIC_SCALE = 1 << FRACTIONBITS,
  CORDIC_INTEGER = ~(CORDIC_SCALE - 1), INT_SCALE = 1000
}
 

Funktionen

LUALIB_API fixed floatToFixed (double a)
 
LUALIB_API fixed intToFixed (int4b a, int round)
 
LUALIB_API int4b fixedToInt (fixed a, int round)
 
LUALIB_API fixed muldivScaled (fixed a, fixed b, fixed c)
 
LUALIB_API fixed sind (fixed phi)
 
LUALIB_API fixed cosd (fixed phi)
 
LUALIB_API fixed tand (fixed phi)
 
LUALIB_API void recd (fixed r, fixed theta, fixed *px, fixed *py)
 
LUALIB_API fixed asind (fixed x)
 
LUALIB_API fixed acosd (fixed x)
 
LUALIB_API fixed atand (fixed x)
 
LUALIB_API void pold (fixed px, fixed py, fixed *r, fixed *theta)
 
LUALIB_API fixed sinr (fixed phi)
 
LUALIB_API fixed cosr (fixed phi)
 
LUALIB_API fixed tanr (fixed phi)
 
LUALIB_API void recr (fixed r, fixed theta, fixed *px, fixed *py)
 
LUALIB_API fixed asinr (fixed x)
 
LUALIB_API fixed acosr (fixed x)
 
LUALIB_API fixed atanr (fixed x)
 
LUALIB_API void polr (fixed px, fixed py, fixed *r, fixed *theta)
 
LUALIB_API fixed fint (fixed a)
 
LUALIB_API fixed fceil (fixed a)
 
LUALIB_API fixed ffloor (fixed a)
 
LUALIB_API fixed fround (fixed a)
 

Variablen

LUAI_DATA fixed FULL_CIRCLE []
 
LUAI_DATA fixed HALF_CIRCLE []
 
LUAI_DATA fixed QUART_CIRCLE []
 

Makro-Dokumentation

#define FIXED (   X)    (floatToFixed((X)))

Definiert in Zeile 56 der Datei cordic_math.h.

#define FIXED2INT (   X)    (fixedToInt((X), 0))

Definiert in Zeile 60 der Datei cordic_math.h.

#define FIXED2INTR (   X)    (fixedToInt((X), 1))

Definiert in Zeile 61 der Datei cordic_math.h.

#define FLOAT (   X)    ((X) / (double)CORDIC_SCALE)

Definiert in Zeile 57 der Datei cordic_math.h.

#define INT2FIXED (   X)    (intToFixed((X), 0))

Definiert in Zeile 58 der Datei cordic_math.h.

#define INT2FIXEDR (   X)    (intToFixed((X), 1))

Definiert in Zeile 59 der Datei cordic_math.h.

Dokumentation der benutzerdefinierten Typen

typedef int fcordic

Definiert in Zeile 41 der Datei cordic_math.h.

typedef long fixed

Definiert in Zeile 37 der Datei cordic_math.h.

typedef int int4b

Definiert in Zeile 38 der Datei cordic_math.h.

typedef int tangle

Definiert in Zeile 43 der Datei cordic_math.h.

Dokumentation der Aufzählungstypen

anonymous enum
Aufzählungswerte
ROTATE 
VECTOR 

Definiert in Zeile 40 der Datei cordic_math.h.

40 {ROTATE, VECTOR};
anonymous enum
Aufzählungswerte
RAD 
DEG 

Definiert in Zeile 42 der Datei cordic_math.h.

42 {RAD, DEG};
anonymous enum
Aufzählungswerte
FRACTIONBITS 
N 
M 
CORDIC_SCALE 
CORDIC_INTEGER 
INT_SCALE 

Definiert in Zeile 45 der Datei cordic_math.h.

45  {
46  FRACTIONBITS = 17,
47  N = 17,
48  M = 9,
51  INT_SCALE = 1000,
52 };

Dokumentation der Funktionen

LUALIB_API fixed acosd ( fixed  x)

Definiert in Zeile 221 der Datei cordic_math.c.

221  {
222  return acosCordic(DEG, x);
223 }
LUALIB_API fixed acosr ( fixed  x)

Definiert in Zeile 254 der Datei cordic_math.c.

254  {
255  return acosCordic(RAD, x);
256 }
LUALIB_API fixed asind ( fixed  x)

Definiert in Zeile 217 der Datei cordic_math.c.

217  {
218  return asinCordic(DEG, x);
219 }
LUALIB_API fixed asinr ( fixed  x)

Definiert in Zeile 250 der Datei cordic_math.c.

250  {
251  return asinCordic(RAD, x);
252 }
LUALIB_API fixed atand ( fixed  x)

Definiert in Zeile 225 der Datei cordic_math.c.

225  {
226  return atanCordic(DEG, x);
227 }
LUALIB_API fixed atanr ( fixed  x)

Definiert in Zeile 258 der Datei cordic_math.c.

258  {
259  return atanCordic(RAD, x);
260 }
LUALIB_API fixed cosd ( fixed  phi)

Definiert in Zeile 205 der Datei cordic_math.c.

205  {
206  return cosCordic(DEG, phi);
207 }
LUALIB_API fixed cosr ( fixed  phi)

Definiert in Zeile 238 der Datei cordic_math.c.

238  {
239  return cosCordic(RAD, phi);
240 }
LUALIB_API fixed fceil ( fixed  a)

Definiert in Zeile 271 der Datei cordic_math.c.

271  {
272  fixed int_a = fint(a);
273  return (a < 0 || a == int_a)? int_a: int_a + CORDIC_SCALE;
274 }
LUALIB_API fixed ffloor ( fixed  a)

Definiert in Zeile 276 der Datei cordic_math.c.

276  {
277  fixed int_a = fint(a);
278  return (a > 0 || a == int_a)? int_a: int_a - CORDIC_SCALE;
279 }
LUALIB_API fixed fint ( fixed  a)

Definiert in Zeile 267 der Datei cordic_math.c.

267  {
268  return cordic_sign(a) * (cordic_abs(a) & CORDIC_INTEGER);
269 }
LUALIB_API int4b fixedToInt ( fixed  a,
int  round 
)

Definiert in Zeile 310 der Datei cordic_math.c.

310  {
311  double res = cordic_abs(a);
312  if (res > INT_MAX) {
313  // error int4b overflow
314  res = INT_MAX;
315  }
316  res = res * INT_SCALE / CORDIC_SCALE;
317  if (round) res = res + 0.5;
318  return cordic_sign(a) * res;
319 }
LUALIB_API fixed floatToFixed ( double  a)

Definiert in Zeile 286 der Datei cordic_math.c.

286  {
287  int sign = 1;
288  if (a < 0) {
289  sign = -1;
290  a = -a;
291  }
292  if (a > FIXED_MAX) {
293  // error fixed overflow
294  a = FIXED_MAX;
295  }
296  return a * CORDIC_SCALE * sign;
297 }
LUALIB_API fixed fround ( fixed  a)

Definiert in Zeile 281 der Datei cordic_math.c.

281  {
282  return ffloor(a + CORDIC_SCALE / 2);
283 }
LUALIB_API fixed intToFixed ( int4b  a,
int  round 
)

Definiert in Zeile 299 der Datei cordic_math.c.

299  {
300  double res = cordic_abs(a);
301  if (round) res = res + 0.5;
302  res = res * CORDIC_SCALE / INT_SCALE;
303  if (res > INT_MAX) {
304  // error fixed overflow
305  res = INT_MAX;
306  }
307  return cordic_sign(a) * res;
308 }
LUALIB_API fixed muldivScaled ( fixed  a,
fixed  b,
fixed  c 
)

Definiert in Zeile 58 der Datei cordic_math.c.

58  {
59  double res;
60  if (c != 0) {
61  int sign = cordic_sign(a) * cordic_sign(b) / cordic_sign(c);
62  res = FLOAT(cordic_abs(a)) * FLOAT(cordic_abs(b)) / FLOAT(cordic_abs(c));
63  if (res > INT_MAX) {
64  // error overflow
65  res = INT_MAX;
66  } else { res = sign * res; }
67  } else {
68  // error div 0
69  res = 0;
70  }
71  return FIXED(res);
72 }
LUALIB_API void pold ( fixed  px,
fixed  py,
fixed r,
fixed theta 
)

Definiert in Zeile 229 der Datei cordic_math.c.

229  {
230  polCordic(DEG, px, py, r, theta);
231 }
LUALIB_API void polr ( fixed  px,
fixed  py,
fixed r,
fixed theta 
)

Definiert in Zeile 262 der Datei cordic_math.c.

262  {
263  polCordic(RAD, px, py, r, theta);
264 }
LUALIB_API void recd ( fixed  r,
fixed  theta,
fixed px,
fixed py 
)

Definiert in Zeile 213 der Datei cordic_math.c.

213  {
214  recCordic(DEG, r, theta, px, py);
215 }
LUALIB_API void recr ( fixed  r,
fixed  theta,
fixed px,
fixed py 
)

Definiert in Zeile 246 der Datei cordic_math.c.

246  {
247  recCordic(RAD, r, theta, px, py);
248 }
LUALIB_API fixed sind ( fixed  phi)

Definiert in Zeile 201 der Datei cordic_math.c.

201  {
202  return sinCordic(DEG, phi);
203 }
LUALIB_API fixed sinr ( fixed  phi)

Definiert in Zeile 234 der Datei cordic_math.c.

234  {
235  return sinCordic(RAD, phi);
236 }
LUALIB_API fixed tand ( fixed  phi)

Definiert in Zeile 209 der Datei cordic_math.c.

209  {
210  return tanCordic(DEG, phi);
211 }
LUALIB_API fixed tanr ( fixed  phi)

Definiert in Zeile 242 der Datei cordic_math.c.

242  {
243  return tanCordic(RAD, phi);
244 }

Variablen-Dokumentation

LUAI_DATA fixed FULL_CIRCLE[]

Definiert in Zeile 65 der Datei cordic_math.h.

LUAI_DATA fixed HALF_CIRCLE[]

Definiert in Zeile 66 der Datei cordic_math.h.

LUAI_DATA fixed QUART_CIRCLE[]

Definiert in Zeile 67 der Datei cordic_math.h.