d2

package
v0.0.0-...-1c91121 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsElem

func AbsElem(a r2.Vec) r2.Vec

func CeilElem

func CeilElem(a r2.Vec) r2.Vec

func Clamp

func Clamp(x, a, b r2.Vec) r2.Vec

func CosElem

func CosElem(a r2.Vec) r2.Vec

func DivElem

func DivElem(a, b r2.Vec) r2.Vec

func Elem

func Elem(sides float64) r2.Vec

func EqualWithin

func EqualWithin(a, b r2.Vec, tol float64) bool

func LTEZero

func LTEZero(a r2.Vec) bool

LTEZero returns true if any vector components are <= 0.

func LTZero

func LTZero(a r2.Vec) bool

LTZero returns true if any vector components are < 0.

func Max

func Max(a r2.Vec) float64

func MaxElem

func MaxElem(a, b r2.Vec) r2.Vec

MaxElem return a vector with the maximum components of two vectors.

func Min

func Min(a r2.Vec) float64

func MinElem

func MinElem(a, b r2.Vec) r2.Vec

MinElem return a vector with the minimum components of two vectors.

func MulElem

func MulElem(a, b r2.Vec) r2.Vec

func Overlap

func Overlap(a, b r2.Vec) bool

Overlap returns true if 1D line segments a and b overlap.

func PolarToXY

func PolarToXY(r, theta float64) r2.Vec

PolarToXY converts polar to cartesian coordinates. (TODO remove)

func SinElem

func SinElem(a r2.Vec) r2.Vec

Types

type Box

type Box r2.Box

Box is a 2d bounding box.

func NewBox2

func NewBox2(center, size r2.Vec) Box

NewBox2 creates a 2d box with a given center and size.

func (Box) BottomLeft

func (a Box) BottomLeft() r2.Vec

BottomLeft returns the bottom left corner of a 2d bounding box.

func (Box) Center

func (a Box) Center() r2.Vec

Center returns the center of a 2d box.

func (Box) Contains

func (a Box) Contains(v r2.Vec) bool

Contains checks if the 2d box contains the given vector (considering bounds as inside).

func (Box) Enlarge

func (a Box) Enlarge(v r2.Vec) Box

Enlarge returns a new 2d box enlarged by a size vector.

func (Box) Equals

func (a Box) Equals(b Box, tol float64) bool

Equals test the equality of 2d boxes.

func (Box) Extend

func (a Box) Extend(b Box) Box

Extend returns a box enclosing two 2d boxes.

func (Box) Include

func (a Box) Include(v r2.Vec) Box

Include enlarges a 2d box to include a point.

func (Box) MinMaxDist2

func (a Box) MinMaxDist2(p r2.Vec) r2.Vec

MinMaxDist2 returns the minimum and maximum dist * dist from a point to a box. Points within the box have minimum distance = 0.

func (*Box) Random

func (b *Box) Random() r2.Vec

Random returns a random point within a bounding box.

func (*Box) RandomSet

func (b *Box) RandomSet(n int) Set

RandomSet returns a set of random points from within a bounding box.

func (Box) ScaleAboutCenter

func (a Box) ScaleAboutCenter(k float64) Box

ScaleAboutCenter returns a new 2d box scaled about the center of a box.

func (Box) Size

func (a Box) Size() r2.Vec

Size returns the size of a 2d box.

func (Box) TopLeft

func (a Box) TopLeft() r2.Vec

TopLeft returns the top left corner of a 2d bounding box.

func (Box) Translate

func (a Box) Translate(v r2.Vec) Box

Translate translates a 2d box.

func (Box) Vertices

func (a Box) Vertices() Set

Vertices returns a slice of 2d box corner vertices.

type Pol

type Pol struct {
	R, Theta float64
}

func CartesianToPolar

func CartesianToPolar(a r2.Vec) Pol

CartesianToPolar converts a cartesian to a polar coordinate.

func (Pol) PolarToCartesian

func (a Pol) PolarToCartesian() r2.Vec

PolarToCartesian converts a polar to a cartesian coordinate.

type Set

type Set []r2.Vec

func (Set) Max

func (a Set) Max() r2.Vec

Max return the maximum components of a set of vectors.

func (Set) Min

func (a Set) Min() r2.Vec

Min return the minimum components of a set of vectors.

type SortByX

type SortByX Set

func (SortByX) Len

func (a SortByX) Len() int

func (SortByX) Less

func (a SortByX) Less(i, j int) bool

func (SortByX) Swap

func (a SortByX) Swap(i, j int)

type Transform

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

Transform represents a 2D spatial transformation including translation and rotation.

func NewTransform

func NewTransform(data []float64) Transform

func TransformIdentity

func TransformIdentity() Transform

func (Transform) Add

func (a Transform) Add(b Transform) Transform

func (Transform) ApplyBox

func (a Transform) ApplyBox(box Box) Box

ApplyBox rotates/translates a 2d bounding box and resizes for axis-alignment.

func (Transform) ApplyPos

func (t Transform) ApplyPos(b r2.Vec) r2.Vec

func (*Transform) At

func (t *Transform) At(i, j int) float64

func (Transform) Determinant

func (a Transform) Determinant() float64

Determinant returns the determinant of a 4x4 matrix.

func (Transform) Inverse

func (a Transform) Inverse() Transform

Inverse returns the inverse of a 3x3 matrix.

func (Transform) Mul

func (a Transform) Mul(b Transform) Transform

Mul multiplies 3x3 matrices.

func (Transform) Scale

func (t Transform) Scale(k float64) Transform

func (*Transform) Set

func (t *Transform) Set(i, j int, v float64)

Jump to

Keyboard shortcuts

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