Documentation ¶
Overview ¶
Package vec2 contains a 2D float64 vector type T and functions.
Index ¶
- Variables
- func Angle(a, b *T) float64
- func Dot(a, b *T) float64
- func IsLeftWinding(a, b *T) bool
- func IsRightWinding(a, b *T) bool
- func PointSegmentDistance(p1 *T, x1 *T, x2 *T) float64
- type Rect
- func (rect *Rect) Area() float64
- func (rect *Rect) Array() *[4]float64
- func (rect *Rect) Contains(other *Rect) bool
- func (rect *Rect) ContainsPoint(p *T) bool
- func (rect *Rect) Extend(p *T)
- func (rect *Rect) Height() float64
- func (rect *Rect) Intersects(other *Rect) bool
- func (rect *Rect) Join(other *Rect)
- func (rect *Rect) Size() float64
- func (rect *Rect) Slice() []float64
- func (rect *Rect) String() string
- func (rect *Rect) Width() float64
- type T
- func (vec *T) Add(v *T) *T
- func (vec *T) Angle() float64
- func (vec *T) Clamp(min, max *T) *T
- func (vec *T) Clamp01() *T
- func (vec *T) Clamped(min, max *T) T
- func (vec *T) Clamped01() T
- func (vec *T) Cols() int
- func (vec *T) Get(col, row int) float64
- func (vec *T) Invert() *T
- func (vec *T) Inverted() T
- func (vec *T) IsZero() bool
- func (vec *T) Length() float64
- func (vec *T) LengthSqr() float64
- func (vec *T) Mul(v *T) *T
- func (vec *T) Normalize() *T
- func (vec *T) Normalized() T
- func (vec *T) Rotate(angle float64) *T
- func (vec *T) Rotate90DegLeft() *T
- func (vec *T) Rotate90DegRight() *T
- func (vec *T) RotateAroundPoint(point *T, angle float64) *T
- func (vec *T) Rotated(angle float64) T
- func (vec *T) Rows() int
- func (vec *T) Scale(f float64) *T
- func (vec *T) Scaled(f float64) T
- func (vec *T) SetMax(c T)
- func (vec *T) SetMin(c T)
- func (vec *T) Size() int
- func (vec *T) Slice() []float64
- func (vec *T) String() string
- func (vec *T) Sub(v *T) *T
Constants ¶
This section is empty.
Variables ¶
var ( // Zero holds a zero vector. Zero = T{} // UnitX holds a vector with X set to one. UnitX = T{1, 0} // UnitY holds a vector with Y set to one. UnitY = T{0, 1} // UnitXY holds a vector with X and Y set to one. UnitXY = T{1, 1} // MinVal holds a vector with the smallest possible component values. MinVal = T{-math.MaxFloat64, -math.MaxFloat64} // MaxVal holds a vector with the highest possible component values. MaxVal = T{+math.MaxFloat64, +math.MaxFloat64} )
Functions ¶
func IsLeftWinding ¶
IsLeftWinding returns if the angle from a to b is left winding.
func IsRightWinding ¶
IsRightWinding returns if the angle from a to b is right winding.
Types ¶
type Rect ¶
Rect is a coordinate system aligned rectangle defined by a Min and Max vector.
func (*Rect) ContainsPoint ¶
ContainsPoint returns if a point is contained within the rectangle.
func (*Rect) Intersects ¶
type T ¶
type T [2]float64
T represents a 2D vector.
func Interpolate ¶
Interpolate interpolates between a and b at t (0,1).
func (*T) Clamped ¶
Clamped returns a copy of the vector with the components clamped to be in the range of min to max.
func (*T) Clamped01 ¶
Clamped01 returns a copy of the vector with the components clamped to be in the range of 0 to 1.
func (*T) LengthSqr ¶
LengthSqr returns the squared length of the vector. See also Length and Normalize.
func (*T) Normalized ¶
Normalized returns a unit length normalized copy of the vector.
func (*T) Rotate90DegLeft ¶
Rotate90DegLeft rotates the vector 90 degrees left (counter-clockwise).
func (*T) Rotate90DegRight ¶
Rotate90DegRight rotates the vector 90 degrees right (clockwise).
func (*T) RotateAroundPoint ¶
RotateAroundPoint rotates the vector counter-clockwise around a point.