govecs

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 2 Imported by: 0

README

Vecgo

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/vecgo

Usage

package main

import (
    "fmt"

    "github.com/cantoramann/vecgo"
)


func main() {
    // Create a new vector (NewVector takes two points, start and end points)
    v := vecgo.NewVector(vecgo.NewPoint(1, 2, 3), vecgo.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(v2 *Vector) float64

func (*Vector) CrossProduct

func (v *Vector) CrossProduct(v2 *Vector) *Vector

func (*Vector) DirectionVector

func (v *Vector) DirectionVector() *Vector

func (*Vector) DotProduct

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

func (*Vector) GetDirection

func (v *Vector) GetDirection() *Point

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) String

func (v *Vector) String() string

func (*Vector) UnitVector

func (v *Vector) UnitVector() *Vector

Jump to

Keyboard shortcuts

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