Documentation
¶
Overview ¶
Package mathg provides mathematical functions for graphics / games.
Index ¶
- Constants
- func Clamp(v float64) float64
- func Lerp(a, b, t float64) float64
- func Yoyo(v float64) float64
- type Line
- type Point
- func (p Point) Add(q Point) Point
- func (p Point) Angle() float64
- func (p Point) Cross(q Point) float64
- func (p Point) Div(k float64) Point
- func (p Point) Dot(q Point) float64
- func (p Point) Equal(q Point) bool
- func (p Point) In(r Rectangle) bool
- func (p Point) LengthSq() float64
- func (p Point) Lerp(q Point, t float64) Point
- func (p Point) Mul(k float64) Point
- func (p Point) Normalized() Point
- func (p Point) Rotate(theta float64) Point
- func (p Point) String() string
- func (p Point) Sub(q Point) Point
- type Rectangle
- func (r Rectangle) Add(p Point) Rectangle
- func (r Rectangle) At(x, y int) color.Color
- func (r Rectangle) Bounds() image.Rectangle
- func (r Rectangle) Canon() Rectangle
- func (r Rectangle) ColorModel() color.Model
- func (r Rectangle) Dx() float64
- func (r Rectangle) Dy() float64
- func (r Rectangle) Empty() bool
- func (r Rectangle) Eq(s Rectangle) bool
- func (r Rectangle) Image() image.Rectangle
- func (r Rectangle) In(s Rectangle) bool
- func (r Rectangle) Inset(n float64) Rectangle
- func (r Rectangle) Intersect(s Rectangle) Rectangle
- func (r Rectangle) Overlaps(s Rectangle) bool
- func (r Rectangle) Size() Point
- func (r Rectangle) String() string
- func (r Rectangle) Sub(p Point) Rectangle
- func (r Rectangle) Union(s Rectangle) Rectangle
Constants ¶
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Point ¶
type Point struct {
X, Y float64
}
A Point is an X, Y coordinate pair.
func PolarToPoint ¶
func (Point) Normalized ¶
Normalized returns the normalized vector.
type Rectangle ¶
type Rectangle struct {
Min, Max Point
}
func (Rectangle) Canon ¶
Canon returns the canonical version of r. The returned rectangle has minimum and maximum coordinates swapped if necessary so that it is well-formed.
func (Rectangle) ColorModel ¶
ColorModel implements the Image interface.
func (Rectangle) Eq ¶
Eq reports whether r and s contain the same set of points. All empty rectangles are considered equal.
func (Rectangle) Inset ¶
Inset returns the rectangle r inset by n, which may be negative. If either of r's dimensions is less than 2*n then an empty rectangle near the center of r will be returned.
func (Rectangle) Intersect ¶
Intersect returns the largest rectangle contained by both r and s. If the two rectangles do not overlap then the zero rectangle will be returned.