maths

package
v0.4.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package math contins generic math functions that we need for doing transforms. this package will augment the go math library.

Index

Constants

View Source
const (
	WebMercator = tegola.WebMercator
	WGS84       = tegola.WGS84
	Deg2Rad     = math.Pi / 180
	Rad2Deg     = 180 / math.Pi
	PiDiv2      = math.Pi / 2.0
	PiDiv4      = math.Pi / 4.0
)

Variables

This section is empty.

Functions

func AreaOfPolygon

func AreaOfPolygon(p tegola.Polygon) (area float64)

AreaOfPolygon will calculate the Area of a polygon using the surveyor's formula (https://en.wikipedia.org/wiki/Shoelace_formula)

func AreaOfPolygonLineString added in v0.4.0

func AreaOfPolygonLineString(line tegola.LineString) (area float64)

func DegToRad

func DegToRad(deg float64) float64

func DistOfLine added in v0.4.0

func DistOfLine(l tegola.LineString) (dist float64)

DistOfLine will calculate the Manhattan distance of a line.

func RadToDeg

func RadToDeg(rad float64) float64

Types

type Line added in v0.4.0

type Line [2]Pt

func (Line) Clamp added in v0.4.0

func (l Line) Clamp(pt Pt) (p Pt)

Clamp will return a point that is on the line based on pt. It will do this by restricting each of the coordiantes to the line.

func (Line) DistanceFromPoint added in v0.4.0

func (l Line) DistanceFromPoint(pt Pt) float64

DistanceFromPoint will return the perpendicular distance from the point.

func (Line) ExInBetween added in v0.4.0

func (l Line) ExInBetween(pt Pt) bool

func (Line) InBetween added in v0.4.0

func (l Line) InBetween(pt Pt) bool

InBetween will check to see if the given point lies the line provided inbetween the endpoints.

func (Line) SlopeIntercept added in v0.4.0

func (l Line) SlopeIntercept() (m, b float64, defined bool)

SlopeIntercept will find the slop (if there is one) and the intercept of the two provided lines. If there isn't a slope because the lines are verticle, the slopeDefined will be false.

type Pointer added in v0.4.0

type Pointer interface {
	Point() Pt
}

type Pt added in v0.4.0

type Pt struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

Pt describes a 2d Point.

func DouglasPeucker added in v0.4.0

func DouglasPeucker(points []Pt, tolerence float64) []Pt

func Intersect added in v0.4.0

func Intersect(l1, l2 Line) (pt Pt, ok bool)

Intersect find the intersection point (x,y) between two lines if there is one. Ok will be true if it found an intersection point, and false if it did not.

func (Pt) Coords added in v0.4.0

func (pt Pt) Coords() []float64

func (Pt) Delta added in v0.4.0

func (pt Pt) Delta(pt2 Pt) (d Pt)

func (*Pt) GoString added in v0.4.0

func (pt *Pt) GoString() string

func (Pt) IsEqual added in v0.4.0

func (pt Pt) IsEqual(pt2 Pt) bool

func (Pt) String added in v0.4.0

func (pt Pt) String() string

func (Pt) Truncate added in v0.4.0

func (pt Pt) Truncate() Pt

func (Pt) XCoord added in v0.4.0

func (pt Pt) XCoord() float64

func (Pt) YCoord added in v0.4.0

func (pt Pt) YCoord() float64

type WindingOrder added in v0.4.0

type WindingOrder uint8

WindingOrder the direction the line strings.

const (
	Clockwise WindingOrder
	CounterClockwise
)

func WindingOrderOf added in v0.4.0

func WindingOrderOf(sub []float64) WindingOrder

func WindingOrderOfLine added in v0.4.0

func WindingOrderOfLine(l tegola.LineString) WindingOrder

func (WindingOrder) IsClockwise added in v0.4.0

func (w WindingOrder) IsClockwise() bool

func (WindingOrder) IsCounterClockwise added in v0.4.0

func (w WindingOrder) IsCounterClockwise() bool

func (WindingOrder) Not added in v0.4.0

func (w WindingOrder) Not() WindingOrder

func (WindingOrder) String added in v0.4.0

func (w WindingOrder) String() string

Directories

Path Synopsis
Package webmercator does the translation to and from WebMercator and WGS84 Gotten from: http://wiki.openstreetmap.org/wiki/Mercator#C.23
Package webmercator does the translation to and from WebMercator and WGS84 Gotten from: http://wiki.openstreetmap.org/wiki/Mercator#C.23

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL