vector

package
v0.0.0-...-ddc071b Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: GPL-3.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cast

func Cast(a [3]float32) []float32

func CastFixed

func CastFixed(a Vec) [3]float32

func Copy

func Copy(store Vec, reference Vec)

Copy copies the reference vector into the store vec @MUTATES store and updates with copies of reference Vec Copy will attempt to copy even if vectors are different sizes

func DimEq

func DimEq(a Vec, b Vec) bool

DimEq(a, b) checks if two vectors have equal sizes

func Dist

func Dist(a Vec, b Vec) float32

Dist returns the distance between two vectors B-A/L by non mutating ops

func Dot

func Dot(a Vec, b Vec) float32

---TRIPLE CHECK THIS LOL Dot computes the dot product as in a.Dot(b) where the resulting value should return a scalar value representative of the ||a|||b||Cos() theta angle between two non-parallel vectors

func Eql

func Eql(a Vec, b Vec) bool

Eql Checks if two vectors are equal by lazy comparison If the user of this API wishes to check whether two vectors are within EPSILON of Eachother please use the Equal() function denoted at the top of this library

func Equal

func Equal(a Vec, b Vec) bool

Equal checks if two vectors are logically equal their subtraction and the resulting mag() of that vector gives a value less than EPSIOLN if two vectors are equal

func Mag

func Mag(v Vec) float32

Mag (v Vec) returns the magnitued of any vector > length size 0. Operation does not mutate vector state

func SinDot

func SinDot(a Vec, b Vec) float32

Types

type Vec

type Vec []float32

Vector slice array

func Add

func Add(a Vec, b Vec) Vec

Add sums each element index against the other vector a stores the result in a new vector @DELEGATES

func Cross

func Cross(a Vec, b Vec) Vec

Cross cross multpiplies A x B. Be aware that cross multplication is not commutative Cross is a non-mutating function @NONMUTATE and represents a Vector that is perpendicular To the plane created from two vectors when those vectors are 3 Vecs satisfying that property In general cross products produce an orthonormal vector between two vectors. For now only works on 3 Vecs and 3 Like 4 Vecs =

func LogVecError

func LogVecError(vec Vec, op string) Vec

func Neg

func Neg(a Vec) Vec

Negates the current vector by -1.0. But stores the result in a new value @NONMUTATE function see NegV for mutating

func Norm

func Norm(a Vec) Vec

Returns normalized vector A.i / Mag() function is non mutating and delegates result to a new vector

func Proj

func Proj(a Vec, n Vec) Vec

Proj projects a vector onto the N Vec a -> N. Functino is non mutating and delegates The output vector to a new vector. Error log checking handled by internal dot product call. N typically may be considered to be a Normal vector that A will be projected onto.

func ProjPlane

func ProjPlane(a Vec, n Vec) Vec

ProjPlane projects a vector on to the the plane defined by A & N. Functino is non mutating and delegates The output vector to a new vector. Error log checking handled by internal dot product call. N typically may be considered to be a Normal vector that A will be projected onto.

func RaySphereIntersection

func RaySphereIntersection(r0 Vec, d0 Vec, c Vec, r float32) (Vec, bool)

RaySphereIntersection Calculates the Intersection Points for a Ray and Sphere r0 is ray origin , d0 direction , c is the sphere origin, r is the radius

func Refl

func Refl(v Vec, n Vec) Vec

Refl reflects the v vector about N this function is non mutating and delegates vector result into a new vector

func Scale

func Scale(a Vec, k float32) Vec

Scl scales vector kX this function does not mutate the current vector

func ScaleVar

func ScaleVar(a Vec, b Vec) Vec

Scl scales vector kX this function does not mutate the current vector

func Sub

func Sub(b Vec, a Vec) Vec

Sub subtracts the vector b minus a utilizing the same add functions above. @NONMUTATE

func Tan

func Tan(a Vec, n Vec) Vec

Tan returns the tangent vector from the given normal profile - this may Just be a plane projection of A onto the the plane p....defined by projection of A onto N when A is not parallel to N.

func Vec2

func Vec2() Vec

Vec2 creates new vector as 2-Length slice

func Vec3

func Vec3() Vec

Vec3 creates new vector as 3-Length slice

func Vec4

func Vec4() Vec

Vec4 creates new vector as 3-Length slice

func VecN

func VecN(n int) Vec

func (Vec) Add

func (a Vec) Add(b Vec) Vec

Add sums each element index against the other vector a stores the result in a new vector @DELEGATES

func (Vec) Clamp

func (v Vec) Clamp(min float32, max float32)

Clamps Vector between min and max values for each entry @mutate_selector / #utility / #mgl / #vector / #math

func (Vec) Copy

func (store Vec) Copy(reference Vec)

Copy copies the reference vector into the store vec @MUTATES store and updates with copies of reference Vec Copy will attempt to copy even if vectors are different sizes

func (Vec) Dim

func (v Vec) Dim() int

Vec Dim returns vector dimensions

func (Vec) DimEq

func (a Vec) DimEq(b Vec) bool

DimEq(a, b) checks if two vectors have equal sizes

func (Vec) Dist

func (a Vec) Dist(b Vec) float32

Dist returns the distance between two vectors B-A/L by non mutating ops

func (Vec) Eql

func (a Vec) Eql(b Vec) bool

Eql Checks if two vectors are equal by lazy comparison If the user of this API wishes to check whether two vectors are within EPSILON of Eachother please use the Equal() function denoted at the top of this library

func (Vec) Equal

func (a Vec) Equal(b Vec) bool

Equal checks if two vectors are logically equal their subtraction and the resulting mag() of that vector gives a value less than EPSIOLN if two vectors are equal

func (Vec) Mag

func (v Vec) Mag() float32

Mag (v Vec) returns the magnitued of any vector > length size 0. Operation does not mutate vector state @DELEGATES

func (Vec) Mul

func (b Vec) Mul(a Vec) Vec

func (Vec) Neg

func (a Vec) Neg() Vec

Negates the current vector by -1.0. But stores the result in a new value @NONMUTATE function see NegV for mutating

func (Vec) NegV

func (a Vec) NegV() Vec

Negates the current vector by -1.0. But stores the result in a new value @NONMUTATE function see NegV for mutating

func (Vec) Norm

func (a Vec) Norm() Vec

Returns normalized vector A.i / Mag() function is non mutating and delegates result to a new vector - fails quietly with 0 vector

func (Vec) Proj

func (a Vec) Proj(n Vec) Vec

Proj projects a vector onto the N Vec a -> N. Functino is non mutating and delegates The output vector to a new vector. Error log checking handled by internal dot product call. N typically may be considered to be a Normal vector that A will be projected onto.

func (Vec) ProjPlane

func (a Vec) ProjPlane(n Vec) Vec

ProjPlane projects a vector on to the the plane defined by A & N. Functino is non mutating and delegates The output vector to a new vector. Error log checking handled by internal dot product call. N typically may be considered to be a Normal vector that A will be projected onto.

func (Vec) Refl

func (v Vec) Refl(n Vec) Vec

Refl reflects the v vector about N this function is non mutating and delegates vector result into a new vector

func (Vec) Scale

func (a Vec) Scale(k float32) Vec

Scale scales vector kX this function does not mutate the current vector @NONMUTATE function Scale

func (Vec) Sub

func (b Vec) Sub(a Vec) Vec

Sub subtracts the vector b minus a utilizing the same add functions above. @NONMUTATE

func (Vec) Tan

func (a Vec) Tan(n Vec) Vec

func (Vec) ToString

func (v Vec) ToString() string

Jump to

Keyboard shortcuts

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