gmath

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package gmath includes useful math funcs for games, graphics, and GUIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clamp

func Clamp[N num.Real](val, min, max N) N

Clamp will return the value clamped between min and max, inclusive.

func Lerp

func Lerp[N num.Real, F num.Float](a, b N, t F) N

Lerp linearly interpolates between a and b using t. t is clamped between 0.0 and 1.0. eg, when t is 0.0, this returns a. When t is 1.0 this returns b. When t is 0.5 this returns the midpoint between a and b.

NOTE: Lerping unsigned values requires extra care - there may be unexpected results when a > b. Suggest ordering [a, b] such that a <= b, or casting to a float prior to calling this function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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