Documentation ¶
Index ¶
- func Determinate(a, b, c Point) float64
- func IsClockwise(poly []Point) bool
- func IsConvex(a, b, c Point) bool
- func LineIntersects(line1, line2 []Point) (bool, error)
- func PointInsidePolygon(p *Point, polygon *Polygon) bool
- func PointInsideTriangle(p, ta, tb, tc *Point) bool
- func PolygonArea(data []Point) float64
- type BoundingBox
- type Circle
- func (circle *Circle) CircleInside(circleCandidate *Circle) bool
- func (circle *Circle) GetBoundingBox() BoundingBox
- func (circle *Circle) GetID() int64
- func (circle *Circle) GetName() string
- func (circle *Circle) GetProperties() ShapeProperties
- func (circle *Circle) PointInside(point *Point) bool
- func (circle *Circle) PointInsideBoundingBox(point *Point) bool
- func (circle *Circle) PolygonInside(polygon *Polygon) bool
- func (circle *Circle) SetID(id int64)
- func (circle *Circle) SetProperties(shapeProperties ShapeProperties)
- func (circle *Circle) ShapeInside(shape Shape) bool
- func (circle *Circle) Type() string
- type Point
- func (p1 *Point) Cross(p2 *Point) float64
- func (p1 *Point) DistanceTo(p2 *Point) float64
- func (p1 *Point) DistanceToLine(a, b *Point) float64
- func (p1 *Point) Divide(value float64) Point
- func (p1 *Point) Dot(p2 *Point) float64
- func (p1 *Point) Equal(p2 *Point) bool
- func (p1 *Point) MinusPoint(p2 *Point) Point
- func (p1 *Point) PlusPoint(p2 *Point) Point
- func (p1 *Point) Times(value float64) Point
- type PointElement
- type Polygon
- func (polygon *Polygon) CircleInside(circle *Circle) bool
- func (polygon *Polygon) GetBoundingBox() BoundingBox
- func (polygon *Polygon) GetID() int64
- func (polygon *Polygon) GetName() string
- func (polygon *Polygon) GetProperties() ShapeProperties
- func (polygon *Polygon) PointInside(point *Point) bool
- func (polygon *Polygon) PointInsideBoundingBox(point *Point) bool
- func (polygon *Polygon) PolygonInside(polygonCandidate *Polygon) bool
- func (polygon *Polygon) SetID(id int64)
- func (polygon *Polygon) SetProperties(shapeProperties ShapeProperties)
- func (polygon *Polygon) ShapeInside(shape Shape) bool
- func (polygon *Polygon) Type() string
- type Shape
- type ShapeProperties
- type ShapeStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Determinate ¶
Determinate calculates the determinate of a triangle
func IsClockwise ¶
IsClockwise checks if a polygon is clockwise or not
func IsConvex ¶
IsConvex checks if a triangle is convex (angle less than 180deg) based on its determinate
func LineIntersects ¶
LineIntersects checks if a line interesects another line
func PointInsidePolygon ¶
PointInsidePolygon checks if given point is present inside polygon by using precalculated triangles
func PointInsideTriangle ¶
PointInsideTriangle take a point and an triangle as ta tb tc Point2d
func PolygonArea ¶
PolygonArea calculates an area of a polygon
Types ¶
type BoundingBox ¶
BoundingBox contains information about the Shape bounding box
func CalculateBoundingBox ¶
func CalculateBoundingBox(points []Point) BoundingBox
CalculateBoundingBox calculates the bounding box based on given list of Point
func (*BoundingBox) BoundingBoxIntersects ¶
func (boundingBox *BoundingBox) BoundingBoxIntersects(intersectingBoundingBox *BoundingBox) bool
BoundingBoxIntersects checks if another BoundingBox intersects with the bounding box
func (*BoundingBox) ContainsPoint ¶
func (boundingBox *BoundingBox) ContainsPoint(p *Point) bool
ContainsPoint checks if a Point is within the bounding box
type Circle ¶
type Circle struct { ID int64 Name string Origo Point Radius float64 Properties ShapeProperties }
Circle contains information about circle
func (*Circle) CircleInside ¶
CircleInside checks whether a circle is inside the circle Expects the Radius to be normalized according to X,Y-grid
func (*Circle) GetBoundingBox ¶
func (circle *Circle) GetBoundingBox() BoundingBox
BoundingBox returns the circles BoundingBox
func (*Circle) GetProperties ¶
func (circle *Circle) GetProperties() ShapeProperties
GetProperties fetches the properties of the circle shape
func (*Circle) PointInside ¶
PointInside checks if a point is inside circle
func (*Circle) PointInsideBoundingBox ¶
PointInsideBoundingBox checks if a point is inside the circle
func (*Circle) PolygonInside ¶
PolygonInside checks whether a polygon is inside the circle
func (*Circle) SetProperties ¶
func (circle *Circle) SetProperties(shapeProperties ShapeProperties)
SetProperties sets the properties of the circle shape
func (*Circle) ShapeInside ¶
ShapeInside checks if a shape is inside the circle
type Point ¶
Point is a 2d point representation
func NewPointFromFloat ¶
NewPointFromFloat takes a list of float64 which represents X and Y and returns a single Point
func NewPointsFromFloat ¶
NewPointsFromFloat takes a list of float64 and returns a list of Points
func NormalizePoints ¶
NormalizePoints takes in an array of Point2d and removes redundant points from the list
func (*Point) DistanceTo ¶
DistanceTo calculates squared distance between two points.
func (*Point) DistanceToLine ¶
DistanceToLine Checks the point' distance towards a line by creating a 90 deg normal between p1 and the line
func (*Point) MinusPoint ¶
MinusPoint Subtracts points together and returns a new Point instance
type PointElement ¶
type PointElement struct {
Prev, Next *PointElement
Point Point
}
PointElement ...
type Polygon ¶
type Polygon struct { ID int64 Name string Description string AlphaShape []Point Triangles [][]Point BoundingBox BoundingBox Properties ShapeProperties }
Polygon contains static and processed information about a polygon
func NewPolygonFromPoints ¶
NewPolygonFromPoints Returns a new Polygon with BoundingBox and AlphaShape, without triangulating points
func (*Polygon) CircleInside ¶
CircleInside checks whether a circle is inside the polygon
func (*Polygon) GetBoundingBox ¶
func (polygon *Polygon) GetBoundingBox() BoundingBox
BoundingBox returns the polygons BoundingBox
func (*Polygon) GetProperties ¶
func (polygon *Polygon) GetProperties() ShapeProperties
GetProperties fetches the properties of the polygon shape
func (*Polygon) PointInside ¶
PointInside checks if a point is inside the given polygon
func (*Polygon) PointInsideBoundingBox ¶
PointInsideBoundingBox checks if a point is inside the given polygon
func (*Polygon) PolygonInside ¶
PolygonInside checks whether a polygon is inside the polygon
func (*Polygon) SetProperties ¶
func (polygon *Polygon) SetProperties(shapeProperties ShapeProperties)
SetProperties sets the properties of the polygon shape
func (*Polygon) ShapeInside ¶
ShapeInside checks if another shape is inside the given polygon
type Shape ¶
type Shape interface { GetName() string Type() string GetID() int64 SetID(int64) GetProperties() ShapeProperties SetProperties(shapeProperties ShapeProperties) GetBoundingBox() BoundingBox PointInside(point *Point) bool PointInsideBoundingBox(point *Point) bool ShapeInside(shape Shape) bool }
Shape is a interface which is an abstract way of checking if a point exists within it
func ShapeStoreToShapes ¶
func ShapeStoreToShapes(store *ShapeStore) []Shape
ShapeStoreToShapes deserializes a ShapeStore to a list of shapes
type ShapeProperties ¶
type ShapeProperties map[string]interface{}
ShapeProperties represents arbitrary string properties connected to a shape
func (*ShapeProperties) Scan ¶
func (shapeProperties *ShapeProperties) Scan(src interface{}) error
Scan implements SQL scan driver
type ShapeStore ¶
ShapeStore is a local struct to easier serialize/deserialize a list of shapes
func ShapesToShapeStore ¶
func ShapesToShapeStore(shapes []Shape) ShapeStore
ShapesToShapeStore creates a serializable ShapeStore from a list of shapes
func (*ShapeStore) Scan ¶
func (shapeStore *ShapeStore) Scan(src interface{}) error
Scan implements SQL scan driver