vec2

package
v0.0.0-...-548dba9 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const Deg2Rad = math.Pi / 180
View Source
const Rad2Deg = 180 / math.Pi

Variables

View Source
var Up = V2{X: 0, Y: -1}

Functions

func Dir

func Dir(v V2) float64

func Len

func Len(a V2) float64

Len return length of vector a

func LenSqr

func LenSqr(a V2) float64

LenSqr return square length of vector a

func RotateF

func RotateF(ang float64) func(V2) V2

Types

type V2

type V2 struct {
	X float64
	Y float64
}

float64 vector2

var BotLeft V2
var BotMid V2
var BotRight V2
var Center V2
var MidLeft V2
var MidRight V2
var TopLeft V2

Corners relative vectors

var TopMid V2
var TopRight V2
var ZV V2

zero vector

func Add

func Add(a, b V2) V2

Run returns vector equal to sum a+b

func AddMul

func AddMul(a, b V2, t float64) V2

AddMul returns a new vector = a+b*t

func ApplyOnTransform

func ApplyOnTransform(V, pos V2, angle float64) V2

ApplyOnTransform translate vector V moving by pos and turning by angle degrees

func InDir

func InDir(angle float64) V2

InDir return an ort vector in direction of angle degrees 0 angle is up (0,-1), positive direction is counterclockwise for world coords primary, use for screen coords with caution (because of Y axis)

func Mul

func Mul(a V2, t float64) V2

Mul returns vector a multiplied by t

func MulXY

func MulXY(a V2, b V2) V2

Mul returns vector a.x*b.x; a.y*b.y

func Normed

func Normed(a V2) V2

Normed returns normed copy of vector a with len = 1

func RandomInCircle

func RandomInCircle(R float64) V2

RandomInCircle returns a random vector in circle with radius R

func RandomOrt

func RandomOrt() V2

RandomOrt returns a random vector with len = 1

func Rotate

func Rotate(V V2, angle float64) V2

Rotate returns a new vector equal to V rotated by angle degrees

func Rotate90

func Rotate90(a V2) V2

Rotate returns a new vector equal to V rotated by 90 degrees

func Sub

func Sub(a, b V2) V2

Sub returns vector equal to a-b

func V

func V(x, y float64) V2

func (V2) Add

func (a V2) Add(b V2) V2

func (V2) AddMul

func (a V2) AddMul(b V2, t float64) V2

func (V2) ApplyOnTransform

func (v V2) ApplyOnTransform(pos V2, angle float64) V2

func (V2) Dir

func (a V2) Dir() float64

func (*V2) DoAddMul

func (a *V2) DoAddMul(b V2, t float64)

func (*V2) DoNorm

func (a *V2) DoNorm()

func (V2) Len

func (a V2) Len() float64

func (V2) LenSqr

func (a V2) LenSqr() float64

func (V2) Mul

func (a V2) Mul(t float64) V2

func (V2) MulXY

func (a V2) MulXY(b V2) V2

func (V2) Normed

func (a V2) Normed() V2

func (V2) Rotate

func (a V2) Rotate(angle float64) V2

func (V2) Rotate90

func (a V2) Rotate90() V2

func (V2) String

func (a V2) String() string

func (V2) Sub

func (a V2) Sub(b V2) V2

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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