Documentation ¶
Overview ¶
Pacakge v2d implements 2D float32 vector math
Index ¶
- type Rect
- type Transform
- type TransformRotateMove
- type Vec
- func (v Vec) Add(w Vec) Vec
- func (v Vec) Angle() float32
- func (v Vec) Cross(w Vec) float32
- func (v Vec) CrossZ(z float32) Vec
- func (v Vec) Dot(w Vec) float32
- func (v Vec) Eq(w Vec, tol float32) bool
- func (v Vec) IsZero() bool
- func (v Vec) Length() float32
- func (v Vec) LengthSquared() float32
- func (v Vec) Neg() Vec
- func (v Vec) Orth() (w Vec)
- func (v Vec) Scale(s float32) Vec
- func (v Vec) Split() (float32, float32)
- func (v Vec) Sub(w Vec) Vec
- func (v Vec) Unit() Vec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Rect ¶
type Rect struct {
Min, Max Vec
}
A Rect represents a bounding rectangle in the (x, y) plane that is always aligned with the x and y axis.
type TransformRotateMove ¶
func RotateMove ¶
func RotateMove(theta float32, around, offset Vec) (t TransformRotateMove)
Rotate move creates a Transform that rotates with an angle theta about around and subsequently adds offset.
func (TransformRotateMove) TransRect ¶
func (t TransformRotateMove) TransRect(r Rect) (tr Rect)
TransRect applies this transform to a rectangle. Note that since rectangles always are axis aligned the transformed rectangle will fully enclose the original rectangle.
func (TransformRotateMove) TransVec ¶
func (t TransformRotateMove) TransVec(v Vec) (w Vec)
TransVec applies this Transform to a vector
type Vec ¶
type Vec struct {
X, Y float32
}
Vec is a 2D vector (x, y)
func (Vec) Cross ¶
Cross assumes that v, w are (x,y,0) vectors and returns the z component of 3D cross product only.
func (Vec) LengthSquared ¶
LengthSquared returns the length of the vector squared.
func (Vec) Orth ¶
Orth returns a vector w of same length as v that is orthogonal to v such that (v, w) are "right handed".