vector

package
v0.14.10 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2022 License: Apache-2.0 Imports: 3 Imported by: 27

Documentation

Overview

Package vector defines an n-dimensional vector. The mutable / immutable syntax is based loosely off of the github.com/kvartborg/vector implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dot

func Dot(v V, u V) float64

func IsOrthogonal

func IsOrthogonal(v V, u V) bool

func Magnitude

func Magnitude(v V) float64

func SquaredMagnitude

func SquaredMagnitude(v V) float64

func Within

func Within(v V, u V) bool

func WithinEpsilon added in v0.10.0

func WithinEpsilon(v V, u V, e epsilon.E) bool

Types

type D

type D int
const (
	// AXIS_X is a common alias for the first dimension.
	AXIS_X D = iota

	// AXIS_Y is a common alias for the second dimension.
	AXIS_Y

	// AXIS_Z is a common alias for the third dimension.
	AXIS_Z

	// AXIS_W is a common alias for the fourth dimension.
	AXIS_W
)

type M added in v0.13.0

type M []float64

M is a mutable n-dimensional vector.

func (M) Add added in v0.13.0

func (v M) Add(u V)

func (M) Copy added in v0.13.0

func (v M) Copy(u V)

func (M) Dimension added in v0.13.0

func (v M) Dimension() D

func (M) Scale added in v0.13.0

func (v M) Scale(c float64)

func (M) SetX added in v0.13.0

func (v M) SetX(i D, c float64)

func (M) Sub added in v0.13.0

func (v M) Sub(u V)

func (M) Unit added in v0.13.0

func (v M) Unit()

func (M) V added in v0.13.0

func (v M) V() V

func (M) X added in v0.13.0

func (v M) X(i D) float64

func (M) Zero added in v0.13.0

func (v M) Zero()

type V

type V []float64

V is an immutable n-length vector.

func Add

func Add(v V, u V) V

func New

func New(xs ...float64) *V

func Scale

func Scale(c float64, v V) V

func Sub

func Sub(v V, u V) V

func Unit

func Unit(v V) V

func (V) Dimension

func (v V) Dimension() D

Dimension returns the dimension of the vector.

func (V) M added in v0.13.0

func (v V) M() M

func (V) X

func (v V) X(i D) float64

Jump to

Keyboard shortcuts

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