geom/polygonf.go

21 lines
520 B
Go

package geom
// PointsF is a set of points.
type PointsF []PointF
// PolF creates a polygon of points q.
func PolF(q ...PointF) PolygonF { return PolygonF{Points: q} }
// PolygonF is defined by a set of points (floating point).
type PolygonF struct {
Points PointsF
}
// Add creates a new polyqon based on p with one or more extra points q.
func (p PolygonF) Add(q ...PointF) PolygonF {
var t = PolygonF{make(PointsF, len(p.Points)+len(q))}
copy(t.Points, p.Points)
copy(t.Points[len(p.Points):], q)
return t
}