vector

package module
v0.0.0-...-a1f6614 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: MIT Imports: 1 Imported by: 3

Documentation

Overview

Package vector provides vector functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Vector

type Vector struct {
	X, Y float64
}

Vector represents a point in space

func NewVector

func NewVector(x, y float64) *Vector

NewVector returns a new *Vector

func (*Vector) Add

func (v *Vector) Add(o *Vector) *Vector

Add adds o to v and returns a new Vector

func (*Vector) AngleTo

func (v *Vector) AngleTo(other *Vector) float64

AngleTo returns the angle between v to other

func (*Vector) Length

func (v *Vector) Length() float64

Length returns the length of the vector

func (*Vector) Mult

func (v *Vector) Mult(scalar float64) *Vector

Mult multiplies v by scaler and returns a new Vector for chaining

func (*Vector) Normalize

func (v *Vector) Normalize() *Vector

Normalize returns a new Vector representing the normal of v

func (*Vector) Rotate

func (v *Vector) Rotate(phi float64) *Vector

Rotate rotates a point about 0,0 and returns v for chaining

func (*Vector) RotateAround

func (v *Vector) RotateAround(phi float64, o *Vector) *Vector

RotateAround rotates a Vector about another Vector and returns v for chaining

func (*Vector) Sub

func (v *Vector) Sub(o *Vector) *Vector

Sub subtracts o from v and returns a new Vector

Jump to

Keyboard shortcuts

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