diff --git a/math.go b/math.go index 0d9be4b..5c1346c 100644 --- a/math.go +++ b/math.go @@ -17,7 +17,27 @@ func NaN() float64 { return math.NaN() } -// NaN32 returns not a floating point number. +// NaN32 returns not a floating point number. func NaN32() float32 { return float32(NaN()) } + +// Max the maximum of the two values. +func Max(a, b float64) float64 { + return math.Max(a, b) +} + +// Max32 the maximum of the two values. +func Max32(a, b float32) float32 { + return float32(math.Max(float64(a), float64(b))) +} + +// Min the minimum of the two values. +func Min(a, b float64) float64 { + return math.Min(a, b) +} + +// Min32 the minimum of the two values. +func Min32(a, b float32) float32 { + return float32(math.Min(float64(a), float64(b))) +} diff --git a/pointf32.go b/pointf32.go index 716fdc2..9552f81 100644 --- a/pointf32.go +++ b/pointf32.go @@ -12,3 +12,11 @@ var ZeroPtF32 = PointF32{X: 0, Y: 0} func PtF32(x, y float32) PointF32 { return PointF32{x, y} } + +// In tests if the point p is inside the rectangle r. +func (p PointF32) In(r RectangleF32) bool { + if p.X < r.Min.X || p.X >= r.Max.X || p.Y < r.Min.Y || p.Y >= r.Max.Y { + return false + } + return true +}