types

package
v0.0.0-...-5062497 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Point

type Point struct {
	X int32 `json:"x"`
	Y int32 `json:"y"`
}

Point structs holds 2D vector with int coordinates.

func NewPoint

func NewPoint(x, y int32) *Point

NewPoint initializes new vector with given parameters.

func NewPointFromPolar

func NewPointFromPolar(angle float64, radius uint32) *Point

NewPointFromPolar initializes new vector form given polar coordinates.

func ZeroPoint

func ZeroPoint() *Point

ZeroPoint initializes new zero vector.

func (*Point) Add

func (point *Point) Add(other *Vector) *Point

Add adds given Vector and return Point.

func (*Point) Distance

func (point *Point) Distance(other *Point) float64

Distance returns the distance between two points

func (*Point) Length

func (point *Point) Length() float64

Length returns length of the vector.

func (*Point) Normalize

func (point *Point) Normalize() *Vector

Normalize returns a new normalized vector.

func (*Point) String

func (point *Point) String() string

String returns string representation.

func (*Point) ToProto

func (point *Point) ToProto() *pb.Point

ToProto returns protobuf representation

type Vector

type Vector struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

Vector structs holds 2D vector.

func NewVector

func NewVector(x, y float64) *Vector

NewVector initlizes new vector with given parameters.

func ZeroVector

func ZeroVector() *Vector

ZeroVector initializes new zero vector.

func (*Vector) Add

func (v *Vector) Add(other *Vector) *Vector

Add returns new Vector that is a sum of the two given.

func (*Vector) Length

func (v *Vector) Length() float64

Length returns length of the vector.

func (*Vector) Multiply

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

Multiply returns new Vector that is a product of the the vector and given scalar.

func (*Vector) Normalize

func (v *Vector) Normalize() *Vector

Normalize returns a new normalized vector.

func (*Vector) Radians

func (v *Vector) Radians() float64

Radians returns vector's angle in radians.

func (*Vector) Rotate

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

Rotate returns rotated vector by give angle.

func (*Vector) String

func (v *Vector) String() string

String returns string representation.

func (*Vector) ToProto

func (v *Vector) ToProto() *pb.Vector

ToProto returns Vector's protobuf representation

Jump to

Keyboard shortcuts

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