vector4

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 3 Imported by: 12

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 Int64

type Int64 = Vector[int64]

type Vector

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

Vector contains 4 components

func Average

func Average[T vector.Number](vectors []Vector[T]) Vector[T]

Average sums all vector3's components together and divides each component by the number of vectors added

func Lerp

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

Lerp linearly interpolates between a and b by t

func Max

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

func Min

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

func New

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

New creates a new vector with corresponding 3 components

func One

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

One is (1, 1, 1)

func Zero

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

Zero is (0, 0, 0)

func (Vector[T]) Add

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

Add takes each component of our vector and adds them to the vector passed in, returning a resulting vector

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]) MarshalJSON

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

func (Vector[T]) Scale

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

func (Vector[T]) SetW

func (v Vector[T]) SetW(newW T) Vector[T]

SetW changes the w component of the vector

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]) SetZ

func (v Vector[T]) SetZ(newZ T) Vector[T]

SetZ changes the z component of the vector

func (Vector[T]) Sub

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

func (Vector[T]) ToFloat32

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

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

func (*Vector[T]) UnmarshalJSON

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

func (Vector[T]) W

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

W returns the w component

func (Vector[T]) X

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

X returns the x component

func (Vector[T]) Y

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

Y returns the y component

func (Vector[T]) Z

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

Z returns the z component

Jump to

Keyboard shortcuts

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