mathlib

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package mathlib implements some functions for math calculation.

Index

Constants

View Source
const R = 6367000

R 地球半径,单位米

Variables

This section is empty.

Functions

func Abs

func Abs[T Numeric](n T) T

Abs get absolute value of given value

func Average

func Average[T Numeric](numbers ...T) T

Average return average value of numbers.

func BDToGCJ

func BDToGCJ(lat, lng float64) (float64, float64)

BDToGCJ 百度坐标系 (BD-09) 与 火星坐标系 (GCJ-02)的转换

func Ceil

func Ceil[T Numeric](a, b T) T

func Distance

func Distance(lngA, latA, lngB, latB float64) float64

func DistanceI

func DistanceI[T constraints.Integer](lngA, latA, lngB, latB int64) T

func Floor

func Floor[T Numeric](a, b T) T

func InRange

func InRange[T constraints.Ordered](val, min, max T) bool

InRange check if val in int/float range [min, max]

func Max

func Max[T constraints.Ordered](i T, n ...T) T

func Min

func Min[T constraints.Ordered](i T, n ...T) T

func OutRange

func OutRange[T constraints.Ordered](val, min, max T) bool

OutRange check if val not in int/float range [min, max]

func Percent

func Percent[T Numeric](a, b T) float64

func Round

func Round[T Numeric](a, b T) T

func SafePage

func SafePage[T constraints.Integer](i T) T

func Sum

func Sum[T Numeric](n []T, missing T) T

func ToString added in v1.0.6

func ToString[T constraints.Integer](input T) string

ToString convert a integer to string with base 10

Types

type Numeric

type Numeric interface {
	constraints.Integer | constraints.Float
}

Jump to

Keyboard shortcuts

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