package geoimport ()typeRoute []*Pointfunc ( Route) () float64 { := 0.for := 0; < len()-1; ++ { += EuclideanDistance( [].X, [].Y, [+1].X, [+1].Y, ) }return}// return the point at _distance_ along the route, and the index of the segment it's onfunc ( Route) ( float64) (*Point, int) { := var , *Pointvarfloat64for := 0; < len()-1; ++ { , = [], [+1] = EuclideanDistance(.X, .Y, .X, .Y)if <= { := / // point t% of the way between curr and nextreturn .Interpolate(, ), } -= }// distance > length, so continue with last segment // Note: distance < 0 handled above with first segmentreturn .Interpolate(, 1+/), len() - 2}func ( Route) () (, *Point) { := math.Inf(1) := math.Inf(1) := math.Inf(-1) := math.Inf(-1)for , := range {if .X < { = .X }if .X > { = .X }if .Y < { = .Y }if .Y > { = .Y } }returnNewPoint(, ), NewPoint(, )}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.