package
module
Version:
v1.0.2
Opens a new window with list of versions in this module.
Published: Nov 15, 2022
License: MIT
Opens a new window with license information.
Imports: 3
Opens a new window with list of imports.
Imported by: 3
Opens a new window with list of known importers.
README
¶
Documentation
¶
type V[T numeric] struct {
X, Y T
}
V represents 2D vector.
func New[T numeric](x, y T) (r V[T])
New creates new vector with given coordinates.
func (v V[T]) Abs() (r V[T])
Abs returns vector of absolute values.
func (v V[T]) Add(n V[T]) (r V[T])
Add performs vector addition.
func (v V[T]) Ceil() (r V[T])
Ceil returns rounded-up vector.
func (v V[T]) Cross(n V[T]) (r T)
Cross calculates cross-product.
func (v V[T]) Div(n V[T]) (r V[T])
Div performs vector division.
func (v V[T]) DivScalar(n T) (r V[T])
DivScalar performs vector * scalar division.
func (v V[T]) Dot(n V[T]) (r T)
Dot calculates dot-product.
func (v V[T]) Floor() (r V[T])
Floor returns rounded-down vector.
func (v V[T]) Len() (r T)
Len calculates length of vector.
func (v V[T]) Max(n V[T]) (r V[T])
Max returns maximum of two vectors.
func (v V[T]) Min(n V[T]) (r V[T])
Min returns minimum of two vectors.
func (v V[T]) Mul(n V[T]) (r V[T])
Mul performs vector multiplication.
func (v V[T]) MulScalar(n T) (r V[T])
MulScalar performs vector * scalar multiplication.
func (v V[T]) Neg() (r V[T])
Neg returns negative vector.
func (v V[T]) Norm() (r V[T])
Norm calculates normal vector.
String returns string representation of vector.
func (v V[T]) Sub(n V[T]) (r V[T])
Sub performs vector subtraction.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.