adding rectfrompoint

This commit is contained in:
Fraser Graham 2013-10-21 07:50:16 -07:00
parent 84c959f0df
commit b350b001da
1 changed files with 6 additions and 0 deletions

View File

@ -71,6 +71,12 @@ func PointInRect(p Point2d, r Rect2d) bool {
return (p.X > r.A.X) && (p.X < r.B.X) && (p.Y > r.A.Y) && (p.Y < r.B.Y)
}
func RectFromPoint(p Point2d, size float32) Rect2d {
return Rect2d{
A: Point2d{X: p.X - size, Y: p.Y - size},
B: Point2d{X: p.X + size, Y: p.Y + size}}
}
func RectIntersection(r Rect2d, p Point2d, v Vector2d) (bool, bool, Point2d) {
collision := false
inside := false