about summary refs log tree commit diff
path: root/structs/boundingBox.go
diff options
context:
space:
mode:
Diffstat (limited to 'structs/boundingBox.go')
-rw-r--r--structs/boundingBox.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/structs/boundingBox.go b/structs/boundingBox.go
new file mode 100644
index 0000000..ad02eab
--- /dev/null
+++ b/structs/boundingBox.go
@@ -0,0 +1,27 @@
+package structs
+
+// BoundingBox is a struct defining the spatial outreach of a box
+type BoundingBox struct {
+	center Vec2    // Center of the box
+	width  float64 // width of the box
+}
+
+func (b *BoundingBox) Width() float64 {
+	return b.width
+}
+
+func (b *BoundingBox) SetWidth(width float64) {
+	b.width = width
+}
+
+func (b *BoundingBox) Center() Vec2 {
+	return b.center
+}
+
+func (b *BoundingBox) SetCenter(center Vec2) {
+	b.center = center
+}
+
+func NewBoundingBox(center Vec2, halfDim float64) *BoundingBox {
+	return &BoundingBox{center: center, width: halfDim}
+}