Documentation
¶
Overview ¶
Package r2 provides 2D vectors and boxes and operations on them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Box ¶
type Box struct {
Min, Max Vec
}
Box is a 2D bounding box. Well formed Boxes have Min components smaller than Max components.
func NewBox ¶
NewBox is shorthand for Box{Min:Vec{x0,y0}, Max:Vec{x1,y1}}. The sides are swapped so that the resulting Box is well formed.
func (Box) Add ¶
Add adds v to the bounding box components. It is the equivalent of translating the Box by v.
func (Box) Canon ¶
Canon returns the canonical version of b. The returned Box has minimum and maximum coordinates swapped if necessary so that it is well-formed.
func (Box) Empty ¶
IsEmpty returns true if a Box's volume is zero or if a Min component is greater than its Max component.
func (Box) Scale ¶
Scale returns a new Box scaled by a size vector around its center. The scaling is done element wise, which is to say the Box's X size is scaled by v.X. Negative components of v are interpreted as zero.
type Rotation ¶
type Rotation struct {
// contains filtered or unexported fields
}
Rotation describes a rotation in 2D.
func NewRotation ¶
NewRotation creates a rotation by alpha, around p.
type Triangle ¶
type Triangle [3]Vec
Triangle represents a triangle in 2D space and is composed by 3 vectors corresponding to the position of each of the vertices.
func (Triangle) Centroid ¶
Centroid returns the intersection of the three medians of the triangle as a point in space.
func (Triangle) IsDegenerate ¶
IsDegenerate returns true if all of triangle's vertices are within tol distance of its longest side.