govecs

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 2 Imported by: 1

README

Govecs

A lightweight, basic vector library for Go. It is designed to be simple and easy to use, and to be as fast as possible.

Installation

go get github.com/cantoramann/govecs

Usage

package main

import (
    "fmt"

    "github.com/cantoramann/govecs"
)


func main() {
    // Create a new vector (NewVector takes two points, start and end points)
    v := govecs.NewVector(govecs.NewPoint(1, 2, 3), govecs.NewPoint(4, 5, 6))

    // Get the direction of the vector
    point := v.Direction()

    // Get the length of the vector
    fmt.Println(v.Length())

    // Get the unit vector
    vector := v.UnitVector()

    // Get the angle between two vectors
    angle := v.Angle(anotherVector)

    // Get the dot product of two vectors
    dotProduct := v.DotProduct(anotherVector)

    // Get the cross product of two vectors
    crossProduct := v.CrossProduct(anotherVector)

    // more coming soon...

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Point

type Point struct {
	// contains filtered or unexported fields
}

func NewPoint

func NewPoint(x, y, z float64) *Point

func (*Point) GetX

func (p *Point) GetX() float64

func (*Point) GetY

func (p *Point) GetY() float64

func (*Point) GetZ

func (p *Point) GetZ() float64

func (*Point) String

func (p *Point) String() string

type Vector

type Vector struct {
	// contains filtered or unexported fields
}

func NewVector

func NewVector(start, end *Point) *Vector

func (*Vector) Angle

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

func (*Vector) AngleDegree added in v1.0.2

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

func (*Vector) AngleRadian added in v1.0.2

func (c *Vector) AngleRadian(other *Vector) float64

func (*Vector) CrossProduct

func (v *Vector) CrossProduct(other *Vector) *Point

func (*Vector) DirectionVectorFromOrigin added in v1.0.2

func (v *Vector) DirectionVectorFromOrigin() *Point

func (*Vector) DotProduct

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

func (*Vector) GetEnd

func (v *Vector) GetEnd() *Point

func (*Vector) GetStart

func (v *Vector) GetStart() *Point

func (*Vector) Length

func (v *Vector) Length() float64

func (*Vector) Magnitude added in v1.0.2

func (v *Vector) Magnitude() float64

func (*Vector) Project added in v1.0.2

func (v *Vector) Project(other *Vector) *Vector

func (*Vector) String

func (v *Vector) String() string

func (*Vector) UnitVector

func (v *Vector) UnitVector() *Point

Jump to

Keyboard shortcuts

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