diff options
-rw-r--r-- | structs/structs.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/structs/structs.go b/structs/structs.go index 6f1dd57..b4b550a 100644 --- a/structs/structs.go +++ b/structs/structs.go @@ -16,3 +16,18 @@ type boundingBox struct { center coord halfDimension float64 } + +// containsPoint returns true if the given point is inside of the boundingBox the method is called on +func (boundingBox *boundingBox) containsPoint(point coord) bool { + // find out if the point is in or outside of the box + if boundingBox.center.x-boundingBox.halfDimension < point.x && boundingBox.center.x+boundingBox.halfDimension > point.x { + if boundingBox.center.y-boundingBox.halfDimension < point.y && boundingBox.center.y+boundingBox.halfDimension > point.y { + + // the point is inside of the cell -> return true + return true + } + } + + // the point is outside of the cell -> return false + return false +} |