Documentation ¶
Index ¶
- Variables
- func EqualBBox(a, b BBox) bool
- func EqualContour(c1, c2 Contour) bool
- func EqualEdge(a, b manhattanEdge) bool
- func EqualFloat(a, b float64) bool
- func EqualFloat64Slice(a, b []float64) bool
- func EqualPolygon(a, b Polygon) bool
- func EqualVertex(a, b Vertex) bool
- func IsInRangeFloat64(x, a, b float64) bool
- func IsStrictlyBelowFloat(a, b float64) bool
- func SquaredDistanceOfPointToSegment(p, p0, p1 Vertex) float64
- func SquaredDistancePointToPolygon(point Vertex, p Polygon) float64
- type BBox
- type Contour
- type Polygon
- type SVGWriter
- func (w *SVGWriter) Circle(x, y, radius float64)
- func (w *SVGWriter) Contour(c *Contour)
- func (w *SVGWriter) GroupEnd()
- func (w *SVGWriter) GroupStart(classname string)
- func (w *SVGWriter) Height() int
- func (w *SVGWriter) MoveToOrigin()
- func (w *SVGWriter) Polygon(p *Polygon)
- func (w *SVGWriter) PolygonWithClass(p *Polygon, class string)
- func (w *SVGWriter) Rect(x, y, width, height float64)
- func (w *SVGWriter) RectWithClass(x, y, width, height float64, class string)
- func (w *SVGWriter) Style(style string)
- func (w *SVGWriter) Text(text string, x, y float64)
- func (w *SVGWriter) Translate(x0, y0 float64)
- func (w *SVGWriter) ViewBox(xleft, xright, ybottom, ytop float64)
- func (w *SVGWriter) ViewBoxHeight() float64
- func (w *SVGWriter) ViewBoxWidth() float64
- func (w *SVGWriter) Width() int
- func (w *SVGWriter) WriteHTML(out io.Writer)
- func (w *SVGWriter) WriteSVG(out io.Writer)
- func (w *SVGWriter) WriteStyle(out io.Writer)
- type Vertex
Constants ¶
This section is empty.
Variables ¶
var ( // ErrWrongOrientation indicates that an attempt was made to use clockwise polygons // (or a mix of counter and clock-wise polygons), while this library's algorithms // only works with counter-clockwise polygons ErrWrongOrientation = errors.New("polygons should be oriented counterclockwise for this algorithm") )
Functions ¶
func EqualBBox ¶
EqualBBox checks if two boxes are equal. For the precision of the comparison see EqualFloat function.
func EqualContour ¶
EqualContour returns true if the two contours have the same set of (sorted) vertices
func EqualEdge ¶
func EqualEdge(a, b manhattanEdge) bool
EqualEdge returns true if edges a and b are equal
func EqualFloat ¶
EqualFloat checks if two float64 are equal within 1E-4 (on difference)
func EqualFloat64Slice ¶
EqualFloat64Slice checks if two float64 slices are equal (same elements in exact same order)
func EqualPolygon ¶
EqualPolygon checks if two polygon are the same (same vertices, whetever the order)
func EqualVertex ¶
EqualVertex checks if two vertices are equal For the precision of the comparison see EqualFloat function.
func IsInRangeFloat64 ¶
IsInRangeFloat64 returns true if a<=x<=b
func IsStrictlyBelowFloat ¶
IsStrictlyBelowFloat returns true if a < b
func SquaredDistanceOfPointToSegment ¶
SquaredDistanceOfPointToSegment computes the square of the distance between point p and segment (p0,p1)
func SquaredDistancePointToPolygon ¶
SquaredDistancePointToPolygon return the square of the distance between a point and a polygon
Types ¶
type BBox ¶
type BBox interface { Xcenter() float64 Ycenter() float64 Width() float64 Height() float64 Xmin() float64 Xmax() float64 Ymin() float64 Ymax() float64 Contains(x, y float64) bool fmt.Stringer }
BBox describes a simple bounding box.
func NewBBoxUnchecked ¶
NewBBoxUnchecked return a bbox that might contain garbage (mostly used in test to ease declaration of multiple bounding boxes)
type Contour ¶
type Contour []Polygon
Contour is a set of polygons
func NewContour ¶
NewContour returns the boolean union of the polygons
type Polygon ¶
type Polygon []Vertex
Polygon describes a simple, rectilinear, closed set of vertices with a specific orientation
func (Polygon) Contains ¶
Contains returns true if the point (xp,yp) is inside the polygon
Note that this algorithm yields unpredicatable result if the point xp,yp is on one edge of the polygon. Should not generally matters, except when comparing two different implementations maybe.
TODO : look e.g. to http://alienryderflex.com/polygon/ for some possible optimizations (e.g. pre-computation)
type SVGWriter ¶
type SVGWriter struct {
// contains filtered or unexported fields
}
SVGWriter is a utility object to create SVG output for polygon, contours etc...
func NewSVGWriter ¶
func (*SVGWriter) GroupStart ¶
GroupStart starts a group tag with a given classname.
func (*SVGWriter) MoveToOrigin ¶
func (w *SVGWriter) MoveToOrigin()
func (*SVGWriter) PolygonWithClass ¶
PolygonWithClass adds a polygon object with a given CSS class
func (*SVGWriter) RectWithClass ¶
Rect adds a rectangle object
func (*SVGWriter) ViewBoxHeight ¶
func (*SVGWriter) ViewBoxWidth ¶
func (*SVGWriter) WriteStyle ¶
WriteStyle outputs <style> options