Documentation
¶
Index ¶
- type Vector
- func (v Vector) Add(v1 Vector) Vector
- func (v Vector) CrossProduct(v1 Vector) Vector
- func (v Vector) Dimension() int
- func (v Vector) DotProduct(v1 Vector) float64
- func (v Vector) Length() float64
- func (v Vector) ScalarMultiply(scalar float64) Vector
- func (v Vector) Subtract(v1 Vector) Vector
- func (v Vector) ToFloat64Array() []float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Vector ¶
type Vector struct {
// contains filtered or unexported fields
}
Vector described mathematical Vector. It stores []float64 array under the hood.
func NewVector ¶
NewVector creates new vector. It panics when there is less than 2 arguments provided.
func NewVectorFromFloat64Array ¶
NewVectorFromFloat64Array creates new vector from float64 slice. It panics when array length is less than 2.
func (Vector) Add ¶
Add adds v1 to current vector. It don't mutate current vector but return a new one. Also this function panics when vector dimensions are not the same.
func (Vector) CrossProduct ¶
CrossProduct do cross product of current vector with v1. It don't mutate current vector but return a new one. Also this function panics when vector dimension are not equal to 3.
func (Vector) DotProduct ¶
DotProduct do dot product of current vector with v1. It don't mutate current vector but return a new one. Also this function panics when vector dimensions are not the same.
func (Vector) ScalarMultiply ¶
ScalarMultiply multiply current vector with scalar. It don't mutate current vector but return a new one.
func (Vector) Subtract ¶
Subtract subtracts v1 from current vector. It don't mutate current vector but return a new one. Also this function panics when vector dimensions are not the same.
func (Vector) ToFloat64Array ¶
ToFloat64Array Convert vector to []float64 array.