2017-11-01 05:51:41 +00:00
|
|
|
package geom
|
|
|
|
|
|
|
|
// PointF32 is an X, Y coordinate pair (floating point, 32 bits).
|
|
|
|
type PointF32 struct {
|
|
|
|
X, Y float32
|
|
|
|
}
|
2018-07-18 18:05:06 +00:00
|
|
|
|
2018-08-07 04:56:31 +00:00
|
|
|
// ZeroPtF32 is initialized on (0, 0).
|
|
|
|
var ZeroPtF32 = PointF32{X: 0, Y: 0}
|
|
|
|
|
2018-07-18 18:05:06 +00:00
|
|
|
// PtF32 is a shorthand function to create a point.
|
|
|
|
func PtF32(x, y float32) PointF32 {
|
|
|
|
return PointF32{x, y}
|
|
|
|
}
|
2018-09-23 07:42:08 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|