Re: Shouldn't Cairo use/offer degrees rather than radians?

Lawrence D'Oliveiro <[email protected]>
Newsgroups gmane.comp.lib.cairo
Organization Geek Central
Message-ID <[email protected]>
On Wed, 28 Jun 2017 12:34:34 +0200, David Kastrup wrote:

> That is more than Cairo can deliver right now.

Only by special-casing
<http://git.ghostscript.com/?p=ghostpdl.git;a=blob;f=base/gsmisc.c;h=1ade8db12a9f0ac685396421107333e9347404a2;hb=HEAD>:

    static const int isincos[5] =
    {0, 1, 0, -1, 0};

    /* GCC with -ffast-math compiles ang/90. as ang*(1/90.), losing precission.
     * This doesn't happen when the numeral is replaced with a non-const variable.
     * So we define the variable to work around the GCC problem.
     */
    double const_90_degrees = 90.;

    double
    gs_sin_degrees(double ang)
    {
        double quot = ang / const_90_degrees;

        if (floor(quot) == quot) {
            /*
             * We need 4.0, rather than 4, here because of non-ANSI compilers.
             * The & 3 is because quot might be negative.
             */
            return isincos[(int)fmod(quot, 4.0) & 3];
        }
        return sin(ang * (M_PI / 180));
    }

    double
    gs_cos_degrees(double ang)
    {
        double quot = ang / const_90_degrees;

        if (floor(quot) == quot) {
            /* See above re the following line. */
            return isincos[((int)fmod(quot, 4.0) & 3) + 1];
        }
        return cos(ang * (M_PI / 180));
    }

Do you really want to see hacks like that in the Cairo code?
-- 
cairo mailing list
[email protected]
https://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.