Added Max for floating point numbers.
This commit is contained in:
parent
060dd4380c
commit
45e7d0c8fd
22
math.go
22
math.go
@ -17,7 +17,27 @@ func NaN() float64 {
|
|||||||
return math.NaN()
|
return math.NaN()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NaN32 returns not a floating point number.
|
// NaN32 returns not a floating point number.
|
||||||
func NaN32() float32 {
|
func NaN32() float32 {
|
||||||
return float32(NaN())
|
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)))
|
||||||
|
}
|
||||||
|
@ -12,3 +12,11 @@ var ZeroPtF32 = PointF32{X: 0, Y: 0}
|
|||||||
func PtF32(x, y float32) PointF32 {
|
func PtF32(x, y float32) PointF32 {
|
||||||
return PointF32{x, y}
|
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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user