Esempio n. 1
0
void coords_get_rect_gmp(coords* c, mpf_t xmin, mpf_t xmax,
                                    mpf_t ymax, mpf_t width)
{
    coords_center_to_rect(c);
    mpfr_to_gmp(c->xmin, xmin);
    mpfr_to_gmp(c->xmax, xmax);
    mpfr_to_gmp(c->ymax, ymax);
    mpfr_to_gmp(c->width, width);
}
Esempio n. 2
0
int fractal_gmp_calculate_line(image_info* img, int line)
{
    int ret = 1;
    int ix = 0;
    int mx = 0;
    int chk_px = ((rthdata*)img->rth_ptr)->check_stop_px;
    int img_width = img->real_width;
    int* raw_data = &img->raw_data[line * img_width];

    depth_t depth = img->depth;

    mpf_t  x,      y;
    mpf_t  x2,     y2;
    mpf_t  c_re,   c_im;

/*  working variables:      */
    mpf_t  wre,    wim;
    mpf_t  wre2,   wim2;

    mpf_t  frs_bail;
    mpf_t  width,  img_rw,    img_xmin;
    mpf_t  t1;

    mpf_init2(x,       img->precision);
    mpf_init2(y,       img->precision);
    mpf_init2(x2,      img->precision);
    mpf_init2(y2,      img->precision);
    mpf_init2(c_re,    img->precision);
    mpf_init2(c_im,    img->precision);
    mpf_init2(wre,     img->precision);
    mpf_init2(wim,     img->precision);
    mpf_init2(wre2,    img->precision);
    mpf_init2(wim2,    img->precision);
    mpf_init2(frs_bail,img->precision);
    mpf_init2(width,   img->precision);
    mpf_init2(img_rw,  img->precision);
    mpf_init2(img_xmin,img->precision);
    mpf_init2(t1,      img->precision);

    mpf_set_si(frs_bail,   4);
    mpf_set_si(img_rw,     img_width);
    mpf_set(   img_xmin,   img->gxmin);
    mpf_set(   width,      img->gwidth);

/*  y = img->ymax - ((img->xmax - img->xmin) 
                / (long double)img->real_width)
                * (long double)img->lines_done; */
    mpf_div(       t1,     width,      img_rw);

    mpf_mul_ui(    t1,     t1,         line);
    mpf_sub(       y,      img->gymax, t1);
    mpf_mul(       y2,     y,          y);

    while (ix < img_width)
    {
        mx += chk_px;
        if (mx > img_width)
            mx = img_width;
        for (; ix < mx; ++ix, ++raw_data)
        {
/*          x = ((long double)ix / (long double)img->real_width)
                * (img->xmax - img->xmin) + img->xmin;              */

            mpf_ui_div(t1,  ix,    img_rw);

            mpf_mul(x,      t1,    width);
            mpf_add(x,      x,     img_xmin);

            mpf_mul(   x2,     x,      x);
            mpf_set(   wre,    x);
            mpf_set(   wim,    y);
            mpf_set(   wre2,   x2);
            mpf_set(   wim2,   y2);

            switch (img->family)
            {
            case FAMILY_MANDEL:
                mpf_set(c_re,  x);
                mpf_set(c_im,  y);
                break;
            case FAMILY_JULIA:
                mpfr_to_gmp(img->u.julia.c_re, c_re);
                mpfr_to_gmp(img->u.julia.c_im, c_im);
                break;
            }
            switch(img->fractal)
            {
            case BURNING_SHIP:
                *raw_data = frac_burning_ship_gmp(
                                                depth, frs_bail,
                                                    wim, wre,
                                                    c_im, c_re,
                                                    wim2, wre2, t1);
                break;
            case GENERALIZED_CELTIC:
                *raw_data = frac_generalized_celtic_gmp(
                                                depth,  frs_bail,
                                                    wim, wre,
                                                    c_im, c_re,
                                                    wim2, wre2, t1);
                break;
            case VARIANT:
                *raw_data = frac_variant_gmp(
                                                depth, frs_bail,
                                                    wim, wre,
                                                    c_im, c_re,
                                                    wim2, wre2, t1);
                break;
            case MANDELBROT:
            default:
                *raw_data = frac_mandel_gmp(depth,  frs_bail,
                                                    wim, wre,
                                                    c_im, c_re,
                                                    wim2, wre2, t1);
            }
        }
        if (rth_render_should_stop((rthdata*)img->rth_ptr))
        {
            ret = 0;
            break;
        }
    }
    mpf_clear(x);
    mpf_clear(y);
    mpf_clear(x2);
    mpf_clear(y2);
    mpf_clear(c_re);
    mpf_clear(c_im);
    mpf_clear(wre);
    mpf_clear(wim);
    mpf_clear(wre2);
    mpf_clear(wim2);
    mpf_clear(frs_bail);
    mpf_clear(width);
    mpf_clear(img_rw);
    mpf_clear(t1);
    return ret;
}