math

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: CC0-1.0, MIT Imports: 1 Imported by: 13

Documentation

Index

Constants

View Source
const Epsilon = 0.00001

Variables

This section is empty.

Functions

func ToDegrees added in v1.2.17

func ToDegrees(radians float64) float64

func ToRadians added in v1.2.17

func ToRadians(degrees float64) float64

Types

type Vec2

type Vec2 struct {
	X float64
	Y float64
}

Vec2 represents a 2D vector.

func NewVec2

func NewVec2(x, y float64) Vec2

NewVec2 creates a new vector.

func (Vec2) Add

func (v Vec2) Add(other Vec2) Vec2

Add adds x and y to the vector.

func (Vec2) Angle

func (v Vec2) Angle(other Vec2) float64

Angle returns angle in radian to another vec2

func (Vec2) Distance

func (v Vec2) Distance(other Vec2) float64

Distance returns the distance between the vector and another vector.

func (Vec2) DivScalar

func (v Vec2) DivScalar(scalar float64) Vec2

DivScalar divides the vector by a scalar.

func (Vec2) Dot

func (v Vec2) Dot(other *Vec2) float64

Dot returns the dot product of the vector and another vector.

func (Vec2) Equal

func (v Vec2) Equal(other Vec2) bool

Equal returns true if the vector is equal to another vector.

func (Vec2) IsZero added in v1.2.20

func (v Vec2) IsZero() bool

IsZero returns true if the vector is (0, 0).

func (Vec2) Magnitude

func (v Vec2) Magnitude() float64

Magnitude returns the magnitude of the vector.

func (Vec2) Mul added in v1.2.17

func (v Vec2) Mul(other Vec2) Vec2

Mul multiplies the vector by another vector.

func (Vec2) MulScalar

func (v Vec2) MulScalar(scalar float64) Vec2

MulScalar multiplies the vector by a scalar.

func (Vec2) Normalized added in v1.2.20

func (v Vec2) Normalized() Vec2

Normalized returns the normalized vector.

func (Vec2) Rotate

func (v Vec2) Rotate(rad float64) Vec2

Rotate rotates the vector by the given angle.

func (Vec2) RotateAround

func (v Vec2) RotateAround(point *Vec2, angle float64) Vec2

RotateAround rotates the vector by the given angle around the given point.

func (Vec2) Sub

func (v Vec2) Sub(other Vec2) Vec2

Sub subtracts x and y from the vector.

func (Vec2) XY added in v1.4.1

func (v Vec2) XY() (float64, float64)

Jump to

Keyboard shortcuts

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