Exemplo n.º 1
0
func (d distort) para(time *big.Float) *big.Float {
	prec := d.next.Prec()
	delta := bigbase.MakeBigFloat(0.0, prec)

	delta.Sub(&d.next, &d.prev)
	delta.Mul(&delta, time)

	extra := bigbase.MakeBigFloat(0.0, prec)

	return extra.Add(&d.prev, &delta)
}
Exemplo n.º 2
0
func (z *Zoom) lens(degree float64) *Info {
	appinfo := new(Info)
	*appinfo = z.Prev
	appinfo.UserRequest.FixAspect = config.Stretch
	baseapp := makeBaseFacade(appinfo)
	app := makeBigBaseFacade(appinfo, baseapp)
	num := bigbase.Make(app)

	time := bigbase.MakeBigFloat(degree, num.Precision)

	// Y min and max reversed as pixels grow downward...
	min := num.PixelToPlane(int(z.Xmin), int(z.Ymax))
	max := num.PixelToPlane(int(z.Xmax), int(z.Ymin))

	target := []big.Float{
		min.R,
		min.I,
		max.R,
		max.I,
	}

	bounds := []big.Float{
		z.Prev.RealMin,
		z.Prev.ImagMin,
		z.Prev.RealMax,
		z.Prev.ImagMax,
	}

	zoom := make([]*big.Float, len(bounds))
	for i, b := range bounds {
		d := distort{
			prev: b,
			next: target[i],
		}

		res := d.para(&time)
		zoom[i] = res
	}

	info := new(Info)
	*info = z.Prev
	info.RealMin = *zoom[0]
	info.ImagMin = *zoom[1]
	info.RealMax = *zoom[2]
	info.ImagMax = *zoom[3]
	info.UserRequest = info.GenRequest()

	return info
}
Exemplo n.º 3
0
func TestRegionSplitNegPos(t *testing.T) {
	helper := bigRegionSplitHelper{
		left:   bigbase.MakeBigFloat(-100.0, prec),
		right:  bigbase.MakeBigFloat(24.0, prec),
		top:    bigbase.MakeBigFloat(10.0, prec),
		bottom: bigbase.MakeBigFloat(-340.0, prec),
		midR:   bigbase.MakeBigFloat(-38.0, prec),
		midI:   bigbase.MakeBigFloat(-165.0, prec),
	}

	testRegionSplit(helper, t)
}
Exemplo n.º 4
0
func TestRegionSplitPos(t *testing.T) {
	helper := bigRegionSplitHelper{
		left:   bigbase.MakeBigFloat(1.0, prec),
		right:  bigbase.MakeBigFloat(3.0, prec),
		top:    bigbase.MakeBigFloat(3.0, prec),
		bottom: bigbase.MakeBigFloat(1.0, prec),
		midR:   bigbase.MakeBigFloat(2.0, prec),
		midI:   bigbase.MakeBigFloat(2.0, prec),
	}

	testRegionSplit(helper, t)
}
Exemplo n.º 5
0
// 3. Operational constants.  This program uses various integers in control
//    flow, in arithmetic, and when requesting memory from the operating system.
//    These are the least "magical" numbers present in this program.  Each of
//    these should be reviewed, since it may be desirable to replace these with
//    an item that can be configured at runtime.

// MATHEMATICAL CONSTANTS

// Minimum bounds of Mandelbrot set
const MandelbrotMin complex128 = -2.01 - 1.11i

// Maximum bounds of Mandelbrot set
const MandelbrotMax complex128 = 0.59 + 1.13i

// Named bignums
var bigZero big.Float = bigbase.MakeBigFloat(0, DefaultHighPrec)
var bigOne big.Float = bigbase.MakeBigFloat(1, DefaultHighPrec)
var bigTwo big.Float = bigbase.MakeBigFloat(2, DefaultHighPrec)

// DEFAULTS

// Default high precision for newly created big floats
const DefaultHighPrec uint = 500

