int
juliabf_per_pixel()
{
    // old.x = xxmin + col*delx + row*delx2
    mult_bf_int(bfold.x, bfxdel, (U16)col);
    mult_bf_int(bftmp, bfxdel2, (U16)row);

    add_a_bf(bfold.x, bftmp);
    add_a_bf(bfold.x, bfxmin);

    // old.y = yymax - row*dely - col*dely2;
    // note: in next four lines, bfnew is just used as a temporary variable
    mult_bf_int(bfnew.x, bfydel, (U16)row);
    mult_bf_int(bfnew.y, bfydel2, (U16)col);
    add_a_bf(bfnew.x, bfnew.y);
    sub_bf(bfold.y, bfymax, bfnew.x);

    // square has side effect - must copy first
    copy_bf(bfnew.x, bfold.x);
    copy_bf(bfnew.y, bfold.y);

    // Square these to rbflength bytes of precision
    square_bf(bftmpsqrx, bfnew.x);
    square_bf(bftmpsqry, bfnew.y);

    return (1);                  // 1st iteration has been done
}
int  bfIMAGbailout()
{
    long longtempsqry;

    square_bf(bftmpsqrx, bfnew.x);
    square_bf(bftmpsqry, bfnew.y);
    longtempsqry = bftoint(bftmpsqry);
    if (longtempsqry >= (long)rqlim)
        return 1;
    copy_bf(bfold.x, bfnew.x);
    copy_bf(bfold.y, bfnew.y);
    return (0);
}
int  bfREALbailout()
{
    long longtempsqrx;

    square_bf(bftmpsqrx, bfnew.x);
    square_bf(bftmpsqry, bfnew.y);
    longtempsqrx = bftoint(bftmpsqrx);
    if (longtempsqrx >= (long)rqlim)
        return 1;
    copy_bf(bfold.x, bfnew.x);
    copy_bf(bfold.y, bfnew.y);
    return 0;
}
int  bfMODbailout()
{
    long longmagnitude;

    square_bf(bftmpsqrx, bfnew.x);
    square_bf(bftmpsqry, bfnew.y);
    add_bf(bftmp, bftmpsqrx, bftmpsqry);

    longmagnitude = bftoint(bftmp);
    if (longmagnitude >= (long)rqlim)
        return 1;
    copy_bf(bfold.x, bfnew.x);
    copy_bf(bfold.y, bfnew.y);
    return 0;
}
int  bfMANRbailout()
{
    long longtempmag;

    square_bf(bftmpsqrx, bfnew.x);
    square_bf(bftmpsqry, bfnew.y);
    add_bf(bftmp, bfnew.x, bfnew.y); // don't need abs since we square it next
    // note: in next two lines, bfold is just used as a temporary variable
    square_bf(bfold.x, bftmp);
    longtempmag = bftoint(bfold.x);
    if (longtempmag >= (long)rqlim)
        return 1;
    copy_bf(bfold.x, bfnew.x);
    copy_bf(bfold.y, bfnew.y);
    return (0);
}
int mandelbf_per_pixel()
{
    // parm.x = xxmin + col*delx + row*delx2
    mult_bf_int(bfparm.x, bfxdel, (U16)col);
    mult_bf_int(bftmp, bfxdel2, (U16)row);

    add_a_bf(bfparm.x, bftmp);
    add_a_bf(bfparm.x, bfxmin);

    // parm.y = yymax - row*dely - col*dely2;
    // note: in next four lines, bfold is just used as a temporary variable
    mult_bf_int(bfold.x, bfydel, (U16)row);
    mult_bf_int(bfold.y, bfydel2, (U16)col);
    add_a_bf(bfold.x, bfold.y);
    sub_bf(bfparm.y, bfymax, bfold.x);

    copy_bf(bfold.x, bfparm.x);
    copy_bf(bfold.y, bfparm.y);

    if ((inside == BOF60 || inside == BOF61) && !nobof)
    {
        /* kludge to match "Beauty of Fractals" picture since we start
           Mandelbrot iteration with init rather than 0 */
        floattobf(bfold.x, param[0]); // initial pertubation of parameters set
        floattobf(bfold.y, param[1]);
        coloriter = -1;
    }
    else
    {
        floattobf(bfnew.x, param[0]);
        floattobf(bfnew.y, param[1]);
        add_a_bf(bfold.x, bfnew.x);
        add_a_bf(bfold.y, bfnew.y);
    }

    // square has side effect - must copy first
    copy_bf(bfnew.x, bfold.x);
    copy_bf(bfnew.y, bfold.y);

    // Square these to rbflength bytes of precision
    square_bf(bftmpsqrx, bfnew.x);
    square_bf(bftmpsqry, bfnew.y);

    return (1);                  // 1st iteration has been done
}
int  bfMANHbailout()
{
    long longtempmag;

    square_bf(bftmpsqrx, bfnew.x);
    square_bf(bftmpsqry, bfnew.y);
    // note: in next five lines, bfold is just used as a temporary variable
    abs_bf(bfold.x, bfnew.x);
    abs_bf(bfold.y, bfnew.y);
    add_bf(bftmp, bfold.x, bfold.y);
    square_bf(bfold.x, bftmp);
    longtempmag = bftoint(bfold.x);
    if (longtempmag >= (long)rqlim)
        return 1;
    copy_bf(bfold.x, bfnew.x);
    copy_bf(bfold.y, bfnew.y);
    return (0);
}
示例#8
0
文件: ZOOM.C 项目: mmammel/projects
void zoomoutbf(void) /* for ctl-enter, calc corners for zooming out */
{
    /* (xxmin,yymax), etc, are already set to zoombox corners;
       (sxmin,symax), etc, are still the screen's corners;
       use the same logic as plot_orbit stuff to first calculate current screen
       corners relative to the zoombox, as if the zoombox were a square with
       upper left (0,0) and width/depth 1; ie calc the current screen corners
       as if plotting them from the zoombox;
       then extend these co-ords from current real screen corners to get
       new actual corners
       */
    bf_t savbfxmin,savbfymax,bfftemp;
    bf_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6,bfplotmx1,bfplotmx2,bfplotmy1,bfplotmy2;
    int saved;
    saved = save_stack();
    savbfxmin = alloc_stack(rbflength+2);
    savbfymax = alloc_stack(rbflength+2);
    bfftemp   = alloc_stack(rbflength+2);
    tmp1      = alloc_stack(rbflength+2);
    tmp2      = alloc_stack(rbflength+2);
    tmp3      = alloc_stack(rbflength+2);
    tmp4      = alloc_stack(rbflength+2);
    tmp5      = alloc_stack(rbflength+2);
    tmp6      = alloc_stack(rbflength+2);
    bfplotmx1 = alloc_stack(rbflength+2);
    bfplotmx2 = alloc_stack(rbflength+2);
    bfplotmy1 = alloc_stack(rbflength+2);
    bfplotmy2 = alloc_stack(rbflength+2);
    /* ftemp = (yymin-yy3rd)*(xx3rd-xxmin) - (xxmax-xx3rd)*(yy3rd-yymax); */
    sub_bf(tmp1,bfymin,bfy3rd);
    sub_bf(tmp2,bfx3rd,bfxmin);
    sub_bf(tmp3,bfxmax,bfx3rd);
    sub_bf(tmp4,bfy3rd,bfymax);
    mult_bf(tmp5,tmp1,tmp2);
    mult_bf(tmp6,tmp3,tmp4);
    sub_bf(bfftemp,tmp5,tmp6);
    /* plotmx1 = (xx3rd-xxmin); */ ; /* reuse the plotxxx vars is safe */
    copy_bf(bfplotmx1,tmp2);
    /* plotmx2 = (yy3rd-yymax); */
    copy_bf(bfplotmx2,tmp4);
    /* plotmy1 = (yymin-yy3rd); */
    copy_bf(bfplotmy1,tmp1);
    /* plotmy2 = (xxmax-xx3rd); */;
    copy_bf(bfplotmy2,tmp3);

    /* savxxmin = xxmin; savyymax = yymax; */
    copy_bf(savbfxmin,bfxmin); copy_bf(savbfymax,bfymax);

    sub_bf(tmp1,bfsxmin,savbfxmin); sub_bf(tmp2,bfsymax,savbfymax);
    zmo_calcbf(tmp1,tmp2,bfxmin,bfymax,bfplotmx1,bfplotmx2,bfplotmy1,
               bfplotmy2,bfftemp);
    sub_bf(tmp1,bfsxmax,savbfxmin); sub_bf(tmp2,bfsymin,savbfymax);
    zmo_calcbf(tmp1,tmp2,bfxmax,bfymin,bfplotmx1,bfplotmx2,bfplotmy1,
               bfplotmy2,bfftemp);
    sub_bf(tmp1,bfsx3rd,savbfxmin); sub_bf(tmp2,bfsy3rd,savbfymax);
    zmo_calcbf(tmp1,tmp2,bfx3rd,bfy3rd,bfplotmx1,bfplotmx2,bfplotmy1,
               bfplotmy2,bfftemp);
    restore_stack(saved);
}
bool MandelbfSetup()
{
    // this should be set up dynamically based on corners
    bf_t bftemp1, bftemp2;
    int saved;
    saved = save_stack();
    bftemp1 = alloc_stack(bflength+2);
    bftemp2 = alloc_stack(bflength+2);

    bf_math = bf_math_type::BIGFLT;

    // bfxdel = (bfxmax - bfx3rd)/(xdots-1)
    sub_bf(bfxdel, bfxmax, bfx3rd);
    div_a_bf_int(bfxdel, (U16)(xdots - 1));

    // bfydel = (bfymax - bfy3rd)/(ydots-1)
    sub_bf(bfydel, bfymax, bfy3rd);
    div_a_bf_int(bfydel, (U16)(ydots - 1));

    // bfxdel2 = (bfx3rd - bfxmin)/(ydots-1)
    sub_bf(bfxdel2, bfx3rd, bfxmin);
    div_a_bf_int(bfxdel2, (U16)(ydots - 1));

    // bfydel2 = (bfy3rd - bfymin)/(xdots-1)
    sub_bf(bfydel2, bfy3rd, bfymin);
    div_a_bf_int(bfydel2, (U16)(xdots - 1));

    abs_bf(bfclosenuff, bfxdel);
    if (cmp_bf(abs_bf(bftemp1, bfxdel2), bfclosenuff) > 0)
        copy_bf(bfclosenuff, bftemp1);
    if (cmp_bf(abs_bf(bftemp1, bfydel), abs_bf(bftemp2, bfydel2)) > 0)
    {
        if (cmp_bf(bftemp1, bfclosenuff) > 0)
            copy_bf(bfclosenuff, bftemp1);
    }
    else if (cmp_bf(bftemp2, bfclosenuff) > 0)
        copy_bf(bfclosenuff, bftemp2);
    {
        int t;
        t = abs(periodicitycheck);
        while (t--)
            half_a_bf(bfclosenuff);
    }

    c_exp = (int)param[2];
    switch (fractype)
    {
    case fractal_type::JULIAFP:
        copy_bf(bfparm.x, bfparms[0]);
        copy_bf(bfparm.y, bfparms[1]);
        break;
    case fractal_type::FPMANDELZPOWER:
        init_big_pi();
        if ((double)c_exp == param[2] && (c_exp & 1)) // odd exponents
            symmetry = symmetry_type::XY_AXIS_NO_PARAM;
        if (param[3] != 0)
            symmetry = symmetry_type::NONE;
        break;
    case fractal_type::FPJULIAZPOWER:
        init_big_pi();
        copy_bf(bfparm.x, bfparms[0]);
        copy_bf(bfparm.y, bfparms[1]);
        if ((c_exp & 1) || param[3] != 0.0 || (double)c_exp != param[2])
            symmetry = symmetry_type::NONE;
        break;
    default:
        break;
    }

    restore_stack(saved);
    return true;
}