various

package
v0.0.0-...-17a2a95 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: Apache-2.0 Imports: 7 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Zero2 = [2]float64{0, 0}

Functions

func Add2

func Add2(a, b [2]float64) [2]float64

Add2 returns the sum of two vectors.

func AddVecToLatLong

func AddVecToLatLong(lat, lon float64, vec [2]float64) (float64, float64)

Adds a vector to a latitude and longitude in degrees. The vector's x coordinate is modified by the cosine of the latitude to account for the fact that the distance between degrees of longitude decreases as the latitude increases.

func Angle2

func Angle2(a, b [2]float64) float64

Angle2 returns the angle between two vectors.

func CalcBearingRad

func CalcBearingRad(lat1, lon1, lat2, lon2 float64) float64

calcBearing calculates the bearing between two lat/long pairs.

func CalcHeightInTriangle

func CalcHeightInTriangle(p1, p2, p3, p [2]float64, z1, z2, z3 float64) float64

CalcHeightInTriangle calculates the height of a point in a triangle.

func CalcVecFromLatLong

func CalcVecFromLatLong(lat1, lon1, lat2, lon2 float64) [2]float64

CalcVecFromLatLong calculates the vector between two lat/long pairs.

func ConvToArray

func ConvToArray(in map[int]bool) []int

ConvToArray converts a map of ints to bools into a slice of ints.

func ConvToMap

func ConvToMap(in []int) map[int]bool

ConvToMap converts a slice of ints into a map of ints to bools.

func ConvToVec3

func ConvToVec3(xyz []float64) vectors.Vec3

ConvToVec3 converts a float slice containing 3 values into a vectors.Vec3.

func Cross2

func Cross2(a, b [2]float64) float64

Cross2 returns the cross product of two vectors.

func CrossArc

func CrossArc(lat1, lon1, lat2, lon2, lat3, lon3 float64) float64

CrossArc calculates the shortest distance between an arc (defined by p1 and p2) and a third point, p3. The input is expected in degrees. See: https://stackoverflow.com/questions/32771458/distance-from-lat-lng-point-to-minor-arc-segment

func DegToRad

func DegToRad(deg float64) float64

func Dist2

func Dist2(a, b [2]float64) float64

Dist2 returns the eucledian distance between two points.

func DistToSegment2

func DistToSegment2(v, w, p [2]float64) float64

DistToSegment2 returns the distance between a point p and a line segment defined by the points v and w.

func Dot2

func Dot2(a, b [2]float64) float64

Dot2 returns the dot product of two vectors.

func GetCentroidOfTriangle

func GetCentroidOfTriangle(a, b, c []float64) vectors.Vec3

GetCentroidOfTriangle returns the centroid of a triangle defined by the xyz coordinates a, b, c as a vectors.Vec3.

func Haversine

func Haversine(lat1, lon1, lat2, lon2 float64) float64

Haversine returns the great arc distance between two lat/long pairs.

func HeronsTriArea

func HeronsTriArea(a, b, c float64) float64

HeronsTriArea returns the area of a triangle given the three sides. See: https://www.mathopenref.com/heronsformula.html

func InitFloatSlice

func InitFloatSlice(size int) []float64

InitFloatSlice returns a slice of floats of the given size, initialized to -1.

func InitRegionSlice

func InitRegionSlice(size int) []int

InitRegionSlice returns a slice of ints of the given size, initialized to -1.

func InitSlice

func InitSlice[V utils.Number](size int) []V

InitSlice returns a slice of the given type of the given size, initialized to -1.

func InitTimeSlice

func InitTimeSlice(size int) []int64

InitTimeSlice returns a slice of int64s of the given size, initialized to -1.

func IsInIntList

func IsInIntList(l []int, i int) bool

IsInIntList returns true if the given int is in the given slice.

func IsPointInTriangle

func IsPointInTriangle(p1, p2, p3, p [2]float64) bool

IsPointInTriangle returns true if the point (xp, yp) is inside the triangle or on the edge of the triangle.

func KickOffChunkWorkers

func KickOffChunkWorkers(totalItems int, fn func(start, end int))

func LatLonFromVec3

func LatLonFromVec3(position vectors.Vec3, sphereRadius float64) (float64, float64)

LatLonFromVec3 converts a vectors.Vec3 to latitude and longitude. See: https://rbrundritt.wordpress.com/2008/10/14/conversion-between-spherical-and-cartesian-coordinates-systems/

func LatLonToCartesian

func LatLonToCartesian(latDeg, lonDeg float64) []float64

LatLonToCartesian converts latitude and longitude to x, y, z coordinates. See: https://rbrundritt.wordpress.com/2008/10/14/conversion-between-spherical-and-cartesian-coordinates-systems/

func Len2

func Len2(a [2]float64) float64

Len2 returns the length of the given vector.

func MergeIndexSegments

func MergeIndexSegments(segs [][2]int) [][]int

MergeIndexSegments matches up the ends of the segments (region pairs) and returns a slice containing all continuous, connected segments as sequence of connected regions.

func Normal2

func Normal2(v [2]float64) [2]float64

Normal2 returns the normalized vector of the given vector.

func Normalize2

func Normalize2(a [2]float64) [2]float64

Normalize2 returns the normalized vector of the given vector.

func RadToDeg

func RadToDeg(rad float64) float64

func Read2FloatSlice

func Read2FloatSlice(r io.Reader) ([][2]float64, error)

func ReadFloatSlice

func ReadFloatSlice(r io.Reader) ([]float64, error)

func ReadIntSlice

func ReadIntSlice(r io.Reader) ([]int, error)

func ReadMapIntBool

func ReadMapIntBool(r io.Reader) (map[int]bool, error)

func ReadMapIntFloat64

func ReadMapIntFloat64(r io.Reader) (map[int]float64, error)

func ReadMapIntInt

func ReadMapIntInt(r io.Reader) (map[int]int, error)

func Rotate2

func Rotate2(v [2]float64, angle float64) [2]float64

Rotate2 returns the rotated vector of the given vector.

func RoundToDecimals

func RoundToDecimals(v, d float64) float64

RoundToDecimals rounds the given float to the given number of decimals.

func Scale2

func Scale2(v [2]float64, s float64) [2]float64

Scale2 returns the scaled vector of the given vector.

func SetMagnitude2

func SetMagnitude2(v [2]float64, mag float64) [2]float64

func Sub2

func Sub2(a, b [2]float64) [2]float64

Sub2 returns the difference of two vectors.

func VectorToLatLong

func VectorToLatLong(vec [2]float64) (float64, float64)

I'm not sure if this is correct, but it seems to work.

func Write2FloatSlice

func Write2FloatSlice(w io.Writer, s [][2]float64) error

func WriteFloatSlice

func WriteFloatSlice(w io.Writer, s []float64) error

func WriteIntSlice

func WriteIntSlice(w io.Writer, s []int) error

func WriteMapIntBool

func WriteMapIntBool(w io.Writer, m map[int]bool) error

func WriteMapIntFloat64

func WriteMapIntFloat64(w io.Writer, m map[int]float64) error

func WriteMapIntInt

func WriteMapIntInt(w io.Writer, m map[int]int) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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