Re: [AD] About the fixed type (continued)

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 28 August 2002 17:58, Eric Botcazou wrote:
> I don't think it's sufficient even for C (let alone C++) because of
> the risk of confusing the user about its semantic type (long or
> fixed). So I think a 'const fixed' is necessary for C, as a 'const
> fix' is needed for C++.

OK, patch attached (for C only). It includes declaration in 'fixed.h' 
(the single typedef was looking a bit lonely), definition in 'math.c', 
and documentation under fixed point trig.

I chose the names fixtorad_r and radtofix_r, representing fixed 
point->radian ratio and radian->fixed point ratio respectively.

Bye for now,
- -- 
Laurence Withers,  lwithers@xxxxxxxxxx
(GnuPG 04A646EA) http://www.lwithers.demon.co.uk/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9bUiGUdhclgSmRuoRAnz/AJwIoj87dlE1iXv8jmG4V8WblduY/gCdFO3N
Rdy1lx21qLm/jE18xCs+KHQ=
=IsdT
-----END PGP SIGNATURE-----
diff -ru allegro.old/docs/src/allegro._tx allegro/docs/src/allegro._tx
--- allegro.old/docs/src/allegro._tx	Wed Aug 28 22:47:19 2002
+++ allegro/docs/src/allegro._tx	Wed Aug 28 22:59:54 2002
@@ -6559,6 +6559,18 @@
 bitwise 'and' can be used to keep the angle within the range zero to a full 
 circle, eliminating all those tiresome 'if (angle &gt= 360)' checks.
 
+@@extern const fixed @fixtorad_r;
+@xref fixmul, radtofix_r
+   This constant gives a ratio which can be used to convert a number in
+   radians to a number in fixed point angle format: if 'x' is a float
+   in radians, then use: 'y = fixmul(ftofix(x), fixtorad_r);'.
+   
+@@extern const fixed @radtofix_r;
+@xref fixmul, fixtorad_r
+   This constant gives a ratio to convert a number in fixed point angle
+   format into radians: if 'y' is a fixed point angle, then use:
+   'x = fixtof(fixmul(y, radtofix_r));'.
+
 @@fixed @fixsin(fixed x);
 @xref Fixed point trig
    Lookup table sine.
diff -ru allegro.old/include/allegro/fixed.h allegro/include/allegro/fixed.h
--- allegro.old/include/allegro/fixed.h	Wed Aug 28 22:47:25 2002
+++ allegro/include/allegro/fixed.h	Wed Aug 28 22:51:03 2002
@@ -24,6 +24,8 @@
 #endif
 
 typedef long fixed;
+extern const fixed fixtorad_r;
+extern const fixed radtofix_r;
 
 #ifdef __cplusplus
    }
diff -ru allegro.old/src/math.c allegro/src/math.c
--- allegro.old/src/math.c	Wed Aug 28 22:47:30 2002
+++ allegro/src/math.c	Wed Aug 28 22:53:02 2002
@@ -281,6 +281,14 @@
 
 
 
+/* fixtorad_r, radtofix_r:
+ *  Ratios for converting between radians and fixed point angles.
+ */
+const fixed fixtorad_r = (fixed)2670177;
+const fixed radtofix_r = (fixed)1608;
+
+
+
 #if (defined ALLEGRO_I386) && (!defined ALLEGRO_USE_C)
 
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/