util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Infinity is the largest possible float64 value
	Infinity float64 = math.Inf(1)
	// AlmostZero is a value that is so small as to be almost zero
	AlmostZero float64 = 1e-8
)

Functions

func DegreesToRadians

func DegreesToRadians(degrees float64) float64

DegreesToRadians converts an angle in degrees to radians

func IsExecOwner added in v0.3.6

func IsExecOwner(mode os.FileMode) bool

IsExecOwner checks the file mode to see if it is executable by owner

Types

type Interval

type Interval struct {
	Min float64
	Max float64
}

Interval defines a range between Min and Max inclusive

var (
	// EmptyInterval contains nothing
	EmptyInterval Interval = Interval{math.Inf(1), math.Inf(-1)}
	// UniverseInterval contains everything
	UniverseInterval Interval = Interval{math.Inf(-1), math.Inf(1)}
)

func CombineIntervals

func CombineIntervals(a Interval, b Interval) Interval

CombineIntervals creates a new interval that is the union of the two given. If there is a gap between the intervals, that is included in the returned interval.

func (Interval) Add

func (i Interval) Add(displacement float64) Interval

Add returns a new interval that is increased with given value. The returned inteval has same size as original

func (Interval) Clamp

func (i Interval) Clamp(x float64) float64

Clamp returns the given value clamped to the interval

func (Interval) Contains

func (i Interval) Contains(x float64) bool

Contains checks if the interval contains a given value

func (Interval) Expand

func (i Interval) Expand(delta float64) Interval

Expand returns a new interval that is larger by given value delta. Delta is added equally to both sides of the interval

func (Interval) Size

func (i Interval) Size() float64

Size return the size of the interval

Jump to

Keyboard shortcuts

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