mathutils

package
v0.0.80 Latest Latest
Warning

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

Go to latest
Published: May 10, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Pi    = 3.14159265358979323846264338327950288419716939937510582097494459 // 3.14159 returns 3.141592653589793238462643383279502
	TwoPi = 2 * Pi                                                           // returns 6.283185307179586476925286766559005

)

Variables

This section is empty.

Functions

func AbsInt

func AbsInt(value int) int

AbsInt returns the absolute value of an int.

func CirclePoint

func CirclePoint(cx, cy int, radius, thetaRadians float64) (x, y int)

CirclePoint returns the absolute config.Alignment of a circle diameter point given by the radius and the theta.

func DegreesAdd

func DegreesAdd(baseDegrees, deltaDegrees float64) float64

DegreesAdd adds a delta to a base in radians.

func DegreesToCompass

func DegreesToCompass(deg float64) float64

DegreesToCompass returns the degree value in compass / clock orientation.

func DegreesToRadians

func DegreesToRadians(degrees float64) float64

DegreesToRadians returns degrees as radians.

func GetRoundToForDelta

func GetRoundToForDelta(delta float64) float64

GetRoundToForDelta returns a `roundTo` value for a given delta.

func MaxInt

func MaxInt(values ...int) (max int)

MaxInt returns the maximum int.

func Mean

func Mean(values ...float64) float64

Mean returns the mean of a set of values

func MeanInt

func MeanInt(values ...int) int

MeanInt returns the mean of a set of integer values.

func MinInt

func MinInt(values ...int) (min int)

MinInt returns the minimum int.

func MinMax

func MinMax(values ...float64) (min, max float64)

MinMax returns the minimum and maximum of a given set of values.

func NormalizeToProportions

func NormalizeToProportions(values ...float64) []float64

NormalizeToProportions convierte un conjunto de números en sus proporciones relativas en el intervalo [0,1]. Por ejemplo: 4,3,2,1 => 0.4, 0.3, 0.2, 0.1 Los valores se redondean para evitar errores de punto flotante, pero la suma puede no ser exactamente 1.0.

func PercentDifference

func PercentDifference(v1, v2 float64) float64

PercentDifference computes the percentage difference between two values. The formula is (v2-v1)/v1.

func PercentToRadians

func PercentToRadians(pct float64) float64

PercentToRadians converts a normalized value (0,1) to radians.

func RadianAdd

func RadianAdd(base, delta float64) float64

RadianAdd adds a delta to a base in radians.

func RadiansToDegrees

func RadiansToDegrees(value float64) float64

RadiansToDegrees translates a radian value to a degree value.

func RotateCoordinate

func RotateCoordinate(cx, cy, x, y int, thetaRadians float64) (rx, ry int)

RotateCoordinate rotates a coordinate around a given center by a theta in radians.

func Round added in v0.0.67

func Round(value float64) int

Round rounds a float64 to the nearest int. eg: 1.5 -> 2, 1.4 -> 1, -1.5 -> -2, -1.4 -> -1

func RoundDown

func RoundDown(value, roundTo float64) float64

RoundDown rounds down to a given roundTo value.

func RoundPlaces

func RoundPlaces(input float64, places int) (rounded float64)

RoundPlaces rounds an input to a given places.

func RoundToInt

func RoundToInt(value float64) int

RoundToInt convierte un float64 a int redondeando al entero más cercano

func RoundUp

func RoundUp(value, roundTo float64) float64

RoundUp rounds up to a given roundTo value.

func Sum

func Sum(values ...float64) float64

Sum sums a set of values.

func SumInt

func SumInt(values ...int) int

SumInt sums a set of values.

Types

This section is empty.

Jump to

Keyboard shortcuts

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