minmax

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxFloat32 float32 = 3.402823466e+38
	MinFloat32 float32 = 1.175494351e-38
)

Variables

This section is empty.

Functions

This section is empty.

Types

type F32

type F32 struct {
	Min float32
	Max float32
	// contains filtered or unexported fields
}

F32 represents a min / max range for float32 values. Supports clipping, renormalizing, etc

func (*F32) ClipNormVal

func (mr *F32) ClipNormVal(val float32) float32

ClipNormVal clips then normalizes given value within 0-1 Note: a NaN will remain as a NaN

func (*F32) ClipVal

func (mr *F32) ClipVal(val float32) float32

ClipVal clips given value within Min / Max range Note: a NaN will remain as a NaN

func (*F32) FitInRange

func (mr *F32) FitInRange(oth F32) bool

FitInRange adjusts our Min, Max to fit within those of other F32 returns true if we had to adjust to fit.

func (*F32) FitValInRange

func (mr *F32) FitValInRange(val float32) bool

FitValInRange adjusts our Min, Max to fit given value within Min, Max range returns true if we had to adjust to fit.

func (*F32) InRange

func (mr *F32) InRange(val float32) bool

InRange tests whether value is within the range (>= Min and <= Max)

func (*F32) IsHigh

func (mr *F32) IsHigh(val float32) bool

IsHigh tests whether value is higher than the maximum

func (*F32) IsLow

func (mr *F32) IsLow(val float32) bool

IsLow tests whether value is lower than the minimum

func (*F32) IsValid

func (mr *F32) IsValid() bool

IsValid returns true if Min <= Max

func (*F32) Midpoint

func (mr *F32) Midpoint() float32

Midpoint returns point halfway between Min and Max

func (*F32) NormVal

func (mr *F32) NormVal(val float32) float32

NormVal normalizes value to 0-1 unit range relative to current Min / Max range Clips the value within Min-Max range first.

func (*F32) ProjVal

func (mr *F32) ProjVal(val float32) float32

ProjVal projects a 0-1 normalized unit value into current Min / Max range (inverse of NormVal)

func (*F32) Range

func (mr *F32) Range() float32

Range returns Max - Min

func (*F32) Scale

func (mr *F32) Scale() float32

Scale returns 1 / Range -- if Range = 0 then returns 0

func (*F32) Set

func (mr *F32) Set(min, max float32)

Set sets the min and max values

func (*F32) SetInfinity

func (mr *F32) SetInfinity()

SetInfinity sets the Min to +MaxFloat, Max to -MaxFloat -- suitable for iteratively calling Fit*InRange

Jump to

Keyboard shortcuts

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