math

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const PrecisionThreshold = 1

Variables

This section is empty.

Functions

func Float32

func Float32(f float64) float32

Float32 converts to a float32 and logs a warning if there is loss of precision

func MustFloat32 added in v0.1.0

func MustFloat32(f float64) float32

MustFloat32 converts to a float32 and panics if there is loss of precision

Types

type CoordinateMapper

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

func NewRawCalcElement

func NewRawCalcElement(rect *Rect, scale float32) *CoordinateMapper

func (CoordinateMapper) DeScaleAt

func (c CoordinateMapper) DeScaleAt(i int, factor ScaleFactor) Transform

func (CoordinateMapper) ScaleAt

func (c CoordinateMapper) ScaleAt(i int, factor ScaleFactor) Transform

type Mapper

type Mapper interface {
	ScaleAt(i int, factor ScaleFactor) Transform
	DeScaleAt(i int, factor ScaleFactor) Transform
}

type MonotonicMapper

type MonotonicMapper struct {
	*Rect
	// contains filtered or unexported fields
}

MonotonicMapper scales values for x and y linearly to certain ranges and vice versa

func NewMonotonicMapper

func NewMonotonicMapper(scale float32) *MonotonicMapper

NewMonotonicMapper creates a new linearly scale calculation element

func (MonotonicMapper) DeScaleAt

func (l MonotonicMapper) DeScaleAt(i int, factor ScaleFactor) Transform

func (*MonotonicMapper) Max

func (l *MonotonicMapper) Max(max V) bool

func (*MonotonicMapper) Min

func (l *MonotonicMapper) Min(min V) bool

func (MonotonicMapper) ScaleAt

func (l MonotonicMapper) ScaleAt(i int, factor ScaleFactor) Transform

type Rect

type Rect struct {
	Min V
	Max V
}

type ScaleFactor

type ScaleFactor int
const (
	Normal ScaleFactor = iota + 1
	Inverse
)

type StackedMapper

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

func NewStackedMapper

func NewStackedMapper(stack ...Mapper) *StackedMapper

func (StackedMapper) DeScaleAt

func (s StackedMapper) DeScaleAt(i int, factor ScaleFactor) Transform

func (StackedMapper) ScaleAt

func (s StackedMapper) ScaleAt(i int, factor ScaleFactor) Transform

type Transform

type Transform func(x float32) float32

type V

type V []float32

Vector defines a point in n dimensional space

func NewV

func NewV(x ...float32) V

func (V) Dim

func (v V) Dim() int

Dim returns the dimensions of the point

func (V) Distance

func (v V) Distance(p V) float32

Distance calculates the distance of the point to another V

func (V) Norm

func (v V) Norm() float32

Norm returns the norm of the point e.g. the distance to the start of the coordinate system

type VoidCalcMapper

type VoidCalcMapper struct {
}

func (VoidCalcMapper) DeScaleAt

func (v VoidCalcMapper) DeScaleAt(i int, factor ScaleFactor) Transform

func (VoidCalcMapper) ScaleAt

func (v VoidCalcMapper) ScaleAt(i int, factor ScaleFactor) Transform

Jump to

Keyboard shortcuts

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