A 2 dimensional Point, for Go

David Thielemann 991f3184cc Updated tests for the int rather than int64 update 1 jaar geleden
LICENSE 022c7c5b74 Added MIT License 1 jaar geleden
README.md 74d04ffbae Added Go Reference Badge to Project README 1 jaar geleden
go.mod a8d3ce06fa Moved this to a repo 1 jaar geleden
point.go 7b288bca28 Changed from int64 to int 1 jaar geleden
point_test.go 991f3184cc Updated tests for the int rather than int64 update 1 jaar geleden

README.md

Point 2D

A 2 dimensional Point.

Get it go get git.red-green.com/david/point2d

Go Reference

Example

package main

import (
    "fmt"
    "git.red-green.com/david/point2d"
)

func main() {
    var p *point2d.Point = new(point2d.Point)
    fmt.Println(p) // Automatically calls p.String()
    p.Set(3, 2) // Set's the Point's position to (3, 2)
    if p.Equal(3, 2) {
       fmt.Println("p is equal (3, 2)")
    } else {
       fmt.Println("p is not equal (3, 2), p is", p.String())
    }
    var p2 *point2d.Point = point2d.AsPoint(3, 9)
    var dist int = p.DistanceTo(&p2)
    fmt.Printf("p is %d away from p2\n", dist)
}