func (obj *Object) BoundsToSpace(dx, dy float64) (int, int, int, int) {
	cx, cy := obj.Space.WorldToSpace(obj.X+dx, obj.Y+dy)
	ex, ey := obj.Space.WorldToSpace(obj.X+obj.W+dx-1, obj.Y+obj.H+dy-1)
	return cx, cy, ex, ey
}
BoundsToSpace returns the Space coordinates of the shape (x, y, w, and h), given its world position and size, and a supposed movement of dx and dy.
package resolv
import (
	"math"
	"sort"
	"github.com/kvartborg/vector"
)
type Object struct {
	Shape         Shape             
	Space         *Space            
	X, Y, W, H    float64           
	TouchingCells []*Cell           
	Data          interface{}       
	ignoreList    map[*Object]bool  
	tags          []string          
}
func NewObject(x, y, w, h float64, tags ...string) *Object {
	o := &Object{
		X:          x,
		Y:          y,
		W:          w,
		H:          h,
		tags:       []string{},
		ignoreList: map[*Object]bool{},
	}
	if len(tags) > 0 {
		o.AddTags(tags...)
	}
	return o
}
func (obj *Object) Clone() *Object {
	newObj := NewObject(obj.X, obj.Y, obj.W, obj.H, obj.Tags()...)
	newObj.Data = obj.Data
	if obj.Shape != nil {
		newObj.SetShape(obj.Shape.Clone())
	}
	for k := range obj.ignoreList {
		newObj.AddToIgnoreList(k)
	}
	return newObj
}
func (obj *Object) Update() {
	if obj.Space != nil {
		space := obj.Space
		obj.Space.Remove(obj)
		obj.Space = space
		cx, cy, ex, ey := obj.BoundsToSpace(0, 0)
		for y := cy; y <= ey; y++ {
			for x := cx; x <= ex; x++ {
				c := obj.Space.Cell(x, y)
				if c != nil {
					c.register(obj)
					obj.TouchingCells = append(obj.TouchingCells, c)
				}
			}
		}
	}
	if obj.Shape != nil {
		obj.Shape.SetPosition(obj.X, obj.Y)
	}
}
func (obj *Object) AddTags(tags ...string) {
	obj.tags = append(obj.tags, tags...)
}
func (obj *Object) RemoveTags(tags ...string) {
	for _, tag := range tags {
		for i, t := range obj.tags {
			if t == tag {
				obj.tags = append(obj.tags[:i], obj.tags[i+1:]...)
				break
			}
		}
	}
}
func (obj *Object) HasTags(tags ...string) bool {
	for _, tag := range tags {
		for _, t := range obj.tags {
			if t == tag {
				return true
			}
		}
	}
	return false
}
func (obj *Object) Tags() []string {
	return append([]string{}, obj.tags...)
}
func (obj *Object) SetShape(shape Shape) {
	if obj.Shape != shape {
		obj.Shape = shape
		obj.Update()
	}
}