vector

package
v0.0.0-...-4eb613b Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: MIT Imports: 3 Imported by: 0

README

Package vector

Simple vector (math kind) implementation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SimpleVector

type SimpleVector []float64

the Vector type is a slice of float64

func New

func New(elems ...float64) SimpleVector

func (SimpleVector) Add

func (v SimpleVector) Add(other Vector) Vector

Add returns the sum of two vectors

func (SimpleVector) Angle

func (v SimpleVector) Angle(other Vector) float64

Angle calculates the angle between two vectors (Rad)

func (SimpleVector) DotProd

func (v SimpleVector) DotProd(other Vector) (result float64)

DotProd calculates the dot product using sum of prudcts

func (SimpleVector) Eq

func (v SimpleVector) Eq(other Vector) bool

Eq compares vector magnitude and directions

func (SimpleVector) Eq2

func (v SimpleVector) Eq2(other Vector) bool

Eq compares each vector components for equality

func (SimpleVector) IsZero

func (v SimpleVector) IsZero() bool

Test for the zero vector

func (SimpleVector) Mag

func (v SimpleVector) Mag() (result float64)

Mag computes the magnitude of the vector

func (SimpleVector) Proj

func (v SimpleVector) Proj(base Vector) Vector

func (SimpleVector) Scale

func (v SimpleVector) Scale(scale float64)

Scale scales the vector

func (SimpleVector) String

func (v SimpleVector) String() string

String returns a string representation of the Vector

func (SimpleVector) Sub

func (v SimpleVector) Sub(other Vector) Vector

Sub returns the subtraction of a vector from another

func (SimpleVector) Unit

func (v SimpleVector) Unit() Vector

Unit returns the normalization of the vector

type Vector

type Vector interface {
	String() string
	Eq(other Vector) bool
	Add(other Vector) Vector
	Sub(other Vector) Vector
	Scale(factor float64)
	DotProd(other Vector) float64
	Angle(other Vector) float64
	Mag() float64
	Unit() Vector
}

Jump to

Keyboard shortcuts

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