vector2

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: MIT Imports: 4 Imported by: 37

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Float32

type Float32 = Vector[float32]

type Float64

type Float64 = Vector[float64]

type Int

type Int = Vector[int]

type Int16 added in v1.2.0

type Int16 = Vector[int16]

type Int32 added in v1.2.0

type Int32 = Vector[int32]

type Int64

type Int64 = Vector[int64]

type Int8 added in v1.2.0

type Int8 = Vector[int8]

type Vector

type Vector[T vector.Number] struct {
	// contains filtered or unexported fields
}

func Down

func Down[T vector.Number]() Vector[T]

func Fill added in v1.1.0

func Fill[T vector.Number](v T) Vector[T]

Fill creates a vector where each component is equal to v

func FromArray added in v1.1.0

func FromArray[T vector.Number](data []T) Vector[T]

Builds a vector from the data found from the passed in array to the best of it's ability. If the length of the array is smaller than the vector itself, only those values will be used to build the vector, and the remaining vector components will remain the default value of the vector's data type (some version of 0).

func Left

func Left[T vector.Number]() Vector[T]

func Lerp added in v1.0.2

func Lerp[T vector.Number](a, b Vector[T], t float64) Vector[T]

Lerp linearly interpolates between a and b by t

func Max added in v1.0.2

func Max[T vector.Number](a, b Vector[T]) Vector[T]

func Midpoint added in v1.1.0

func Midpoint[T vector.Number](a, b Vector[T]) Vector[T]

func Min added in v1.0.2

func Min[T vector.Number](a, b Vector[T]) Vector[T]

func New

func New[T vector.Number](x T, y T) Vector[T]

func One

func One[T vector.Number]() Vector[T]

func Rand

func Rand(r *rand.Rand) Vector[float64]
func Right[T vector.Number]() Vector[T]

func Up

func Up[T vector.Number]() Vector[T]

func Zero

func Zero[T vector.Number]() Vector[T]

func (Vector[T]) Abs

func (v Vector[T]) Abs() Vector[T]

Abs applies the Abs math operation to each component of the vector

func (Vector[T]) Add

func (v Vector[T]) Add(other Vector[T]) Vector[T]

Add returns a vector that is the result of two vectors added together

func (Vector[T]) Ceil

func (v Vector[T]) Ceil() Vector[T]

Ceil applies the ceil math operation to each component of the vector

func (Vector[T]) CeilToInt

func (v Vector[T]) CeilToInt() Vector[int]

CeilToInt applies the ceil math operation to each component of the vector, and then casts it to a int

func (Vector[T]) Clamp added in v1.0.3

func (v Vector[T]) Clamp(min, max T) Vector[T]

func (Vector[T]) Distance

func (v Vector[T]) Distance(other Vector[T]) float64

Distance is the euclidean distance between two points

func (Vector[T]) DistanceSquared

func (v Vector[T]) DistanceSquared(other Vector[T]) float64

func (Vector[T]) DivByConstant

func (v Vector[T]) DivByConstant(t float64) Vector[T]

func (Vector[T]) Dot

func (v Vector[T]) Dot(other Vector[T]) float64

func (Vector[T]) Floor

func (v Vector[T]) Floor() Vector[T]

func (Vector[T]) FloorToInt

func (v Vector[T]) FloorToInt() Vector[int]

FloorToInt applies the floor math operation to each component of the vector, and then casts it to a int

func (Vector[T]) Length

func (v Vector[T]) Length() float64

func (Vector[T]) LengthSquared

func (v Vector[T]) LengthSquared() float64

func (Vector[T]) MarshalJSON added in v1.0.4

func (v Vector[T]) MarshalJSON() ([]byte, error)

func (Vector[T]) MaxComponent added in v1.2.0

func (v Vector[T]) MaxComponent() T

func (Vector[T]) Midpoint added in v1.0.2

func (v Vector[T]) Midpoint(o Vector[T]) Vector[T]

Midpoint returns the midpoint between this vector and the vector passed in.

func (Vector[T]) MinComponent added in v1.2.0

func (v Vector[T]) MinComponent() T

func (Vector[T]) MultByVector

func (v Vector[T]) MultByVector(o Vector[T]) Vector[T]

func (Vector[T]) NearZero added in v1.0.3

func (v Vector[T]) NearZero() bool

func (Vector[T]) Normalized

func (v Vector[T]) Normalized() Vector[T]

func (Vector[T]) Perpendicular

func (v Vector[T]) Perpendicular() Vector[T]

Perpendicular creates a vector perpendicular to the one passed in with the same magnitude

func (Vector[T]) Round

func (v Vector[T]) Round() Vector[T]

Round takes each component of the vector and rounds it to the nearest whole number

func (Vector[T]) RoundToInt

func (v Vector[T]) RoundToInt() Vector[int]

RoundToInt takes each component of the vector and rounds it to the nearest whole number, and then casts it to a int

func (Vector[T]) Scale

func (v Vector[T]) Scale(t float64) Vector[T]

func (Vector[T]) SetX

func (v Vector[T]) SetX(newX T) Vector[T]

SetX changes the x component of the vector

func (Vector[T]) SetY

func (v Vector[T]) SetY(newY T) Vector[T]

SetY changes the y component of the vector

func (Vector[T]) Sqrt added in v1.0.3

func (v Vector[T]) Sqrt() Vector[T]

Sqrt applies the math.Sqrt to each component of the vector

func (Vector[T]) Sub

func (v Vector[T]) Sub(other Vector[T]) Vector[T]

func (Vector[T]) ToFloat32 added in v1.0.2

func (v Vector[T]) ToFloat32() Vector[float32]

func (Vector[T]) ToFloat64

func (v Vector[T]) ToFloat64() Vector[float64]

func (Vector[T]) ToInt

func (v Vector[T]) ToInt() Vector[int]

func (Vector[T]) ToInt64 added in v1.0.2

func (v Vector[T]) ToInt64() Vector[int64]

func (*Vector[T]) UnmarshalJSON added in v1.0.4

func (v *Vector[T]) UnmarshalJSON(data []byte) error

func (Vector[T]) X

func (v Vector[T]) X() T

func (Vector[T]) Y

func (v Vector[T]) Y() T

func (Vector[T]) YX added in v1.2.0

func (v Vector[T]) YX() Vector[T]

Jump to

Keyboard shortcuts

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