/[zanavi_public1]/navit/navit/coord.c
ZANavi

Diff of /navit/navit/coord.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 27 Revision 28
36 * Get a coordinate 36 * Get a coordinate
37 * 37 *
38 * @param p Pointer to the coordinate 38 * @param p Pointer to the coordinate
39 * @returns the coordinate 39 * @returns the coordinate
40 */ 40 */
41
42
43
44/*
45================
46sine lookup table (input in degress)
47================
48*/
49/*
50#define SINMAX 9000
51double sinlut[SINMAX + 1];
52void sincreate(void)
53{
54 int i;
55 double angle, angleinc;
56
57 angleinc = 3.1415926535 / 2.0 / (SINMAX);
58 for (i = 0, angle = 0.0; i <= SINMAX; ++i, angle += angleinc)
59 {
60 sinlut[i] = sin(angle);
61 }
62}
63
64double sin_lut(double degrees)
65{
66 int ix;
67 ix = (int)(degrees * 100.0);
68 return sinlut[ix];
69}
70*/
71
72// very fast, but can be a bit off the real value!! so be careful!
73float sqrtf_fast2(float x2)
74{
75 unsigned int i = *(unsigned int*) &x2;
76 // adjust bias
77 i += 127 << 23;
78 // approximation of square root
79 i >>= 1;
80 return *(float*) &i;
81}
82
83/*
84================
85SquareRootFloat (rather accurate)
86================
87*/
88float sqrtf_fast(float number2)
89{
90 long i;
91 float x, y;
92 const float f = 1.5F;
93
94 x = number2 * 0.5F;
95 y = number2;
96
97 i = * ( long * ) &y;
98 i = 0x5f3759df - ( i >> 1 );
99 y = * ( float * ) &i;
100 y = y * ( f - ( x * y * y ) );
101 y = y * ( f - ( x * y * y ) );
102 return number2 * y;
103}
104
105
41 106
42struct coord * 107struct coord *
43coord_get(unsigned char **p) 108coord_get(unsigned char **p)
44{ 109{
45 struct coord *ret=(struct coord *)(*p); 110 struct coord *ret=(struct coord *)(*p);

Legend:
Removed from v.27  
changed lines
  Added in v.28

   
Visit the ZANavi Wiki