vector

package
v0.0.0-...-91211bb Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Angle

func Angle(v Vector2D) float64

Finds angle relative to the y-axis. Clockwise is positive and Counterclockwise is negative.

func AngleReg

func AngleReg(v Vector2D) (theta float64)

Finds standard angle

func Components

func Components(v Vector2D) (x, y float64)

Ccomponents returns the components of the vector

func Distance

func Distance(v, v2 Vector2D) float64

func IntersectionPoint

func IntersectionPoint(a, b Vector2D, t float64) (x, y float64)

IntersectionPoints finds the actual intersection points. Will return non-valid numbers if t vector was invalid from IsIntersect. Uses the t arguement from IsIntersect. a and b are position and newPos of boid respectively.

func IsIntersect

func IsIntersect(a, b, c, d Vector2D) (t, u float64, intersected bool)

IsIntersect detects if two linesegments intersect. Intersect if 0 <= t <= 1 and 0 <= u <= 1 https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection Points a and b is 1 segment Points c and d is the 2 segment

func IsSeen

func IsSeen(pos, newPos, otherPos *Vector2D) (cosAngle float64)

IsSeen calculates angle of boid relative to current boid

func RotatePoints

func RotatePoints(theta float64, origin Vector2D, points ...*Vector2D)

RotatePoints Rotates points by an angle theta about an origin point Rotates in-place

func Sign

func Sign(num float64) float64

Types

type Vector2D

type Vector2D struct {
	X float64
	Y float64
}

func (*Vector2D) Add

func (v *Vector2D) Add(v2 Vector2D)

func (*Vector2D) Divide

func (v *Vector2D) Divide(z float64)

func (*Vector2D) Limit

func (v *Vector2D) Limit(max float64)

func (*Vector2D) MagnitudeSquared

func (v *Vector2D) MagnitudeSquared() float64

func (*Vector2D) Mini

func (v *Vector2D) Mini(max float64)

func (*Vector2D) Multiply

func (v *Vector2D) Multiply(z float64)

func (*Vector2D) Normalize

func (v *Vector2D) Normalize()

func (*Vector2D) SetMagnitude

func (v *Vector2D) SetMagnitude(z float64)

func (*Vector2D) Subtract

func (v *Vector2D) Subtract(v2 Vector2D)

Jump to

Keyboard shortcuts

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