// Default precision is for native arithmetic
const DefaultPrecision uint = 53

const DefaultIterations uint8 = 255
const DefaultDivergeLimit float64 = 4.0
const DefaultImageWidth uint = 600
const DefaultImageHeight uint = 600
Exemplo n.º 6
0
func (c *configurator) fixAspect() error {
	if __DEBUG {
		log.Println("Fixing aspect ratio")
	}

	rmin := big.NewFloat(0.0).Copy(&c.RealMin)
	rmax := big.NewFloat(0.0).Copy(&c.RealMax)
	imin := big.NewFloat(0.0).Copy(&c.ImagMin)
	imax := big.NewFloat(0.0).Copy(&c.ImagMax)

	planeWidth := bb.MakeBigFloat(0.0, c.Precision)
	planeHeight := bb.MakeBigFloat(0.0, c.Precision)
	planeAspect := bb.MakeBigFloat(0.0, c.Precision)

	planeWidth.Sub(rmax, rmin)
	planeHeight.Sub(imax, imin)
	planeAspect.Quo(&planeWidth, &planeHeight)

	nativePictureAspect := float64(c.UserRequest.ImageWidth) / float64(c.UserRequest.ImageHeight)
	pictureAspect := bb.MakeBigFloat(nativePictureAspect, c.Precision)
	thindicator := planeAspect.Cmp(&pictureAspect)

	adjustWidth := func() {
		trans := bb.MakeBigFloat(0.0, c.Precision)
		trans.Mul(&planeHeight, &pictureAspect)
		rmax.Add(rmin, &trans)
		c.RealMax = *rmax
	}

	adjustHeight := func() {
		trans := bb.MakeBigFloat(0.0, c.Precision)
		trans.Quo(&planeWidth, &pictureAspect)
		imax.Add(imin, &trans)
		c.ImagMax = *imax
	}

	if __TRACE {
		log.Printf("Old Plane Width: %v", bb.DbgF(planeWidth))
		log.Printf("Old Plane Height: %v", bb.DbgF(planeHeight))
		log.Printf("Old Plane Aspect: %v", bb.DbgF(planeAspect))
		log.Printf("Image Width: %v", c.UserRequest.ImageWidth)
		log.Printf("Image Height: %v", c.UserRequest.ImageHeight)
		log.Printf("Image Aspect: %v", bb.DbgF(pictureAspect))
	}

	var strategy = c.UserRequest.FixAspect

	if strategy == config.Grow {
		// Then the plane is too short, so must be made taller
		if thindicator == 1 {
			if __DEBUG {
				log.Println("Plane becomes taller")
			}
			adjustHeight()
		} else if thindicator == -1 {
			if __DEBUG {
				log.Println("Plane becomes fatter")
			}
			// Then the plane is too thin, and must be made fatter
			adjustWidth()
		}
	} else if strategy == config.Shrink {
		if thindicator == 1 {
			// The plane is too fat, so must be made thinner
			if __DEBUG {
				log.Println("Plane becomes thinner")
			}
			adjustWidth()
		} else if thindicator == -1 {
			if __DEBUG {
				log.Println("Plane becomes shorter")
			}
			// The plane is too tall, so must be made shorter
			adjustHeight()
		}
	}

	if __TRACE && (strategy == config.Shrink || strategy == config.Grow) {
		fixWidth := bb.MakeBigFloat(0.0, c.Precision)
		fixHeight := bb.MakeBigFloat(0.0, c.Precision)
		fixAspect := bb.MakeBigFloat(0.0, c.Precision)

		fixWidth.Sub(rmax, rmin)
		fixHeight.Sub(imax, imin)
		fixAspect.Quo(&fixWidth, &fixHeight)

		log.Printf("New Plane Width: %v", bb.DbgF(fixWidth))
		log.Printf("New Plane Height: %v", bb.DbgF(fixHeight))
		log.Printf("Fixed Aspect: %v", bb.DbgF(fixAspect))
	}

	return nil
}