Documentation ¶
Overview ¶
Package vectors implements various vector thingies.
Index ¶
- Variables
- func Angle2(v Vec2) float64
- func AngleBetween(p1, p2, p3 Vec2) float64
- func AngleBetweenTwoVectors(v1, v2 Vec2) float64
- func Cross2(v1, v2 Vec2) float64
- func Dist2(a, b Vec2) float64
- func Dist3(a, b Vec3) float64
- func Dot2(v1, v2 Vec2) float64
- func Dot3(v1, v2 Vec3) float64
- func EqualVec2(a, b Vec2) bool
- func Equalish(a, b float64) bool
- func MinDegreesDifference2(a, b float64) float64
- func PointInTriangle(p Vec2, triangle []Vec2) bool
- type IVec2
- type Mat3
- type Ray2
- type Segment
- func (s1 Segment) ClosestPoint(p Vec2) Vec2
- func (s1 Segment) DistanceToPoint(p Vec2) float64
- func (s1 Segment) Intersect(s2 Segment) bool
- func (s1 Segment) IntersectPoint(s2 Segment) *Vec2
- func (s1 Segment) Intersects(l2 Segment) (bool, Vec2)
- func (s1 Segment) IsPointOnLine(p Vec2) bool
- func (s Segment) Len() float64
- func (s1 Segment) Midpoint() Vec2
- type Vec2
- func (v1 Vec2) Add(v2 Vec2) Vec2
- func (v1 *Vec2) AddToThis(v2 Vec2)
- func (v Vec2) Angle() float64
- func (v1 Vec2) Cross(v2 Vec2) float64
- func (v Vec2) DistanceTo(v2 Vec2) float64
- func (v Vec2) DistanceToSquared(v2 Vec2) float64
- func (v1 Vec2) Dot(v2 Vec2) float64
- func (v1 Vec2) Equal(v2 Vec2) bool
- func (v1 Vec2) Equalish(v2 Vec2) bool
- func (v1 Vec2) Len() float64
- func (v Vec2) LengthSquared() float64
- func (v1 Vec2) Mul(c float64) Vec2
- func (v1 *Vec2) MulWithThis(c float64)
- func (v Vec2) Negate() Vec2
- func (v Vec2) Normal() Vec2
- func (v Vec2) Normalize() Vec2
- func (v1 Vec2) Perpendicular() Vec2
- func (v Vec2) Reflect(normal Vec2) Vec2
- func (v1 Vec2) Rotate(angle float64) Vec2
- func (v Vec2) RotateAroundPoint(p Vec2, angle float64) Vec2
- func (v *Vec2) SetLength(length float64) Vec2
- func (v1 *Vec2) SetXY(x, y float64)
- func (v1 Vec2) Sub(v2 Vec2) Vec2
- type Vec3
- func (v1 Vec3) Add(v2 Vec3) Vec3
- func (v1 *Vec3) AddToThis(v2 Vec3)
- func (v1 Vec3) Cross(v2 Vec3) Vec3
- func (v1 Vec3) Dot(v2 Vec3) float64
- func (v1 Vec3) Len() float64
- func (v1 Vec3) Mul(c float64) Vec3
- func (v1 Vec3) Normalize() Vec3
- func (v1 Vec3) Rotate(axis Vec3, angle float64) Vec3
- func (v1 Vec3) Sub(v2 Vec3) Vec3
Constants ¶
This section is empty.
Variables ¶
var Up = Vec3{0, 1, 0}
Up is a vector pointing up (0, 1, 0).
Functions ¶
func AngleBetween ¶
AngleBetween returns the angle between the three points.
func AngleBetweenTwoVectors ¶
AngleBetweenTwoVectors returns the angle between two vectors.
func MinDegreesDifference2 ¶
MinDegreesDifference2 returns the minimum difference between two angles in degrees.
func PointInTriangle ¶
Types ¶
type Ray2 ¶
Ray2 represents a ray in 2D space.
func (Ray2) Intersects ¶
Intersects returns true if the ray intersects with the line segment.
type Segment ¶
Segment represents a line segment.
func (Segment) ClosestPoint ¶
ClosestPoint returns the closest point on the segment to the given point.
func (Segment) DistanceToPoint ¶
DistanceToPoint returns the distance to the given point.
func (Segment) IntersectPoint ¶
IntersectPoint returns the intersection point of the two segments.
func (Segment) Intersects ¶
Intersects returns true if the line intersects with the other line.
func (Segment) IsPointOnLine ¶
IsPointOnLine returns true if the point is on the line.
type Vec2 ¶
Vec2 represents a two dimensional vector.
func (Vec2) DistanceTo ¶
DistanceTo returns the distance to the given vector.
func (Vec2) DistanceToSquared ¶
DistanceToSquared returns the squared distance to the given vector.
func (Vec2) LengthSquared ¶
LengthSquared returns the squared length of the vector.
func (*Vec2) MulWithThis ¶
MulWithThis multiplies the current vector with c.
func (Vec2) Perpendicular ¶
Perpendicular returns the perpendicular vector.
func (Vec2) RotateAroundPoint ¶
RotateAroundPoint rotates the vector around the given point.
type Vec3 ¶
Vec3 represents a three dimensional vector.
func (Vec3) Len ¶
Len returns the vector's length (or magnitude).
NOTE: This is equivalent to the square root of the sum of the squares of all elements. E.G. for a Vec2 it's math.Hypot(v[0], v[1]).