fx

package
v0.0.0-...-45de639 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: Unlicense Imports: 5 Imported by: 0

Documentation

Overview

Package fx adds support for working with 16.16 fixed-point numbers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExprVarMap

type ExprVarMap map[string]T

ExprVarMap is used to pass named values to a fixed-point expression.

type T

type T struct {
	// contains filtered or unexported fields
}

T represents a 16.16 fixed-point number.

func Abs

func Abs(f T) T

Abs returns the absolute value of a fixed-point number.

func Acos

func Acos(a T) T

Acos calculates the approximate arc-cosine an angle specified in radians.

func Add

func Add(lhs, rhs T) T

Add returns the result of adding two fixed-point numbers.

func Addf

func Addf(lhs T, rhs float32) T

Addf returns the result of adding a fixed-point number with a float32.

func Addi

func Addi(lhs T, rhs int) T

Addi returns the result of adding a fixed-point number with an integer.

func Asin

func Asin(a T) T

Asin calculates the approximate arc-sine an angle specified in radians.

func Ceil

func Ceil(f T) T

Ceil returns the smaller integer value >= x.

func Clamp

func Clamp(f, min, max T) T

Clamp returns a fixed-point number within the range of min and max.

func Cos

func Cos(a T) T

Cos calculates the approximate cosine of an angle specified in radians.

func Div

func Div(lhs, rhs T) T

Div returns the result of dividing two fixed-point numbers.

func Divf

func Divf(lhs T, rhs float32) T

Divf returns the result of dividing a fixed-point number and a float32.

func Divi

func Divi(lhs T, rhs int) T

Divi returns the result of dividing a fixed-point number and an integer.

func Expr

func Expr(expr string) T

Expr parses a Go math expression and returns its fixed-point value. It will panic when given an invalid expression. Note: Only constant numeric values are valid in the given expression. To use named values, call ExprVars instead. Note: This method is much slower than calling standard functions and should only be used to cache calculations.

func ExprVars

func ExprVars(expr string, values ExprVarMap) T

ExprVars parses a Go math expression and returns its fixed-point value. Unlike Expr, ExprVars allows a list of variables to be passed from the outside context.

func F

func F[FT ~float32 | ~float64](f FT) T

F converts a float into a fixed-point number.

func Floor

func Floor(f T) T

Floor returns the larger integer value <= x.

func I

func I(i int) T

I converts an integer into a fixed-point number.

func InvSqrt

func InvSqrt(x T) T

InvSqrt calculates the approximate inverse square root of x.

func Max

func Max(a, b T) T

Max returns the larger of two fixed-point numbers.

func MaximumValue

func MaximumValue() T

MaximumValue returns the highest value representable by T (approximately 32767.00)

func Min

func Min(a, b T) T

Min returns the smaller of two fixed-point numbers.

func MinimumValue

func MinimumValue() T

MinimumValue returns the lowest value representable by T (approximately -32768.00)

func Mod

func Mod(lhs, rhs T) T

func Mul

func Mul(lhs, rhs T) T

Mul returns the result of multiplying two fixed-point numbers.

func Mulf

func Mulf(lhs T, rhs float32) T

Mulf returns the result of multiplying a fixed-point number and a float32.

func Muli

func Muli(lhs T, rhs int) T

Muli returns the result of multiplying a fixed-point number and an integer.

func NegOne

func NegOne() T

NegOne returns the fixed-point value of -1.

func Negate

func Negate(f T) T

Negate returns the negative value of f.

func One

func One() T

One returns the fixed-point value of 1.

func Pi

func Pi() T

Pi returns the approximate value of pi.

func Pi2

func Pi2() T

Pi2 returns the approximate value of pi/2.

func Round

func Round(f T) T

Round returns f rounded up to the nearest integer.

func Sin

func Sin(a T) T

Sin calculates the approximate sine of an angle specified in radians.

func Sqrt

func Sqrt(x T) T

Sqrt calculates the approximate square root of x.

func Square

func Square(f T) T

func Sub

func Sub(lhs, rhs T) T

Sub returns the result of subtracting two fixed-point numbers.

func Subf

func Subf(lhs T, rhs float32) T

Subf returns the result of subtracting a fixed-point number and a float32.

func Subi

func Subi(lhs T, rhs int) T

Subi returns the result of subtracting a fixed-point number and an integer.

func Tan

func Tan(a T) T

Tan calculates the approximate tangent of an angle specified in radians.

func Tau

func Tau() T

Tau returns the approximate value of 2*pi.

func Zero

func Zero() T

Zero returns the fixed-point value of 0.

func (T) Eq

func (l T) Eq(r T) bool

Eq returns true if two fixed-pointer numbers are equal.

func (T) Float

func (f T) Float() float32

Float converts a fixed-point number into a float32.

func (T) Float64

func (f T) Float64() float64

Float64 converts a fixed-point number into a float64.

func (T) Gt

func (l T) Gt(r T) bool

Gt returns true if l is greater than r.

func (T) GtEq

func (l T) GtEq(r T) bool

GtEq returns true if l is greater than or equal to r.

func (T) Int

func (f T) Int() int

Int converts a fixed-point number into an integer.

func (T) Lt

func (l T) Lt(r T) bool

Lt returns true if l is less than r.

func (T) LtEq

func (l T) LtEq(r T) bool

LtEq returns true if l is less than or equal to r.

func (T) Raw

func (f T) Raw() int32

Raw returns the internal representation of f.

func (T) String

func (f T) String() string

Jump to

Keyboard shortcuts

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