Documentation
¶
Index ¶
- func MaxX[T vector.Number](a, b Vector[T]) T
- func MaxY[T vector.Number](a, b Vector[T]) T
- func MinX[T vector.Number](a, b Vector[T]) T
- func MinY[T vector.Number](a, b Vector[T]) T
- type Array
- func (v2a Array[T]) Add(other Vector[T]) (out Array[T])
- func (v2a Array[T]) AddInplace(other Vector[T]) Array[T]
- func (v2a Array[T]) Bounds() (Vector[T], Vector[T])
- func (v2a Array[T]) Normalized() (out Array[T])
- func (v2a Array[T]) Scale(t float64) (out Array[T])
- func (v2a Array[T]) ScaleInplace(t float64) Array[T]
- func (v2a Array[T]) Sum() (sum Vector[T])
- type Float32
- type Float32Array
- type Float64
- type Float64Array
- type Int
- type Int16
- type Int16Array
- type Int32
- type Int32Array
- type Int64
- type Int64Array
- type Int8
- type Int8Array
- type IntArray
- type Serializable
- type Vector
- func Down[T vector.Number]() Vector[T]
- func Fill[T vector.Number](v T) Vector[T]
- func FromArray[T vector.Number](data []T) Vector[T]
- func Left[T vector.Number]() Vector[T]
- func Lerp[T vector.Number](a, b Vector[T], t float64) Vector[T]
- func LerpClamped[T vector.Number](a, b Vector[T], t float64) Vector[T]
- func Max[T vector.Number](a, b Vector[T]) Vector[T]
- func Midpoint[T vector.Number](a, b Vector[T]) Vector[T]
- func Min[T vector.Number](a, b Vector[T]) Vector[T]
- func New[T vector.Number](x T, y T) Vector[T]
- func One[T vector.Number]() Vector[T]
- func Rand(r *rand.Rand) Vector[float64]
- func Read[T vector.Number](in io.Reader, endian binary.ByteOrder) (v Vector[T], err error)
- func ReadFloat32(in io.Reader, endian binary.ByteOrder) (Vector[float32], error)
- func ReadFloat64(in io.Reader, endian binary.ByteOrder) (Vector[float64], error)
- func ReadInt16(in io.Reader, endian binary.ByteOrder) (Vector[int16], error)
- func ReadInt32(in io.Reader, endian binary.ByteOrder) (Vector[int32], error)
- func ReadInt64(in io.Reader, endian binary.ByteOrder) (Vector[int64], error)
- func ReadInt8(in io.Reader) (Vector[int8], error)
- func Right[T vector.Number]() Vector[T]
- func Up[T vector.Number]() Vector[T]
- func Zero[T vector.Number]() Vector[T]
- func (v Vector[T]) Abs() Vector[T]
- func (v Vector[T]) Add(other Vector[T]) Vector[T]
- func (v Vector[T]) Angle(other Vector[T]) float64
- func (v Vector[T]) Ceil() Vector[T]
- func (v Vector[T]) CeilToInt() Vector[int]
- func (v Vector[T]) Clamp(min, max T) Vector[T]
- func (v Vector[T]) Component(index int) T
- func (v Vector[T]) ContainsNaN() bool
- func (v Vector[T]) Distance(other Vector[T]) float64
- func (v Vector[T]) DistanceSquared(other Vector[T]) float64
- func (v Vector[T]) DivByConstant(t float64) Vector[T]
- func (v Vector[T]) Dot(other Vector[T]) float64
- func (v Vector[T]) Exp() Vector[T]
- func (v Vector[T]) Exp2() Vector[T]
- func (v Vector[T]) Expm1() Vector[T]
- func (v Vector[T]) Flip() Vector[T]
- func (v Vector[T]) FlipX() Vector[T]
- func (v Vector[T]) FlipY() Vector[T]
- func (v Vector[T]) Floor() Vector[T]
- func (v Vector[T]) FloorToInt() Vector[int]
- func (v Vector[T]) Format(format string) string
- func (v Vector[T]) Length() float64
- func (v Vector[T]) LengthSquared() float64
- func (v Vector[T]) Log() Vector[T]
- func (v Vector[T]) Log10() Vector[T]
- func (v Vector[T]) Log2() Vector[T]
- func (v Vector[T]) MarshalJSON() ([]byte, error)
- func (v Vector[T]) MaxComponent() T
- func (v Vector[T]) Midpoint(o Vector[T]) Vector[T]
- func (v Vector[T]) MinComponent() T
- func (v Vector[T]) MultByVector(o Vector[T]) Vector[T]
- func (v Vector[T]) NearZero() bool
- func (v Vector[T]) Normalized() Vector[T]
- func (v Vector[T]) Perpendicular() Vector[T]
- func (v Vector[T]) Round() Vector[T]
- func (v Vector[T]) RoundToInt() Vector[int]
- func (v Vector[T]) Scale(t float64) Vector[T]
- func (v Vector[T]) SetX(newX T) Vector[T]
- func (v Vector[T]) SetY(newY T) Vector[T]
- func (v Vector[T]) Sqrt() Vector[T]
- func (v Vector[T]) Sub(other Vector[T]) Vector[T]
- func (v Vector[T]) ToArr() []T
- func (v Vector[T]) ToFixedArr() [2]T
- func (v Vector[T]) ToFloat32() Vector[float32]
- func (v Vector[T]) ToFloat64() Vector[float64]
- func (v Vector[T]) ToInt() Vector[int]
- func (v Vector[T]) ToInt64() Vector[int64]
- func (v *Vector[T]) UnmarshalJSON(data []byte) error
- func (v Vector[T]) Values() (T, T)
- func (v Vector[T]) Write(out io.Writer, endian binary.ByteOrder) (err error)
- func (v Vector[T]) X() T
- func (v Vector[T]) Y() T
- func (v Vector[T]) YX() Vector[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Array ¶ added in v1.7.0
func (Array[T]) AddInplace ¶ added in v1.7.0
func (Array[T]) Bounds ¶ added in v1.7.0
Bounds returns the min and max points of an AABB encompassing
func (Array[T]) Normalized ¶ added in v1.7.0
func (Array[T]) ScaleInplace ¶ added in v1.7.0
type Float32Array ¶ added in v1.7.0
type Float64Array ¶ added in v1.7.0
type Int16Array ¶ added in v1.7.0
type Int32Array ¶ added in v1.7.0
type Int64Array ¶ added in v1.7.0
type Serializable ¶ added in v1.7.0
func (Serializable[T]) Immutable ¶ added in v1.7.0
func (m Serializable[T]) Immutable() Vector[T]
type Vector ¶
func FromArray ¶ added in v1.1.0
Builds a vector from the data found from the passed in array to the best of it's ability. If the length of the array is smaller than the vector itself, only those values will be used to build the vector, and the remaining vector components will remain the default value of the vector's data type (some version of 0).
func LerpClamped ¶ added in v1.8.0
func ReadFloat32 ¶ added in v1.7.0
func ReadFloat64 ¶ added in v1.7.0
func (Vector[T]) CeilToInt ¶
CeilToInt applies the ceil math operation to each component of the vector, and then casts it to a int
func (Vector[T]) ContainsNaN ¶ added in v1.3.0
func (Vector[T]) DistanceSquared ¶
func (Vector[T]) DivByConstant ¶
func (Vector[T]) Exp2 ¶ added in v1.6.0
Exp2 returns 2**x, the base-2 exponential for each component
func (Vector[T]) Expm1 ¶ added in v1.6.0
Expm1 returns e**x - 1, the base-e exponential for each component minus 1. It is more accurate than Exp(x) - 1 when the component is near zero
func (Vector[T]) FloorToInt ¶
FloorToInt applies the floor math operation to each component of the vector, and then casts it to a int
func (Vector[T]) LengthSquared ¶
func (Vector[T]) MarshalJSON ¶ added in v1.0.4
func (Vector[T]) MaxComponent ¶ added in v1.2.0
func (v Vector[T]) MaxComponent() T
func (Vector[T]) Midpoint ¶ added in v1.0.2
Midpoint returns the midpoint between this vector and the vector passed in.
func (Vector[T]) MinComponent ¶ added in v1.2.0
func (v Vector[T]) MinComponent() T
func (Vector[T]) MultByVector ¶
func (Vector[T]) Normalized ¶
func (Vector[T]) Perpendicular ¶
Perpendicular creates a vector perpendicular to the one passed in with the same magnitude
func (Vector[T]) Round ¶
Round takes each component of the vector and rounds it to the nearest whole number
func (Vector[T]) RoundToInt ¶
RoundToInt takes each component of the vector and rounds it to the nearest whole number, and then casts it to a int
func (Vector[T]) ToFixedArr ¶ added in v1.8.0
func (v Vector[T]) ToFixedArr() [2]T