Documentation
¶
Index ¶
- func Compare[T mathex.SignedNumber](a, b Vector[T]) int
- func Greater[T mathex.SignedNumber](a, b Vector[T]) bool
- func GreaterEq[T mathex.SignedNumber](a, b Vector[T]) bool
- func Less[T mathex.SignedNumber](a, b Vector[T]) bool
- func LessEq[T mathex.SignedNumber](a, b Vector[T]) bool
- func MaxX[T mathex.SignedNumber](a, b Vector[T]) T
- func MaxY[T mathex.SignedNumber](a, b Vector[T]) T
- func MinX[T mathex.SignedNumber](a, b Vector[T]) T
- func MinY[T mathex.SignedNumber](a, b Vector[T]) T
- type Float32
- type Float64
- type Int
- type Int16
- type Int32
- type Int64
- type Int8
- type Vector
- func Down[T mathex.SignedNumber]() Vector[T]
- func Fill[T mathex.SignedNumber](v T) Vector[T]
- func FromArray[T mathex.SignedNumber](data []T) Vector[T]
- func Left[T mathex.SignedNumber]() Vector[T]
- func Lerp[T mathex.SignedNumber](t float32, a, b Vector[T]) Vector[T]
- func Max[T mathex.SignedNumber](a, b Vector[T]) Vector[T]
- func Midpoint[T mathex.SignedNumber](a, b Vector[T]) Vector[T]
- func Min[T mathex.SignedNumber](a, b Vector[T]) Vector[T]
- func New[T mathex.SignedNumber](x T, y T) Vector[T]
- func NewT[T mathex.SignedNumber, XT, YT mathex.Number](x XT, y YT) Vector[T]
- func One[T mathex.SignedNumber]() Vector[T]
- func Rand(r *rand.Rand) Vector[float64]
- func Read[T mathex.SignedNumber](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 mathex.SignedNumber]() Vector[T]
- func To[T, OT mathex.SignedNumber](v Vector[OT]) Vector[T]
- func Up[T mathex.SignedNumber]() Vector[T]
- func Zero[T mathex.SignedNumber]() Vector[T]
- func (v Vector[T]) Abs() Vector[T]
- func (v Vector[T]) Add(other Vector[T]) Vector[T]
- func (v Vector[T]) AddX(dX T) Vector[T]
- func (v Vector[T]) AddXY(x, y T) Vector[T]
- func (v Vector[T]) AddY(dY T) Vector[T]
- func (v Vector[T]) Angle(other Vector[T]) float64
- func (v Vector[T]) AngleF(other Vector[T]) float32
- func (v Vector[T]) Axis(i Axis) T
- func (v Vector[T]) Ceil() Vector[T]
- func (v Vector[T]) CeilToInt() Vector[int]
- func (v Vector[T]) Clamp(vmin, vmax T) Vector[T]
- func (v Vector[T]) Clamp0V(vmax Vector[T]) Vector[T]
- func (v Vector[T]) ClampV(vmin, vmax Vector[T]) Vector[T]
- func (v Vector[T]) ContainsNaN() bool
- func (v Vector[T]) Cross(other Vector[T]) T
- func (v Vector[T]) CrossV(value T) Vector[T]
- func (v Vector[T]) Distance(other Vector[T]) float64
- func (v Vector[T]) DistanceSquared(other Vector[T]) T
- func (v Vector[T]) DivByConstant(t float64) Vector[T]
- func (v Vector[T]) DivByVector(o Vector[T]) Vector[T]
- func (v Vector[T]) Dot(other Vector[T]) T
- func (v Vector[T]) EnumRegion(w, h T, step ...T) iter.Seq[Vector[T]]
- func (v Vector[T]) EnumRegionAround(w, h T, step ...T) iter.Seq[Vector[T]]
- 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]) Inv() Float64
- func (v Vector[T]) InvF() Float32
- func (v Vector[T]) IsZero() bool
- func (v Vector[T]) Length() float64
- func (v Vector[T]) LengthF() float32
- func (v Vector[T]) LengthSquared() T
- 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]) NearZeroF(epsilon float32) bool
- func (v Vector[T]) Negated() Vector[T]
- func (v Vector[T]) Normalize(a Vector[T]) Float64
- func (v Vector[T]) NormalizeF(a Vector[T]) Float32
- func (v Vector[T]) Normalized() Vector[T]
- func (v Vector[T]) Perpendicular() Vector[T]
- func (v Vector[T]) Pivot(anchor Vector[T], wh Vector[T]) Vector[T]
- func (v Vector[T]) Product() T
- func (v Vector[T]) Project(normal Vector[T]) Vector[T]
- func (v Vector[T]) Reciprocal() Vector[float64]
- func (v Vector[T]) ReciprocalF() Vector[float32]
- func (v Vector[T]) Reflect(normal Vector[T]) Vector[T]
- func (v Vector[T]) Reject(normal Vector[T]) Vector[T]
- func (v Vector[T]) Round() Vector[T]
- func (v Vector[T]) RoundToInt() Vector[int]
- func (v Vector[T]) RoundToVector(scale Vector[T]) Vector[T]
- func (v Vector[T]) Scale(t float64) Vector[T]
- func (v Vector[T]) ScaleByVector(o Float64) Vector[T]
- func (v Vector[T]) ScaleByVectorF(o Float32) Vector[T]
- func (v Vector[T]) ScaleByVectorI(o Int) Vector[T]
- func (v Vector[T]) ScaleByXY(x, y float64) Vector[T]
- func (v Vector[T]) ScaleByXYF(x, y float32) Vector[T]
- func (v Vector[T]) ScaleByXYI(x, y int) Vector[T]
- func (v Vector[T]) ScaleF(t float32) Vector[T]
- func (v Vector[T]) SetAxis(i Axis, a T) Vector[T]
- func (v Vector[T]) SetX(X T) Vector[T]
- func (v Vector[T]) SetY(Y T) Vector[T]
- func (v Vector[T]) SignI() Int
- func (v Vector[T]) Sqrt() Vector[T]
- func (v Vector[T]) String() string
- func (v Vector[T]) Sub(other Vector[T]) Vector[T]
- func (v Vector[T]) SubXY(x, y T) Vector[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]) ToInt16() Vector[int16]
- func (v Vector[T]) ToInt32() Vector[int32]
- func (v Vector[T]) ToInt64() Vector[int64]
- func (v Vector[T]) ToInt8() Vector[int8]
- func (v Vector[T]) ToNpot() Vector[T]
- 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]) YX() Vector[T]
- func (v Vector[T]) ZeroF(epsilon float32) Float32
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaxX ¶
func MaxX[T mathex.SignedNumber](a, b Vector[T]) T
func MaxY ¶
func MaxY[T mathex.SignedNumber](a, b Vector[T]) T
func MinX ¶
func MinX[T mathex.SignedNumber](a, b Vector[T]) T
func MinY ¶
func MinY[T mathex.SignedNumber](a, b Vector[T]) T
Types ¶
type Float32 ¶
func NewFloat32 ¶
type Float64 ¶
func NewFloat64 ¶
type Vector ¶
type Vector[T mathex.SignedNumber] struct { X T Y T }
func Down ¶
func Down[T mathex.SignedNumber]() Vector[T]
func Fill ¶
func Fill[T mathex.SignedNumber](v T) Vector[T]
Fill creates a vector where each component is equal to v
func FromArray ¶
func FromArray[T mathex.SignedNumber](data []T) Vector[T]
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 Left ¶
func Left[T mathex.SignedNumber]() Vector[T]
func Lerp ¶
func Lerp[T mathex.SignedNumber](t float32, a, b Vector[T]) Vector[T]
Lerp linearly interpolates between a and b by t
func New ¶
func New[T mathex.SignedNumber](x T, y T) Vector[T]
func One ¶
func One[T mathex.SignedNumber]() Vector[T]
func Right ¶
func Right[T mathex.SignedNumber]() Vector[T]
func Up ¶
func Up[T mathex.SignedNumber]() Vector[T]
func Zero ¶
func Zero[T mathex.SignedNumber]() Vector[T]
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 ¶
func (Vector[T]) DistanceSquared ¶
func (Vector[T]) DivByConstant ¶
func (Vector[T]) DivByVector ¶
func (Vector[T]) EnumRegionAround ¶
func (Vector[T]) Expm1 ¶
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 (v Vector[T]) LengthSquared() T
func (Vector[T]) MarshalJSON ¶
func (Vector[T]) MaxComponent ¶
func (v Vector[T]) MaxComponent() T
func (Vector[T]) Midpoint ¶
Midpoint returns the midpoint between this vector and the vector passed in.
func (Vector[T]) MinComponent ¶
func (v Vector[T]) MinComponent() T
func (Vector[T]) MultByVector ¶
func (Vector[T]) NormalizeF ¶
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]) Reciprocal ¶
func (Vector[T]) ReciprocalF ¶
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]) RoundToVector ¶
RoundToInt takes each component of the vector and rounds it to the nearest whole number, and then casts it to a int