Documentation ¶
Index ¶
- func AngleFromOrigin(v Vector) (float64, error)
- func AngleToIntercept(pos Vector, dir𝚹 float64, target Vector) (float64, error)
- func DotProduct(v Vector, u Vector) (float64, error)
- func Magnitude(v Vector) (float64, error)
- func RelativeAngle(v Vector, u Vector) (float64, error)
- func TranslatePositionToSector2D(ed float64, n int, v Vector) (int, int)
- func UnitAngle(angle float64) float64
- func VectorDistance(v Vector, u Vector) (float64, error)
- type Vector
- func CrossProduct(v Vector, u Vector) (Vector, error)
- func FuzzifyVector(v Vector, ε float64) (Vector, error)
- func Normalise(v Vector) (Vector, error)
- func RandVector(bounds []float64) Vector
- func UnitVector(angle float64) Vector
- func VecAddition(v Vector, u Vector) (Vector, error)
- func VecScalarMultiply(v Vector, scalar float64) (Vector, error)
- type VectorEquality
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AngleFromOrigin ¶
AngleFromOrigin calculates the angle of a given vector from the origin relative to the x-axis of 𝐄 (the model environment)
func AngleToIntercept ¶
AngleToIntercept calculates the change in angle required from the current heading to point in direction of target.
func DotProduct ¶
DotProduct returns the sum of the product of elements of two i-dimension vectors, u and v, as a scalar s.t. v•v = (v₁u₁ + v₂u₂ + ⠂⠂⠂ + vᵢ₋₁uᵢ₋₁ + vᵢuᵢ)
func Magnitude ¶
Magnitude does the classic calculation for length of a vector (or, distance from origin)
func RelativeAngle ¶
RelativeAngle – does what it says on the box. Only implemented in 2D currently, or, as a comparitive rotation between two points on a single plane.
func TranslatePositionToSector2D ¶
TranslatePositionToSector2D : translates the co-ordinates of a 2D vector to sector indices location (2D Version)
Types ¶
type Vector ¶
type Vector []float64
Vector : Any sized dimension representation of a point of vector space.
func CrossProduct ¶
CrossProduct produces a new Vector orthogonal to both v and u. Only supported for 3D vectors.
func FuzzifyVector ¶
FuzzifyVector will return a a 'fuzzy', slightly randomised version of v, at a random variance in range (-ε, +ε) offset from each existing element of v.
func Normalise ¶
Normalise returns the normalised Vector of v – it's what you might call a direction vector, as opposed to a position vector. NOTE: this is not the same as a 'norm'/'normal' which is the vector orthogonal to a plane or surface.
func RandVector ¶
RandVector will give a random vector within boundaries the axes of len(bounds) dimensions
func UnitVector ¶
UnitVector returns a direction unit vector for an axis pair.
func VecAddition ¶
VecAddition – performs vector addition between two vectors, v and u s.t. v + u = [v₁+u₁ , v₂+u₂, ⠂⠂⠂ , vᵢ₋₁+uᵢ₋₁ , vᵢ+uᵢ ] on an i-th dimension vector.
func VecScalarMultiply ¶
VecScalarMultiply - performs scalar multiplication on a vector v, s.t. scalar * v = [scalar*e1, scalar*e2, scalar*e3]
func (Vector) Equal ¶
func (v Vector) Equal(u VectorEquality) bool
Equal method implements an Equality comparison between vectors.
type VectorEquality ¶
type VectorEquality interface {
Equal(VectorEquality) bool
}
VectorEquality – Trying to implement a quick version of checking for Vector equality