2017-11-01 05:51:41 +00:00
|
|
|
package geom
|
|
|
|
|
2019-04-11 17:12:45 +00:00
|
|
|
// 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} }
|
|
|
|
|
2017-11-01 05:51:41 +00:00
|
|
|
// PolygonF is defined by a set of points (floating point).
|
|
|
|
type PolygonF struct {
|
2019-04-11 17:12:45 +00:00
|
|
|
Points PointsF
|
2017-11-01 05:51:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add creates a new polyqon based on p with one or more extra points q.
|
|
|
|
func (p PolygonF) Add(q ...PointF) PolygonF {
|
2019-04-11 17:12:45 +00:00
|
|
|
var t = PolygonF{make(PointsF, len(p.Points)+len(q))}
|
2017-11-01 05:51:41 +00:00
|
|
|
copy(t.Points, p.Points)
|
|
|
|
copy(t.Points[len(p.Points):], q)
|
|
|
|
return t
|
|
|
|
}
|