Documentation ¶
Overview ¶
Package point provides convenience logic for manipulating points and regions in 2-space.
NOTE: this package mostly exists because I (Josh) had never used the core "image" package much, and didn't know about its Point/Rectangle structs; one point of view would say that many of the utililyt methods should just be broken out (maybe into "bork/internal/moremath") as function-taking-data (rather than receiving). The Point structure is (coincidentally) cast-compatible with the standard one in the "image" package; the Box isn't becasue of Go's conservatism composing poorly with my short sightedness.
TODO: de-conflict and align better with core "image".Point et al along spiritually identical or similar methods.
Index ¶
- Variables
- func MulRespective(a, b image.Point) image.Point
- func Sign(pt image.Point) image.Point
- func SumSQ(pt image.Point) int
- type Box
- type Point
- func (pt Point) Abs() Point
- func (pt Point) Add(other Point) Point
- func (pt Point) Div(n int) Point
- func (pt Point) Dot(other Point) int
- func (pt Point) Equal(other Point) bool
- func (pt Point) Less(other Point) bool
- func (pt Point) Max(other Point) Point
- func (pt Point) Min(other Point) Point
- func (pt Point) Mul(n int) Point
- func (pt Point) Neg() Point
- func (pt Point) Sign() Point
- func (pt Point) Sub(other Point) Point
- func (pt Point) SumSQ() int
- type ZFrame
Constants ¶
This section is empty.
Variables ¶
var Zero = Point{}
Zero is the origin, the zero value of Point.
Functions ¶
func MulRespective ¶
MulRespective returns a point scaled by another point, multiplying the values of their respective axes.
Types ¶
type Box ¶
Box represents a bounding box defined by a top-left and bottom-right point.
func (Box) DistanceTo ¶
DistanceTo returns a signed distance to the given point from the nearest box corner.
func (Box) ExpandBy ¶
ExpandBy symmetrically expands a copy of the box by a given x/y displacement, returning the copy.
func (Box) ExpandTo ¶
ExpandTo expands a copy of the box to include the given point, returning the copy.
type Point ¶
type Point struct{ X, Y int }
Point represents a point in <X,Y> 2-space.
func (Point) Max ¶
Max returns a copy of this point with each component the maximum of the two points' components.
func (Point) Min ¶
Min returns a copy of this point with each component the minimum of the two points' components.
func (Point) Sign ¶
Sign returns a copy of this point reduced to the values -1, 0, or 1 depending on the sign of the original values.