v2

package
v0.0.0-...-02f6ed8 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: MIT Imports: 1 Imported by: 38

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Vec

type Vec struct {
	X, Y float64
}

Vec is a 2D float64 vector.

func (Vec) Abs

func (a Vec) Abs() Vec

Abs takes the absolute value of each vector component.

func (Vec) Add

func (a Vec) Add(b Vec) Vec

Add adds two vectors. Returns a + b.

func (Vec) AddScalar

func (a Vec) AddScalar(b float64) Vec

AddScalar adds a scalar to each vector component.

func (Vec) Ceil

func (a Vec) Ceil() Vec

Ceil takes the ceiling value of each vector component.

func (Vec) Clamp

func (a Vec) Clamp(b, c Vec) Vec

Clamp clamps a vector between 2 other vectors.

func (Vec) Cross

func (a Vec) Cross(b Vec) float64

Cross returns the cross product of a and b.

func (Vec) Div

func (a Vec) Div(b Vec) Vec

Div divides two vectors by component.

func (Vec) DivScalar

func (a Vec) DivScalar(b float64) Vec

DivScalar divides each vector component by a scalar.

func (Vec) Dot

func (a Vec) Dot(b Vec) float64

Dot returns the dot product of a and b.

func (Vec) Equals

func (a Vec) Equals(b Vec, tolerance float64) bool

Equals returns true if a == b within the tolerance limit.

func (Vec) LTEZero

func (a Vec) LTEZero() bool

LTEZero returns true if any vector components are < 0.

func (Vec) LTZero

func (a Vec) LTZero() bool

LTZero returns true if any vector components are < 0.

func (Vec) Length

func (a Vec) Length() float64

Length returns the vector length.

func (Vec) Length2

func (a Vec) Length2() float64

Length2 returns the vector length * length.

func (Vec) Max

func (a Vec) Max(b Vec) Vec

Max return a vector with the maximum components of two vectors.

func (Vec) MaxComponent

func (a Vec) MaxComponent() float64

MaxComponent returns the maximum component of the vector.

func (Vec) Min

func (a Vec) Min(b Vec) Vec

Min return a vector with the minimum components of two vectors.

func (Vec) MinComponent

func (a Vec) MinComponent() float64

MinComponent returns the minimum component of the vector.

func (Vec) Mul

func (a Vec) Mul(b Vec) Vec

Mul multiplies two vectors by component.

func (Vec) MulScalar

func (a Vec) MulScalar(b float64) Vec

MulScalar multiplies each vector component by a scalar.

func (Vec) Neg

func (a Vec) Neg() Vec

Neg negates a vector.

func (Vec) Normalize

func (a Vec) Normalize() Vec

Normalize scales a vector to unit length.

func (Vec) Sub

func (a Vec) Sub(b Vec) Vec

Sub subtracts two vectors. Returns a - b.

func (Vec) SubScalar

func (a Vec) SubScalar(b float64) Vec

SubScalar subtracts a scalar from each vector component.

type VecSet

type VecSet []Vec

VecSet is a set of 2D float64 vectors.

func (VecSet) Max

func (a VecSet) Max() Vec

Max return the maximum components of a set of vectors.

func (VecSet) Min

func (a VecSet) Min() Vec

Min return the minimum components of a set of vectors.

type VecSetByX

type VecSetByX VecSet

VecSetByX sorts the vector set by X value

func (VecSetByX) Len

func (a VecSetByX) Len() int

func (VecSetByX) Less

func (a VecSetByX) Less(i, j int) bool

func (VecSetByX) Swap

func (a VecSetByX) Swap(i, j int)

type VecSetByXY

type VecSetByXY VecSet

VecSetByXY sorts the vector set by X then Y

func (VecSetByXY) Len

func (a VecSetByXY) Len() int

func (VecSetByXY) Less

func (a VecSetByXY) Less(i, j int) bool

func (VecSetByXY) Swap

func (a VecSetByXY) Swap(i, j int)

Jump to

Keyboard shortcuts

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