vector

package
v0.0.2-early-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2025 License: MIT Imports: 1 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Two

type Two struct {
	X, Y float64
}

Two represents a 2D vector with X and Y components

func (Two) Add

func (v2a Two) Add(v2b Two) Two

Add returns the sum of two vectors

func (Two) AddAsInterface

func (v2 Two) AddAsInterface(v2B TwoReader) TwoFace

AddAsInterface adds another vector and returns the result as a TwoFace interface

func (Two) Clone

func (v2 Two) Clone() Two

Clone returns a copy of the vector

func (Two) CloneAsInterface

func (v2 Two) CloneAsInterface() TwoFace

CloneAsInterface returns a copy of the vector as a TwoFace interface

func (Two) CrossProduct

func (v2a Two) CrossProduct(v2b Two) float64

CrossProduct calculates the cross product of two vectors

func (Two) CrossProductAsInterface

func (v2 Two) CrossProductAsInterface(v2B TwoReader) float64

CrossProductAsInterface calculates the cross product with another vector

func (Two) Equal

func (v2 Two) Equal(v2b Two) bool

Equal checks if two vectors have identical components

func (Two) GetX

func (v2 Two) GetX() float64

GetX returns the X component of the vector

func (Two) GetY

func (v2 Two) GetY() float64

GetY returns the Y component of the vector

func (Two) Mag

func (v2 Two) Mag() float64

Mag returns the magnitude (length) of the vector

func (Two) MagSquared

func (v2 Two) MagSquared() float64

MagSquared returns the squared magnitude of the vector

func (Two) Norm

func (v2 Two) Norm() Two

Norm returns a normalized (unit length) version of the vector

func (Two) Perpendicular

func (v2 Two) Perpendicular() Two

Perpendicular returns a vector perpendicular to this one

func (Two) Rotate

func (v2 Two) Rotate(radians float64) Two

Rotate rotates the vector by the specified angle in radians

func (Two) RotateAroundPoint

func (v2 Two) RotateAroundPoint(radians float64, point Two) Two

RotateAroundPoint rotates the vector around a specified point

func (Two) RotateAsInterface

func (v2 Two) RotateAsInterface(radians float64) TwoFace

RotateAsInterface rotates the vector and returns the result as a TwoFace interface

func (Two) ScalarProduct

func (v2a Two) ScalarProduct(v2b Two) float64

ScalarProduct calculates the dot product of two vectors

func (Two) Scale

func (v2 Two) Scale(n float64) Two

Scale multiplies the vector by a scalar value

func (Two) ScaleAsInterface

func (v2 Two) ScaleAsInterface(n float64) TwoFace

ScaleAsInterface scales the vector and returns the result as a TwoFace interface

func (*Two) SetFromInterface

func (v2 *Two) SetFromInterface(tr TwoReader)

SetFromInterface sets vector components from a TwoReader interface

func (*Two) SetX

func (v2 *Two) SetX(x float64)

SetX sets the X component of the vector

func (*Two) SetY

func (v2 *Two) SetY(y float64)

SetY sets the Y component of the vector

func (Two) Sub

func (v2a Two) Sub(v2b Two) Two

Sub returns the difference of two vectors

func (Two) SubAsInterface

func (v2 Two) SubAsInterface(v2B TwoReader) TwoFace

SubAsInterface subtracts another vector and returns the result as a TwoFace interface

type TwoCalculator

type TwoCalculator interface {
	CloneAsInterface() TwoFace
	RotateAsInterface(radians float64) TwoFace
	AddAsInterface(TwoReader) TwoFace
	SubAsInterface(TwoReader) TwoFace
	CrossProductAsInterface(TwoReader) float64
	ScaleAsInterface(float64) TwoFace
}

TwoCalculator defines methods for performing calculations with 2D vectors

type TwoFace

type TwoFace interface {
	TwoWriter
	TwoReader
	TwoCalculator
}

TwoFace provides a complete interface for 2D vector operations

type TwoReader

type TwoReader interface {
	GetX() float64
	GetY() float64
}

TwoReader defines methods for accessing 2D vector values

type TwoWriter

type TwoWriter interface {
	SetFromInterface(TwoReader)
	SetX(x float64)
	SetY(y float64)
}

TwoWriter defines methods for modifying 2D vector values

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL