Documentation
¶
Index ¶
- func AngleBetween[T Number](v1, v2 Vector2[T]) float64
- func Cross[T1, T2 Number](v Vector2[T1], other Vector2[T2]) T1
- func Distance[T1, T2 Number](v Vector2[T1], other Vector2[T2]) T1
- func DistanceSquared[T1, T2 Number](v Vector2[T1], other Vector2[T2]) T1
- func DistanceToLine[T Number](a, b, p Vector2[T]) T
- func Dot[T1, T2 Number](v Vector2[T1], other Vector2[T2]) T1
- func IsBetweenInclusive[T1, T2, T3 Number](p Vector2[T1], left Vector2[T2], right Vector2[T3]) bool
- func SideOfPoint[T Number](a, b, p Vector2[T]) T
- type Float
- type Number
- type SignedInteger
- type Vector2
- func Add[T1, T2 Number](v Vector2[T1], other ...Vector2[T2]) Vector2[T1]
- func Div[T1, T2 Number](v Vector2[T1], other ...Vector2[T2]) Vector2[T1]
- func Lerp[T1, T2, T Number](v Vector2[T1], other Vector2[T2], t T) Vector2[T1]
- func Max[T1, T2 Number](v Vector2[T1], other ...Vector2[T2]) Vector2[T1]
- func Min[T1, T2 Number](v Vector2[T1], other ...Vector2[T2]) Vector2[T1]
- func Mul[T1, T2 Number](v Vector2[T1], other ...Vector2[T2]) Vector2[T1]
- func NewFloat32[T Number](x, y T) Vector2[float32]
- func NewFloat64[T Number](x, y T) Vector2[float64]
- func NewFloat64Polar[T1, T2 Number](angle T1, radius T2) Vector2[float64]
- func NewFloat64Random[T Number](minValue, maxValue T) Vector2[float64]
- func NewInt[T Number](x, y T) Vector2[int]
- func Reflect[T1, T2 Number](v Vector2[T1], other Vector2[T2]) Vector2[T1]
- func Sub[T1, T2 Number](v Vector2[T1], other ...Vector2[T2]) Vector2[T1]
- func (v Vector2[T]) Abs() Vector2[T]
- func (v Vector2[T]) AddScalar(scalar T) Vector2[T]
- func (v Vector2[T]) AddScalars(x, y T) Vector2[T]
- func (v Vector2[T]) Angle() float64
- func (v Vector2[T]) AsFloat32() Vector2[float32]
- func (v Vector2[T]) AsFloat64() Vector2[float64]
- func (v Vector2[T]) Ceil() Vector2[T]
- func (v Vector2[T]) Clamp(low, high Vector2[T]) Vector2[T]
- func (v Vector2[T]) Components() (x, y T)
- func (v Vector2[T]) Div(other Vector2[T]) Vector2[T]
- func (v Vector2[T]) DivScalar(scalar T) Vector2[T]
- func (v Vector2[T]) DivScalars(x, y T) Vector2[T]
- func (v Vector2[T]) Equals(other Vector2[T]) bool
- func (v Vector2[T]) Floor() Vector2[T]
- func (v Vector2[T]) InvertY() Vector2[T]
- func (v Vector2[T]) IsZero() bool
- func (v Vector2[T]) Magnitude() T
- func (v Vector2[T]) Minus(other Vector2[T]) Vector2[T]
- func (v Vector2[T]) Mul(other Vector2[T]) Vector2[T]
- func (v Vector2[T]) MulScalar(scalar T) Vector2[T]
- func (v Vector2[T]) MulScalars(x, y T) Vector2[T]
- func (v Vector2[T]) Normalize() Vector2[T]
- func (v Vector2[T]) Perpendicular() Vector2[T]
- func (v Vector2[T]) Plus(other Vector2[T]) Vector2[T]
- func (v Vector2[T]) Round() Vector2[T]
- func (v Vector2[T]) Self() Vector2[T]
- func (v Vector2[T]) String() string
- func (v Vector2[T]) SubScalar(scalar T) Vector2[T]
- func (v Vector2[T]) SubScalars(x, y T) Vector2[T]
- func (v Vector2[T]) Swap() Vector2[T]
- func (v Vector2[T]) WithX(value T) Vector2[T]
- func (v Vector2[T]) WithY(value T) Vector2[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AngleBetween ¶ added in v1.4.0
AngleBetween calculates the angle between two vectors, returning a value in the range [-Pi, Pi].
func DistanceSquared ¶ added in v1.3.0
func DistanceToLine ¶ added in v1.4.0
DistanceToLine calculates the distance from a point P to a line defined by two points A->B.
func IsBetweenInclusive ¶ added in v1.3.0
func SideOfPoint ¶ added in v1.4.0
SideOfPoint calculates which side of the line A->B the point P lies on. Check the sign of the response.
Types ¶
type Number ¶ added in v1.3.0
type Number interface {
SignedInteger | Float
}
type SignedInteger ¶ added in v1.3.0
type Vector2 ¶
type Vector2[T Number] struct { X, Y T }
func NewFloat32 ¶ added in v1.3.0
func NewFloat64 ¶ added in v1.3.0
func NewFloat64Polar ¶ added in v1.3.0
func NewFloat64Random ¶ added in v1.3.0
func (Vector2[T]) AddScalars ¶
func (Vector2[T]) Components ¶ added in v1.3.1
func (v Vector2[T]) Components() (x, y T)
func (Vector2[T]) DivScalars ¶
func (Vector2[T]) MulScalars ¶
func (Vector2[T]) Perpendicular ¶ added in v1.3.0
func (Vector2[T]) Self ¶ added in v1.3.0
Self is useful if you want to build complex stuff with interfaces
func (Vector2[T]) SubScalars ¶
Click to show internal directories.
Click to hide internal directories.