mathutils

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 1 Imported by: 0

README

Go Reference

mathutils

Go package for mathematical utilities.

Documentation

Index

Constants

View Source
const (
	// Tau (τ) is two times pi , representing a full circle in radians. https://oeis.org/A019692
	Tau = 6.2831853071795864769252867665590057683943387987502

	// Phi (φ) is golden ratio. https://oeis.org/A001622/constant
	Phi = 1.6180339887498948482045868343656381177203091798058

	// Golden angle in radians (4-2*Phi)*Pi https://oeis.org/A131988/constant
	GoldenAngle = 2.3999632297286533222315555066336138531249990110581
)

Variables

This section is empty.

Functions

func Clamp

func Clamp(value, min, max float64) float64

Clamp returns value clamped to [min, max]

func Degrees

func Degrees(radians float64) float64

Degrees converts an angle measured in radians to its value in degrees.

func Fract

func Fract(x float64) float64

Fract returns the fractional part of x.

func Lerp

func Lerp(start, end, t float64) float64

Lerp performs linear interpolation between start and end based on t. t should be in the range [0, 1] where 0 returns start and 1 returns end. If t is outside this range, it will extrapolate.

func LinSpace

func LinSpace(min, max float64, n int) []float64

LinSpace returns a slice of float64 values spaced evenly between min and max.

If n is less than or equal to 1, it returns a slice with only the min value.

func MapRange

func MapRange(v, a, b, c, d float64) float64

MapRange maps a value v from one range [a, b] to another range [c, d].

func OppositeAngle

func OppositeAngle(angle float64) float64

OppositeAngle returns opposite angle. Unit is radians. It adds π to the angle and wraps it around if it exceeds 2π.

func Radians

func Radians(degrees float64) float64

Radians converts an angle measured in degrees to its value in radians.

func SinSpace

func SinSpace(amplitude float64, n int) []float64

SinSpace returns a slice of sine values spaced evenly between 0 and 2π.

It generates n points, one period of the sine wave, scaled by the given amplitude.

amplitude // Amplitude of the sine wave
n // Number of points

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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