vector3

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 4 Imported by: 74

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array[T vector.Number] []Vector[T]

func (Array[T]) Add

func (v3a Array[T]) Add(other Vector[T]) (out Array[T])

func (Array[T]) Average

func (v3a Array[T]) Average(vectors []Vector[T]) Vector[float64]

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

func (Array[T]) Bounds

func (v3a Array[T]) Bounds() (Vector[T], Vector[T])

Bounds returns the min and max points of an AABB encompassing

func (Array[T]) Distance

func (v3a Array[T]) Distance() float64

func (Array[T]) DivByConstant

func (v3a Array[T]) DivByConstant(t float64) (out Array[T])

func (Array[T]) Modify

func (v3a Array[T]) Modify(f func(Vector[T]) Vector[T]) (out Array[T])

func (Array[T]) Normalized

func (v3a Array[T]) Normalized() (out Array[T])

func (Array[T]) Scale

func (v3a Array[T]) Scale(t float64) (out Array[T])

func (Array[T]) StandardDeviation added in v1.0.2

func (v3a Array[T]) StandardDeviation() (mean, deviation Vector[float64])

StandardDeviation calculates the population standard deviation on each component of the vector

func (Array[T]) Sum

func (v3a Array[T]) Sum() (sum Vector[T])

type Float32

type Float32 = Vector[float32]

type Float32Array

type Float32Array = Array[float32]

type Float64

type Float64 = Vector[float64]

type Float64Array

type Float64Array = Array[float64]

type Int

type Int = Vector[int]

type Int64

type Int64 = Vector[int64]

type Int64Array

type Int64Array = Array[int64]

type IntArray

type IntArray = Array[int]

type Vector

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

Vector contains 3 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 Backwards

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

Backwards is (0, 0, -1)

func Down

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

Down is (0, -1, 0)

func Forward

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

Forward is (0, 0, 1)

func Left

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

Left is (-1, 0, 0)

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 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, z 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 Rand

func Rand() Vector[float64]

Rand returns a vector with each component being a random value between [0.0, 1.0)

func RandInUnitSphere added in v1.0.2

func RandInUnitSphere() Vector[float64]

RandInUnitSphere returns a randomly sampled point in or on the unit sphere

func RandOnUnitSphere added in v1.0.2

func RandOnUnitSphere() Vector[float64]

RandOnUnitSphere returns a randomly sampled point on the unit sphere

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

Right is (1, 0, 0)

func Up

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

Up is (0, 1, 0)

func Zero

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

Zero is (0, 0, 0)

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 takes each component of our vector and adds them to the vector passed in, returning a resulting vector

func (Vector[T]) Angle

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

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

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

func (Vector[T]) Distance

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

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]

Floor applies the floor math operation to each component of the vector

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

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

MultByVector is component wise multiplication, also known as Hadamard product.

func (Vector[T]) Normalized

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

func (Vector[T]) Perpendicular

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

Perpendicular finds a vector that meets this vector at a right angle. https://stackoverflow.com/a/11132720/4974261

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]

SetX changes the x component of the vector

func (Vector[T]) SetZ

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

SetZ changes the x 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]) X

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

X returns the x component

func (Vector[T]) XY

func (v Vector[T]) XY() vector2.Vector[T]

XY returns vector2 with the x and y components

func (Vector[T]) XZ

func (v Vector[T]) XZ() vector2.Vector[T]

XZ returns vector2 with the x and z components

func (Vector[T]) Y

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

Y returns the y component

func (Vector[T]) YZ

func (v Vector[T]) YZ() vector2.Vector[T]

YZ returns vector2 with the y and z components

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