geom

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EuclidianDistance

func EuclidianDistance(pnt1, pnt2 Point) float64

EuclidianDistance returns the euclidian distance of two points

func RedMeanDistance

func RedMeanDistance(pnt1, pnt2 *Point) float64

RedMeanDistance returns the red mean distance of two color points, thus only works with the first 3 dimensions of the points

Types

type Bounds

type Bounds struct {
	Lower float32
	Upper float32
}

Bounds is a struct for lower - upper bounds

type Point

type Point struct {
	Coordinates []float32
	ID          int
}

Point is a collection of coordinates, with an identifier

func (*Point) Dimension

func (p *Point) Dimension() int

Dimension returns the dimension of the space this point lives in

func (*Point) Equals

func (p *Point) Equals(point Point) bool

Equals determines whether or not two points are the same, including their IDs

type PointSet

type PointSet struct {
	Points []Point
}

PointSet implements a slice of points

func (*PointSet) BranchByMedian

func (ps *PointSet) BranchByMedian(axis int) (PointSet, PointSet, Point)

BranchByMedian splits a PointSet in a left and a right PointSet, and also returns the Point that splits the two. This is done by sorting on one axis (see (*PointSet).SortByAxis())

func (*PointSet) ChunkPoints

func (ps *PointSet) ChunkPoints(n int) [][]Point

ChunkPoints splits the given PointSet in n chunks. The last chunk might be smaller if chunkSize is not a factor of len(PointSet.Points)

func (*PointSet) ChunkPointsMiniBatch added in v0.8.0

func (ps *PointSet) ChunkPointsMiniBatch(n, batchSize int) [][]Point

ChunkPointsMiniBatch splits the given PointSet in n chunks. "MiniBatch" refers to the fact that not all points will be used in the returned slice. This function shuffles the PointSet!

func (*PointSet) Contains

func (ps *PointSet) Contains(point Point) (bool, int)

Contains determines wheter or not, and where, the given Point resides in the PointSet

func (*PointSet) Kardinality

func (ps *PointSet) Kardinality() int

Kardinality returns the kardinality doesn't it

func (*PointSet) LowerAndUpperBounds

func (ps *PointSet) LowerAndUpperBounds() []Bounds

LowerAndUpperBounds returns Bounds for each dimension of the space wherein the Points of PointSet live. Returned value is a collection of lower and upper bounds, one Bounds for each dimension!

func (*PointSet) Mean

func (ps *PointSet) Mean() Point

Mean calculates the mean Point of all the Points in PointSet.

func (*PointSet) Remove

func (ps *PointSet) Remove(index int)

Remove removes the element at index from the PointSet, if a valid index is supplied

func (*PointSet) SortByAxis

func (ps *PointSet) SortByAxis(axis int)

SortByAxis sorts all Points in the PointSet in ascending order of certain provided axis numbers coordinate.

type Vec added in v0.9.4

type Vec [2]float64

Vec is a type alias for a 2D floating point vector

func (*Vec) Add added in v0.9.4

func (v *Vec) Add(other *Vec) Vec

Add adds two vectors and returns the result

func (*Vec) Scale added in v0.9.4

func (v *Vec) Scale(scale float64) Vec

Scale scales the vector according to the scale

func (*Vec) Sub added in v0.9.4

func (v *Vec) Sub(other *Vec) Vec

Sub subtracts two vectors and returns the result

Jump to

Keyboard shortcuts

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