geom

package
v0.0.0-...-c963681 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Directions2D = [4]Point2D[int]{
	{0, -1},
	{1, 0},
	{0, 1},
	{-1, 0},
}

Directions2D is an array of points corresponding to the difference to move in a certain direction in 2D. The order of the points is clockwise starting from up, i.e., UP, RIGHT, DOWN, LEFT.

View Source
var Directions3D = [6]Point3D[int]{
	{0, -1, 0},
	{1, 0, 0},
	{0, 1, 0},
	{-1, 0, 0},
	{0, 0, 1},
	{0, 0, -1},
}

Directions3D is an array of points corresponding to the difference to move in a certain direction in 3D. The order of the points is clockwise starting from up, and then front and back (z-axis), i.e., UP, RIGHT, DOWN, LEFT, FRONT, BACK.

Functions

This section is empty.

Types

type BoundingBox2D

type BoundingBox2D struct {
	MinX int
	MaxX int
	MinY int
	MaxY int
}

BoundingBox2D contains information about coordinates of a rectangular border. This could represent the minimum and maximum value of X and Y coorindates in the coordinate system or minimum and maximum rows and columns for a matrix.

func NewBoundingBox2D

func NewBoundingBox2D(minx, maxx, miny, maxy int) *BoundingBox2D

NewBoundingBox2D creates a new two dimensional bounding box.

func (*BoundingBox2D) Area

func (b *BoundingBox2D) Area() int

Area returns the area of the bounding box.

func (*BoundingBox2D) Contains

func (b *BoundingBox2D) Contains(x, y int) bool

Contains is used to check whether the point formed by given x and y values is within the bounds of the box.

func (*BoundingBox2D) Intersection

func (b *BoundingBox2D) Intersection(other *BoundingBox2D) *BoundingBox2D

Intersection returns the bounding box formed by the intersection of bbox2d with other, nil if they do not intersect.

type BoundingBox3D

type BoundingBox3D struct {
	MinX int
	MaxX int
	MinY int
	MaxY int
	MinZ int
	MaxZ int
}

BoundingBox3D is similar to BoundingBox2D, except this represents a three dimensional cuboid.

func NewBoundingBox3D

func NewBoundingBox3D(minx, maxx, miny, maxy, minz, maxz int) *BoundingBox3D

NewBoundingBox3D creates a new three dimensional bounding box.

func (*BoundingBox3D) Contains

func (b *BoundingBox3D) Contains(x, y, z int) bool

Contains is used to check whether the point formed by given x, y and z values is within the bounds of the box.

func (*BoundingBox3D) Intersection

func (b *BoundingBox3D) Intersection(other *BoundingBox3D) *BoundingBox3D

Intersection returns the bounding box formed by the intersection of bbox3d with other, nil if they do not intersect.

func (*BoundingBox3D) Volume

func (b *BoundingBox3D) Volume() int

Volume returns the volume of the bounding box.

type Point2D

type Point2D[T constraints.Signed] struct {
	X, Y T
}

Point2D represents a 2 dimensional point in the coordinate system.

func (Point2D[T]) Add

func (p Point2D[T]) Add(other Point2D[T]) Point2D[T]

Add adds p to other, returning the new point.

func (Point2D[T]) Equal

func (p Point2D[T]) Equal(other Point2D[T]) bool

Equal returns true if p and other are the same point.

func (Point2D[T]) ManhattanDistance

func (p Point2D[T]) ManhattanDistance(other Point2D[T]) T

ManhattanDistance returns the manhattan distance between p and other.

func (Point2D[T]) Neighbors

func (p Point2D[T]) Neighbors() []Point2D[T]

Neighbors returns the neighboring points for p. These are the 6 directions corresponding to +ve and -ve X, Y and Z axis.

func (Point2D[T]) String

func (p Point2D[T]) String() string

func (Point2D[T]) Sub

func (p Point2D[T]) Sub(other Point2D[T]) Point2D[T]

Sub subtract other from p, returning the new point.

type Point3D

type Point3D[T constraints.Signed] struct {
	X, Y, Z T
}

Point3D represents a 3 dimensional point in the coordinate system.

func (Point3D[T]) Add

func (p Point3D[T]) Add(other Point3D[T]) Point3D[T]

Add adds p to other, returning the new point.

func (Point3D[T]) Equal

func (p Point3D[T]) Equal(other Point3D[T]) bool

Equal returns true if p and other are the same point.

func (Point3D[T]) ManhattanDistance

func (p Point3D[T]) ManhattanDistance(other Point3D[T]) T

ManhattanDistance returns the manhattan distance between p and other.

func (Point3D[T]) Neighbors

func (p Point3D[T]) Neighbors() []Point3D[T]

Neighbors returns the neighboring points for p. These are the 6 directions corresponding to +ve and -ve X, Y and Z axis.

func (Point3D[T]) String

func (p Point3D[T]) String() string

func (Point3D[T]) Sub

func (p Point3D[T]) Sub(other Point3D[T]) Point3D[T]

Sub subtract other from p, returning the new point.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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