geom

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Epsilon is the default value to compare is scalars are nearly equal
	// It can be as low as math.SmallestNonzeroFloat64
	Epsilon = 1e-16
)

Variables

View Source
var ZV = Vec{}

ZV = Vec{0,0}

Functions

func ScalarEqualsEpsilon

func ScalarEqualsEpsilon(a, b, epsilon float64) bool

Types

type Rect

type Rect struct {
	Min Vec
	Max Vec
}
var ZR Rect = Rect{}

ZR is a zero vector

func (Rect) AddVec

func (r Rect) AddVec(v Vec) Rect

func (Rect) At

func (r Rect) At(v Vec) Rect

func (Rect) ContainsVec

func (r Rect) ContainsVec(v Vec) bool

func (Rect) Equals

func (r Rect) Equals(other Rect) bool

func (Rect) Height

func (r Rect) Height() float64

Height returns the height

func (Rect) IsZero

func (r Rect) IsZero() bool

func (Rect) Size

func (r Rect) Size() Vec

Size returns the vector size (width, height)

func (Rect) SubVec

func (r Rect) SubVec(v Vec) Rect

func (Rect) Width

func (r Rect) Width() float64

Width returns the width

type Vec

type Vec struct {
	X float64
	Y float64
}

Vec is a 2d Vector

func (Vec) Add

func (v Vec) Add(other Vec) Vec

func (Vec) Angle

func (v Vec) Angle() float64

func (Vec) Applyed

func (v Vec) Applyed()

func (Vec) Clamp

func (v Vec) Clamp(min, max Vec) Vec

Clamp returns a new Vec between that is "min >= v <= max"

func (Vec) Cross

func (v Vec) Cross(other Vec) float64

Cross product

func (Vec) Dot

func (v Vec) Dot(other Vec) float64

Dot product

func (Vec) Equals

func (v Vec) Equals(other Vec) bool

Equals returns v == other

func (Vec) EqualsEpsilon

func (v Vec) EqualsEpsilon(other Vec) bool

func (Vec) EqualsEpsilon2

func (v Vec) EqualsEpsilon2(other Vec, epsilon float64) bool

func (Vec) IsZero

func (v Vec) IsZero() bool

IsZero returns true if both axes are 0

func (Vec) Magnitude

func (v Vec) Magnitude() float64

Magnitude = length

func (Vec) Mul

func (v Vec) Mul(other Vec) Vec

func (Vec) Normalized

func (v Vec) Normalized() Vec

Normalized normalizes a vector. Also known as direction, unit vector.

func (Vec) RectClamp

func (v Vec) RectClamp(r Rect) Vec

RectClamp returns a new Vec between that is "min >= v <= max"

func (Vec) Scaled

func (v Vec) Scaled(s float64) Vec

Scaled returns {v.X * s, v.Y * s}

func (Vec) ScaledXY

func (v Vec) ScaledXY(sx, sy float64) Vec

ScaledXY returns {v.X * sx, v.Y * sy}

func (Vec) Sub

func (v Vec) Sub(other Vec) Vec

Jump to

Keyboard shortcuts

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