Exemplo n.º 1
0
func createBigRegion(big bigbase.BigBaseNumerics, min bigbase.BigComplex, max bigbase.BigComplex) bigRegion {
	left := min.R
	bottom := min.I
	right := max.R
	top := max.I

	bigTwo := big.MakeBigFloat(2.0)

	midR := big.MakeBigFloat(0.0)
	midR.Add(&right, &left)
	midR.Quo(&midR, &bigTwo)

	midI := big.MakeBigFloat(0.0)
	midI.Add(&top, &bottom)
	midI.Quo(&midI, &bigTwo)

	coords := []bigbase.BigComplex{
		bigbase.BigComplex{left, top},
		bigbase.BigComplex{right, top},
		bigbase.BigComplex{left, bottom},
		bigbase.BigComplex{right, bottom},
		bigbase.BigComplex{midR, midI}, // midpoint is not technically a corner
	}

	points := make([]bigbase.BigEscapeValue, len(coords))

	for i, c := range coords {
		z := big.MakeBigComplex(0.0, 0.0)
		z.R.Copy(c.Real())
		z.I.Copy(c.Imag())
		p := big.Escape(&z)
		points[i] = p
	}

	return bigRegion{
		topLeft:     points[0],
		topRight:    points[1],
		bottomLeft:  points[2],
		bottomRight: points[3],
		midPoint:    points[4],
	}
}
func TestBigProxyRegionClaimExtrinsics(t *testing.T) {
	const prec = 53
	const ilim = 255
	parent := bigbase.BigBaseNumerics{}
	parent.IterateLimit = ilim
	parent.Precision = prec
	parent.SqrtDivergeLimit = parent.MakeBigFloat(2.0)
	min := parent.MakeBigComplex(-1.0, -1.0)
	max := parent.MakeBigComplex(1.0, 1.0)

	big := BigRegionNumericsProxy{}
	big.BigRegionNumerics = &BigRegionNumerics{}
	big.LocalRegion = createBigRegion(parent, min, max)

	big.ClaimExtrinsics()

	if !regionEq(big.LocalRegion, big.BigRegionNumerics.Region) {
		t.Error("Expected", big.LocalRegion,
			"but received", big.BigRegionNumerics.Region)
	}
}
Exemplo n.º 3
0
func testRegionSplit(helper bigRegionSplitHelper, t *testing.T) {
	const iterlim = 255
	parent := bigbase.BigBaseNumerics{}
	parent.Precision = prec
	parent.SqrtDivergeLimit = parent.MakeBigFloat(2.0)
	parent.IterateLimit = iterlim

	initMin := bigbase.BigComplex{helper.left, helper.bottom}
	initMax := bigbase.BigComplex{helper.right, helper.top}

	topLeftMin := bigbase.BigComplex{helper.left, helper.midI}
	topLeftMax := bigbase.BigComplex{helper.midR, helper.top}

	topRightMin := bigbase.BigComplex{helper.midR, helper.midI}
	topRightMax := bigbase.BigComplex{helper.right, helper.top}

	bottomLeftMin := bigbase.BigComplex{helper.left, helper.bottom}
	bottomLeftMax := bigbase.BigComplex{helper.midR, helper.midI}

	bottomRightMin := bigbase.BigComplex{helper.midR, helper.bottom}
	bottomRightMax := bigbase.BigComplex{helper.right, helper.midI}

	subjectRegion := createBigRegion(parent, initMin, initMax)

	expected := []bigRegion{
		createBigRegion(parent, topLeftMin, topLeftMax),
		createBigRegion(parent, topRightMin, topRightMax),
		createBigRegion(parent, bottomLeftMin, bottomLeftMax),
		createBigRegion(parent, bottomRightMin, bottomRightMax),
	}

	numerics := BigRegionNumerics{}
	numerics.BigBaseNumerics = parent
	numerics.Region = subjectRegion
	numerics.Split()
	actualChildren := numerics.subregion.children

	for i, expectReg := range expected {
		actReg := actualChildren[i]
		exPoints := expectReg.points()
		acPoints := actReg.points()

		fail := false
		for j, ep := range exPoints {
			ap := acPoints[j]
			okay := bigbase.BigComplexEq(ep.C, ap.C)
			if !okay {
				fail = true
				t.Log("Region", i, "error at point", j,
					"\nexpected\t", bigbase.DbgC(*ep.C),
					"\nbut received\t", bigbase.DbgC(*ap.C))
			}
		}
		if fail {
			t.Fail()
		}
	}
}
Exemplo n.º 4
0
// Rect return a rectangle representing the position and dimensions of the region on the output
// image.
func (br *bigRegion) rect(base *bigbase.BigBaseNumerics) image.Rectangle {
	l, t := base.PlaneToPixel(br.topLeft.C)
	r, b := base.PlaneToPixel(br.bottomRight.C)
	return image.Rect(l, t, r, b)
}