bigxy

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package bigxy contains robust geographic functions on planar (xy) data. The calculations are performed using big.Float objects for maximum accuracy and robustness.

Note: it is required that all coordinates have the x and y ordinates in the 0 and 1 indexed locations in the geom.Coord array. Given that the coords can be of any size, all data other than x and y is ignored in these calculations.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Intersection

func Intersection(line1Start, line1End, line2Start, line2End geom.Coord) geom.Coord

Intersection computes the intersection point of the two lines using math.big.Float arithmetic. The lines are considered infinate in length. For example, (0,0), (1, 0) and (2, 1) (2, 2) will have intersection of (2, 0) Currently does not handle case of parallel lines.

Example
line1Start := geom.Coord{0, 1}
line1End := geom.Coord{0, -1}
line2Start := geom.Coord{-1, 0}
line2End := geom.Coord{1, 0}

intersection := bigxy.Intersection(line1Start, line1End, line2Start, line2End)

fmt.Println(intersection)
Output:

[0 0]

func OrientationIndex

func OrientationIndex(vectorOrigin, vectorEnd, point geom.Coord) orientation.Type

OrientationIndex returns the index of the direction of the point point relative to a vector specified by vectorOrigin-vectorEnd

vectorOrigin - the origin point of the vector vectorEnd - the final point of the vector point - the point to compute the direction to

Returns CounterClockwise if point is counter-clockwise (left) from vectorOrigin-vectorEnd Returns Clockwise if point is clockwise (right) from vectorOrigin-vectorEnd Returns Collinear if point is collinear with vectorOrigin-vectorEnd

Example
vectorOrigin := geom.Coord{10.0, 10.0}
vectorEnd := geom.Coord{20.0, 20.0}
target := geom.Coord{10.0, 20.0}

orientation := bigxy.OrientationIndex(vectorOrigin, vectorEnd, target)

fmt.Println(orientation)
Output:

CounterClockwise

Types

This section is empty.

Jump to

Keyboard shortcuts

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