Ejemplo n.º 1
0
func Coord(vol volume.Space16, index int) (x, y, z int) {
	z = index % vol.N()
	index /= vol.N()
	y = index % vol.N()
	index /= vol.N()
	x = index
	return
}
Ejemplo n.º 2
0
func NewVolumeField(vol volume.Space16) g3.ScalarField {
	return func(p g3.Point) float64 {
		for _, v := range p {
			if v <= 0 || v >= 1 {
				return 0
			}
		}
		xx := int(p[0] * float64(vol.N()))
		yy := int(p[1] * float64(vol.N()))
		zz := int(p[2] * float64(vol.N()))
		val := vol.Get(g3.Node{xx, yy, zz})
		if val {
			return 100
		}
		return 0
	}
}
Ejemplo n.º 3
0
func NewVolumeField2(vol volume.Space16) g3.ScalarField {
	return func(p g3.Point) float64 {
		for _, v := range p {
			if v <= 0 || v >= 1 {
				return 0
			}
		}

		fx := p[0] * float64(vol.N())
		fy := p[1] * float64(vol.N())
		fz := p[2] * float64(vol.N())

		xx := int(fx)
		yy := int(fy)
		zz := int(fz)

		dx := fx - float64(xx) - 0.5
		dy := fy - float64(yy) - 0.5
		dz := fz - float64(zz) - 0.5

		//		r02 := dx*dx + dy*dy + dz*dz + 0.1

		var val float64
		for _, cell := range cells {
			var v float64
			if vol.Get(g3.Node{xx + cell.dx, yy + cell.dy, zz + cell.dz}) {
				v = 1
			}
			ddx := dx - float64(cell.dx)
			ddy := dy - float64(cell.dy)
			ddz := dz - float64(cell.dz)
			r2 := ddx*ddx + ddy*ddy + ddz*ddz + 0.1
			val += cell.weight * v / r2
		}
		/*		v0 := float64(0)
				if vol.Get(xx, yy, zz) {
					v0 = 1
				}
				val := 0.85 * v0 / r02*/
		return val
	}
}
Ejemplo n.º 4
0
func Index(vol volume.Space16, x, y, z int) int {
	return x*vol.N()*vol.N() + y*vol.N() + z
}