vect

package
v0.0.0-...-ed1452e Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2016 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Vector_Zero = Vect{0, 0}
)

Functions

func Equals

func Equals(v1, v2 Vect) bool

compare two vectors by value.

Types

type Float

type Float float32

func Cross

func Cross(a, b Vect) Float

same as CrossVV.

func CrossVV

func CrossVV(a, b Vect) Float

cross product of two vectors.

func Dist

func Dist(v1, v2 Vect) Float

returns the distance between two vectors.

func DistSqr

func DistSqr(v1, v2 Vect) Float

returns the square distance between two vectors.

func Dot

func Dot(v1, v2 Vect) Float

dot product between two vectors.

func FAbs

func FAbs(a Float) Float

func FClamp

func FClamp(val, min, max Float) Float

func FMax

func FMax(a, b Float) Float

func FMin

func FMin(a, b Float) Float

func Length

func Length(v Vect) Float

returns the length of the vector.

func LengthSqr

func LengthSqr(v Vect) Float

returns the squared length of the vector.

type Vect

type Vect struct {
	X, Y Float
}

basic 2d vector.

func Add

func Add(v1, v2 Vect) Vect

adds the input vectors and returns the result.

func Clamp

func Clamp(v Vect, l Float) Vect

func CrossFV

func CrossFV(s Float, a Vect) Vect

cross product between a float64 and a vector. Not the same as CrossVD result = {-s * a.Y, s * a.X}

func CrossVF

func CrossVF(a Vect, s Float) Vect

cross product between a vector and a float64. result = {s * a.Y, -s * a.X}

func FromAngle

func FromAngle(angle Float) Vect

func Lerp

func Lerp(v1, v2 Vect, s Float) Vect

linear interpolation between two vectors by the given scalar

func Max

func Max(v1, v2 Vect) (out Vect)

returns a new vector with its x/y values set to the bigger one from the two input values. e.g. Min({2, 10}, {8, 3}) would return {2, 3}

func Min

func Min(v1, v2 Vect) (out Vect)
func Min(v1, v2 Vect) Vect {
	return INLI_Min(v1, v2)
}
func Max(v1, v2 Vect) Vect {
	return INLI_Max(v1, v2)
}

func Mult

func Mult(v1 Vect, s Float) Vect

multiplies a vector by a scalar and returns the result.

func Normalize

func Normalize(v Vect) Vect

returns the normalized input vector.

func Perp

func Perp(v Vect) Vect

Returns v rotated by 90 degrees

func Sub

func Sub(v1, v2 Vect) Vect

subtracts the input vectors and returns the result.

func (*Vect) Add

func (v1 *Vect) Add(v2 Vect)

adds v2 to the given vector.

func (Vect) Length

func (v Vect) Length() Float

returns the length of the vector.

func (Vect) LengthSqr

func (v Vect) LengthSqr() Float

returns the squared length of the vector.

func (Vect) MarshalJSON

func (v Vect) MarshalJSON() ([]byte, error)

func (*Vect) Mult

func (v *Vect) Mult(s Float)

multiplies the vector by the scalar.

func (*Vect) Normalize

func (v *Vect) Normalize()

normalizes the vector to a length of 1.

func (*Vect) Sub

func (v1 *Vect) Sub(v2 Vect)

subtracts v2 rom the given vector.

func (*Vect) UnmarshalJSON

func (v *Vect) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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