Re: [AD] C++ fix math

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


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

On Saturday 10 August 2002 16:50, Eric Botcazou wrote:
> Here's the patch I'm going to check in modulo no new argument against
> it:
[snip]

This looks fine to me. Whilst we're at it, can we add a quick function
to convert to/from radians? Perhaps something like this:

fixed radtofix(fixed f) { return fixmul(f, (fixed)2670177) & 0xFFFF; }
fixed fixtorad(fixed f) { return fixmul(f, (fixed)1608); }

The numbers come from the 16.16 representation of 2pi/256 and 256/2pi.

And the corresponding fix functions:

class fix {
  public:
    // ...
    void radtofix() throw() { v = radtofix(v); }
    void fixtorad() throw() { v = fixtorad(v); }
};

This would probably be useful, and would certainly help clarity.

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)

iD8DBQE9VURtUdhclgSmRuoRAhMyAKCCFacGu4ekgzxS5JVqJSsUEx5alwCgqpuW
+5NWPI8G0308DyvYR0X259c=
=yCW2
-----END PGP SIGNATURE-----



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