Documentation ¶
Index ¶
- Constants
- func AngleDiff(fromRad, toRad float32) float32
- func CartesianToSpherical(pos Vec3f) (float32, float32, float32)
- func Clampf(v, min, max float32) float32
- func Clampi(v, min, max int) int
- func EqualEps(a, b, epsilon float32) bool
- func Equalf(a, b float32) bool
- func IsPointOnLeft(a, b Vec2f, point Vec2f) bool
- func IsPointOnLine(a, b Vec2f, point Vec2f) bool
- func IsPointOnLineEps(a, b Vec2f, point Vec2f, eps float32) bool
- func Lerp(a, b, t float32) float32
- func NormalizeDegrees(deg float32) float32
- func NormalizeRadians(rad float32) float32
- func PointToLineDistance2D(a, b, point Vec2f) float32
- func PointToLineSegmentDistance2D(a, b, point Vec2f) float32
- func ToDegrees(rad float32) float32
- func ToRadians(deg float32) float32
- func Wrapf(v, min, max float32) float32
- func Wrapi(v, min, max int) int
- type Mat2f
- func (m Mat2f) Add(other Mat2f) Mat2f
- func (m Mat2f) AddScalar(s float32) Mat2f
- func (m Mat2f) Cell(row, col int) float32
- func (m Mat2f) Col(col int) Vec2f
- func (m Mat2f) Cols() (col0, col1 Vec2f)
- func (m Mat2f) Det() float32
- func (m Mat2f) Diag() Vec2f
- func (m Mat2f) Equal(other Mat2f) bool
- func (m Mat2f) EqualEps(other Mat2f, epsilon float32) bool
- func (m Mat2f) Index(row, col int) int
- func (m Mat2f) Inverse() (Mat2f, bool)
- func (m Mat2f) Mat3f() Mat3f
- func (m Mat2f) Mat4f() Mat4f
- func (m Mat2f) Mul(other Mat2f) Mat2f
- func (m Mat2f) MulScalar(s float32) Mat2f
- func (m Mat2f) MulVec(v Vec2f) Vec2f
- func (m Mat2f) Row(row int) Vec2f
- func (m Mat2f) Rows() (row0, row1 Vec2f)
- func (m *Mat2f) Set(row, col int, v float32)
- func (m *Mat2f) SetCol(col int, v Vec2f)
- func (m *Mat2f) SetRow(row int, v Vec2f)
- func (m Mat2f) String() string
- func (m Mat2f) Sub(other Mat2f) Mat2f
- func (m Mat2f) SubScalar(s float32) Mat2f
- func (m Mat2f) Transpose() Mat2f
- type Mat3f
- func (m Mat3f) Add(other Mat3f) Mat3f
- func (m Mat3f) AddScalar(s float32) Mat3f
- func (m Mat3f) Cell(row, col int) float32
- func (m Mat3f) Col(col int) Vec3f
- func (m Mat3f) Cols() (col0, col1, col2 Vec3f)
- func (m Mat3f) Det() float32
- func (m Mat3f) Diag() Vec3f
- func (m Mat3f) Equal(other Mat3f) bool
- func (m Mat3f) EqualEps(other Mat3f, epsilon float32) bool
- func (m Mat3f) Index(row, col int) int
- func (m Mat3f) Inverse() (Mat3f, bool)
- func (m Mat3f) InverseTranspose() (Mat3f, bool)
- func (m Mat3f) Mat2f() Mat2f
- func (m Mat3f) Mat4f() Mat4f
- func (m Mat3f) Mul(other Mat3f) Mat3f
- func (m Mat3f) MulScalar(s float32) Mat3f
- func (m Mat3f) MulVec(v Vec3f) Vec3f
- func (m Mat3f) Row(row int) Vec3f
- func (m Mat3f) Rows() (row0, row1, row2 Vec3f)
- func (m *Mat3f) Set(row, col int, v float32)
- func (m *Mat3f) SetCol(col int, v Vec3f)
- func (m *Mat3f) SetRow(row int, v Vec3f)
- func (m Mat3f) String() string
- func (m Mat3f) Sub(other Mat3f) Mat3f
- func (m Mat3f) SubScalar(s float32) Mat3f
- func (m Mat3f) Transpose() Mat3f
- type Mat4f
- func Frustum(left, right, bottom, top float32, near, far float32) Mat4f
- func Ident4f() Mat4f
- func LookAt(eye, target, up Vec3f) Mat4f
- func Mat4fFromCols(col0, col1, col2, col3 Vec4f) Mat4f
- func Mat4fFromRotation(axis Vec3f, rad float32) Mat4f
- func Mat4fFromRotationTranslation(rot Quat, trans Vec3f) Mat4f
- func Mat4fFromRotationTranslationScale(rot Quat, trans, scale Vec3f) Mat4f
- func Mat4fFromRotationTranslationScaleOrigin(rot Quat, trans, scale, orig Vec3f) Mat4f
- func Mat4fFromRows(row0, row1, row2, row3 Vec4f) Mat4f
- func Mat4fFromScaling(scaling Vec3f) Mat4f
- func Mat4fFromTranslation(translation Vec3f) Mat4f
- func Mat4fFromXRotation(rad float32) Mat4f
- func Mat4fFromYRotation(rad float32) Mat4f
- func Mat4fFromZRotation(rad float32) Mat4f
- func Ortho(left, right, bottom, top float32, near, far float32) Mat4f
- func Perspective(fovY, aspectRatio, near, far float32) Mat4f
- func UnOrtho(left, right, bottom, top float32, near, far float32) Mat4f
- func (m Mat4f) Add(other Mat4f) Mat4f
- func (m Mat4f) AddScalar(s float32) Mat4f
- func (m Mat4f) Cell(row, col int) float32
- func (m Mat4f) Col(col int) Vec4f
- func (m Mat4f) Cols() (col0, col1, col2, col3 Vec4f)
- func (m Mat4f) Det() float32
- func (m Mat4f) Diag() Vec4f
- func (m Mat4f) Equal(other Mat4f) bool
- func (m Mat4f) EqualEps(other Mat4f, epsilon float32) bool
- func (m Mat4f) Index(row, col int) int
- func (m Mat4f) Inverse() (Mat4f, bool)
- func (m Mat4f) InverseAffine() (Mat4f, bool)
- func (m Mat4f) InverseTranspose() (Mat4f, bool)
- func (m Mat4f) IsAffine() bool
- func (m Mat4f) Mat2f() Mat2f
- func (m Mat4f) Mat3f() Mat3f
- func (m Mat4f) Mul(other Mat4f) Mat4f
- func (m Mat4f) MulScalar(s float32) Mat4f
- func (m Mat4f) MulVec(v Vec4f) Vec4f
- func (m Mat4f) RotateX(rad float32) Mat4f
- func (m Mat4f) RotateY(rad float32) Mat4f
- func (m Mat4f) RotateZ(rad float32) Mat4f
- func (m Mat4f) Rotation() Quat
- func (m Mat4f) Row(row int) Vec4f
- func (m Mat4f) Rows() (row0, row1, row2, row3 Vec4f)
- func (m Mat4f) Scale(scaling Vec3f) Mat4f
- func (m Mat4f) Scaling() Vec3f
- func (m *Mat4f) Set(row, col int, v float32)
- func (m *Mat4f) SetCol(col int, v Vec4f)
- func (m Mat4f) SetMat3f(other Mat3f) Mat4f
- func (m *Mat4f) SetRow(row int, v Vec4f)
- func (m Mat4f) SetScaling(scaling Vec3f) Mat4f
- func (m Mat4f) SetTranslation(translation Vec3f) Mat4f
- func (m Mat4f) String() string
- func (m Mat4f) Sub(other Mat4f) Mat4f
- func (m Mat4f) SubScalar(s float32) Mat4f
- func (m Mat4f) Translate(translation Vec3f) Mat4f
- func (m Mat4f) Translation() Vec3f
- func (m Mat4f) Transpose() Mat4f
- type MatStack4f
- func (m *MatStack4f) MulLeft(mat Mat4f)
- func (m *MatStack4f) MulRight(mat Mat4f)
- func (m *MatStack4f) Pop() error
- func (m *MatStack4f) Push()
- func (m *MatStack4f) PushIdent()
- func (m *MatStack4f) PushMulLeft(mat Mat4f)
- func (m *MatStack4f) PushMulRight(mat Mat4f)
- func (m *MatStack4f) PushSet(mat Mat4f)
- func (m *MatStack4f) Set(mat Mat4f)
- func (m *MatStack4f) SetIdent()
- func (m MatStack4f) Size() int
- func (m MatStack4f) Top() Mat4f
- type Quat
- func (q Quat) Add(other Quat) Quat
- func (q Quat) AddScalar(s float32) Quat
- func (q Quat) Angle() float32
- func (q Quat) AngleTo(other Quat) float32
- func (q Quat) Axis() Vec3f
- func (q Quat) AxisRotation() (Vec3f, float32)
- func (q Quat) Conjugate() Quat
- func (q Quat) Div(other Quat) Quat
- func (q Quat) DivScalar(s float32) Quat
- func (q Quat) Dot(other Quat) float32
- func (q Quat) Equals(other Quat) bool
- func (q Quat) EqualsEps(other Quat, epsilon float32) bool
- func (q Quat) Forward() Vec3f
- func (q Quat) Inverse() Quat
- func (q Quat) Length() float32
- func (q Quat) Lerp(other Quat, t float32) Quat
- func (q Quat) Mat4f() Mat4f
- func (q Quat) Mul(other Quat) Quat
- func (q Quat) MulScalar(s float32) Quat
- func (q Quat) Normalize() Quat
- func (q Quat) Right() Vec3f
- func (q Quat) Rotate(other Quat) Quat
- func (q Quat) RotateVec(v Vec3f) Vec3f
- func (q Quat) RotateX(rad float32) Quat
- func (q Quat) RotateY(rad float32) Quat
- func (q Quat) RotateZ(rad float32) Quat
- func (q Quat) Slerp(other Quat, t float32) Quat
- func (q Quat) SquareLength() float32
- func (q Quat) String() string
- func (q Quat) Sub(other Quat) Quat
- func (q Quat) SubScalar(s float32) Quat
- func (q Quat) ToEuler() (yaw, pitch, roll float32)
- func (q Quat) Up() Vec3f
- func (q Quat) Vec4f() Vec4f
- type Rectf
- func (r Rectf) Add(v Vec2f) Rectf
- func (r Rectf) Area() float32
- func (r Rectf) Bottom() float32
- func (r Rectf) ContainsPoint(point Vec2f) bool
- func (r Rectf) ContainsRectf(other Rectf) bool
- func (r Rectf) Intersects(other Rectf) bool
- func (r Rectf) Left() float32
- func (r Rectf) Merge(other Rectf) Rectf
- func (r Rectf) Normalize() Rectf
- func (r Rectf) PointDistance(pos Vec2f) float32
- func (r Rectf) Recti() Recti
- func (r Rectf) Right() float32
- func (r Rectf) Round() Recti
- func (r Rectf) SetPos(pos Vec2f)
- func (r Rectf) SetSize(size Vec2f)
- func (r Rectf) Size() Vec2f
- func (r Rectf) SquarePointDistance(pos Vec2f) float32
- func (r Rectf) String() string
- func (r Rectf) Sub(v Vec2f) Rectf
- func (r Rectf) Top() float32
- type Recti
- func (r Recti) Add(v Vec2i) Recti
- func (r Recti) Area() int
- func (r Recti) Bottom() int
- func (r Recti) ContainsPoint(point Vec2i) bool
- func (r Recti) ContainsRecti(other Recti) bool
- func (r Recti) Left() int
- func (r Recti) Merge(other Recti) Recti
- func (r Recti) Normalize() Recti
- func (r Recti) Overlaps(other Recti) bool
- func (r Recti) OverlapsOrTouches(other Recti) bool
- func (r Recti) PointDistance(pos Vec2i) float32
- func (r Recti) Rectf() Rectf
- func (r Recti) Right() int
- func (r Recti) SetPos(pos Vec2i)
- func (r Recti) SetSize(size Vec2i)
- func (r *Recti) Size() Vec2i
- func (r Recti) SquarePointDistance(pos Vec2i) int
- func (r Recti) String() string
- func (r Recti) Sub(v Vec2i) Recti
- func (r Recti) Top() int
- type Vec2f
- func (v Vec2f) Abs() Vec2f
- func (v Vec2f) Add(other Vec2f) Vec2f
- func (v Vec2f) AddScalar(s float32) Vec2f
- func (v Vec2f) Angle(other Vec2f) float32
- func (v Vec2f) Clamp(min, max float32) Vec2f
- func (v Vec2f) Distance(other Vec2f) float32
- func (v Vec2f) Div(other Vec2f) Vec2f
- func (v Vec2f) DivScalar(s float32) Vec2f
- func (v Vec2f) Dot(other Vec2f) float32
- func (v Vec2f) Equal(other Vec2f) bool
- func (v Vec2f) EqualEps(other Vec2f, epsilon float32) bool
- func (v Vec2f) FlatAngle() float32
- func (v Vec2f) Format(format string) string
- func (v Vec2f) IsCollinear(other Vec2f) bool
- func (v Vec2f) IsCollinearEps(other Vec2f, eps float32) bool
- func (v Vec2f) IsOrthogonal() bool
- func (v Vec2f) IsParallel(other Vec2f) bool
- func (v Vec2f) IsParallelEps(other Vec2f, eps float32) bool
- func (v Vec2f) IsZero() bool
- func (v Vec2f) Length() float32
- func (v Vec2f) Lerp(other Vec2f, t float32) Vec2f
- func (v Vec2f) MagCross(other Vec2f) float32
- func (v Vec2f) Mul(other Vec2f) Vec2f
- func (v Vec2f) MulScalar(s float32) Vec2f
- func (v Vec2f) Negate() Vec2f
- func (v Vec2f) NormalVec(onLeft bool) Vec2f
- func (v Vec2f) Normalize() Vec2f
- func (v Vec2f) Project(other Vec2f) Vec2f
- func (v Vec2f) Rotate(rad float32) Vec2f
- func (v Vec2f) Round() Vec2i
- func (v Vec2f) Split() (x, y float32)
- func (v Vec2f) SquareDistance(other Vec2f) float32
- func (v Vec2f) SquareLength() float32
- func (v Vec2f) String() string
- func (v Vec2f) Sub(other Vec2f) Vec2f
- func (v Vec2f) SubScalar(s float32) Vec2f
- func (v Vec2f) Vec2i() Vec2i
- func (v Vec2f) Vec3f(z float32) Vec3f
- func (v Vec2f) Vec4f(z, w float32) Vec4f
- func (v Vec2f) X() float32
- func (v Vec2f) Y() float32
- type Vec2i
- func (v Vec2i) Abs() Vec2i
- func (v Vec2i) Add(other Vec2i) Vec2i
- func (v Vec2i) AddScalar(s int) Vec2i
- func (v Vec2i) AddScalarf(s float32) Vec2f
- func (v Vec2i) Clamp(min, max int) Vec2i
- func (v Vec2i) Distance(other Vec2i) float32
- func (v Vec2i) Div(other Vec2i) Vec2i
- func (v Vec2i) DivScalar(s int) Vec2i
- func (v Vec2i) DivScalarf(s float32) Vec2f
- func (v Vec2i) Dot(other Vec2i) int
- func (v Vec2i) Equal(other Vec2i) bool
- func (v Vec2i) Format(format string) string
- func (v Vec2i) IsCollinear(other Vec2i) bool
- func (v Vec2i) IsOrthogonal() bool
- func (v Vec2i) IsParallel(other Vec2i) bool
- func (v Vec2i) IsZero() bool
- func (v Vec2i) Length() float32
- func (v Vec2i) MagCross(other Vec2i) int
- func (v Vec2i) Mul(other Vec2i) Vec2i
- func (v Vec2i) MulScalar(s int) Vec2i
- func (v Vec2i) MulScalarf(s float32) Vec2f
- func (v Vec2i) Negate() Vec2i
- func (v Vec2i) NormalVec(onLeft bool) Vec2i
- func (v Vec2i) Project(other Vec2i) Vec2f
- func (v Vec2i) Split() (x, y int)
- func (v Vec2i) SquareDistance(other Vec2i) int
- func (v Vec2i) SquareLength() int
- func (v Vec2i) String() string
- func (v Vec2i) Sub(other Vec2i) Vec2i
- func (v Vec2i) SubScalar(s int) Vec2i
- func (v Vec2i) SubScalarf(s float32) Vec2f
- func (v Vec2i) Vec2f() Vec2f
- func (v Vec2i) Vec3i(z int) Vec3i
- func (v Vec2i) Vec4i(z, w int) Vec4i
- func (v Vec2i) X() int
- func (v Vec2i) Y() int
- type Vec3f
- func (v Vec3f) Abs() Vec3f
- func (v Vec3f) Add(other Vec3f) Vec3f
- func (v Vec3f) AddScalar(s float32) Vec3f
- func (v Vec3f) Angle(other Vec3f) float32
- func (v Vec3f) Clamp(min, max float32) Vec3f
- func (v Vec3f) Cross(other Vec3f) Vec3f
- func (v Vec3f) Distance(other Vec3f) float32
- func (v Vec3f) Div(other Vec3f) Vec3f
- func (v Vec3f) DivScalar(s float32) Vec3f
- func (v Vec3f) Dot(other Vec3f) float32
- func (v Vec3f) Equal(other Vec3f) bool
- func (v Vec3f) EqualEps(other Vec3f, epsilon float32) bool
- func (v Vec3f) Format(format string) string
- func (v Vec3f) IsCollinear(other Vec3f) bool
- func (v Vec3f) IsCollinearEps(other Vec3f, eps float32) bool
- func (v Vec3f) IsOrthogonal() bool
- func (v Vec3f) IsParallel(other Vec3f) bool
- func (v Vec3f) IsParallelEps(other Vec3f, eps float32) bool
- func (v Vec3f) IsZero() bool
- func (v Vec3f) Length() float32
- func (v Vec3f) Lerp(other Vec3f, t float32) Vec3f
- func (v Vec3f) Mul(other Vec3f) Vec3f
- func (v Vec3f) MulScalar(s float32) Vec3f
- func (v Vec3f) Negate() Vec3f
- func (v Vec3f) Normalize() Vec3f
- func (v Vec3f) Project(other Vec3f) Vec3f
- func (v Vec3f) RotateX(origin Vec3f, rad float32) Vec3f
- func (v Vec3f) RotateY(origin Vec3f, rad float32) Vec3f
- func (v Vec3f) RotateZ(origin Vec3f, rad float32) Vec3f
- func (v Vec3f) RotationTo(dest Vec3f) Quat
- func (v Vec3f) Round() Vec3i
- func (v Vec3f) Split() (x, y, z float32)
- func (v Vec3f) SquareDistance(other Vec3f) float32
- func (v Vec3f) SquareLength() float32
- func (v Vec3f) String() string
- func (v Vec3f) Sub(other Vec3f) Vec3f
- func (v Vec3f) SubScalar(s float32) Vec3f
- func (v Vec3f) Vec3i() Vec3i
- func (v Vec3f) Vec4f(w float32) Vec4f
- func (v Vec3f) X() float32
- func (v Vec3f) XY() Vec2f
- func (v Vec3f) Y() float32
- func (v Vec3f) Z() float32
- type Vec3i
- func (v Vec3i) Abs() Vec3i
- func (v Vec3i) Add(other Vec3i) Vec3i
- func (v Vec3i) AddScalar(s int) Vec3i
- func (v Vec3i) AddScalarf(s float32) Vec3f
- func (v Vec3i) Clamp(min, max int) Vec3i
- func (v Vec3i) Cross(other Vec3i) Vec3i
- func (v Vec3i) Distance(other Vec3i) float32
- func (v Vec3i) Div(other Vec3i) Vec3i
- func (v Vec3i) DivScalar(s int) Vec3i
- func (v Vec3i) DivScalarf(s float32) Vec3f
- func (v Vec3i) Dot(other Vec3i) int
- func (v Vec3i) Equal(other Vec3i) bool
- func (v Vec3i) Format(format string) string
- func (v Vec3i) IsCollinear(other Vec3i) bool
- func (v Vec3i) IsOrthogonal() bool
- func (v Vec3i) IsParallel(other Vec3i) bool
- func (v Vec3i) IsZero() bool
- func (v Vec3i) Length() float32
- func (v Vec3i) Mul(other Vec3i) Vec3i
- func (v Vec3i) MulScalar(s int) Vec3i
- func (v Vec3i) MulScalarf(s float32) Vec3f
- func (v Vec3i) Negate() Vec3i
- func (v Vec3i) Split() (x, y, z int)
- func (v Vec3i) SquareDistance(other Vec3i) int
- func (v Vec3i) SquareLength() int
- func (v Vec3i) String() string
- func (v Vec3i) Sub(other Vec3i) Vec3i
- func (v Vec3i) SubScalar(s int) Vec3i
- func (v Vec3i) SubScalarf(s float32) Vec3f
- func (v Vec3i) Vec3f() Vec3f
- func (v Vec3i) Vec4i(w int) Vec4i
- func (v Vec3i) X() int
- func (v Vec3i) XY() Vec2i
- func (v Vec3i) Y() int
- func (v Vec3i) Z() int
- type Vec4f
- func (v Vec4f) Abs() Vec4f
- func (v Vec4f) Add(other Vec4f) Vec4f
- func (v Vec4f) AddScalar(s float32) Vec4f
- func (v Vec4f) Clamp(min, max float32) Vec4f
- func (v Vec4f) Distance(other Vec4f) float32
- func (v Vec4f) Div(other Vec4f) Vec4f
- func (v Vec4f) DivScalar(s float32) Vec4f
- func (v Vec4f) Dot(other Vec4f) float32
- func (v Vec4f) Equal(other Vec4f) bool
- func (v Vec4f) EqualEps(other Vec4f, epsilon float32) bool
- func (v Vec4f) Format(format string) string
- func (v Vec4f) IsZero() bool
- func (v Vec4f) Length() float32
- func (v Vec4f) Lerp(other Vec4f, t float32) Vec4f
- func (v Vec4f) Mul(other Vec4f) Vec4f
- func (v Vec4f) MulScalar(s float32) Vec4f
- func (v Vec4f) Negate() Vec4f
- func (v Vec4f) Normalize() Vec4f
- func (v Vec4f) Project(other Vec4f) Vec4f
- func (v Vec4f) Round() Vec4i
- func (v Vec4f) Split() (x, y, z, w float32)
- func (v Vec4f) SquareDistance(other Vec4f) float32
- func (v Vec4f) SquareLength() float32
- func (v Vec4f) String() string
- func (v Vec4f) Sub(other Vec4f) Vec4f
- func (v Vec4f) SubScalar(s float32) Vec4f
- func (v Vec4f) Vec4i() Vec4i
- func (v Vec4f) W() float32
- func (v Vec4f) X() float32
- func (v Vec4f) XY() Vec2f
- func (v Vec4f) XYZ() Vec3f
- func (v Vec4f) Y() float32
- func (v Vec4f) Z() float32
- type Vec4i
- func (v Vec4i) Abs() Vec4i
- func (v Vec4i) Add(other Vec4i) Vec4i
- func (v Vec4i) AddScalar(s int) Vec4i
- func (v Vec4i) Clamp(min, max int) Vec4i
- func (v Vec4i) Distance(other Vec4i) float32
- func (v Vec4i) Div(other Vec4i) Vec4i
- func (v Vec4i) DivScalar(s int) Vec4i
- func (v Vec4i) Dot(other Vec4i) int
- func (v Vec4i) Equal(other Vec4i) bool
- func (v Vec4i) Format(format string) string
- func (v Vec4i) IsZero() bool
- func (v Vec4i) Length() float32
- func (v Vec4i) Mul(other Vec4i) Vec4i
- func (v Vec4i) MulScalar(s int) Vec4i
- func (v Vec4i) Negate() Vec4i
- func (v Vec4i) Split() (x, y, z, w int)
- func (v Vec4i) SquareDistance(other Vec4i) int
- func (v Vec4i) SquareLength() int
- func (v Vec4i) String() string
- func (v Vec4i) Sub(other Vec4i) Vec4i
- func (v Vec4i) SubScalar(s int) Vec4i
- func (v Vec4i) Vec4f() Vec4f
- func (v Vec4i) W() int
- func (v Vec4i) X() int
- func (v Vec4i) XY() Vec2i
- func (v Vec4i) XYZ() Vec3i
- func (v Vec4i) Y() int
- func (v Vec4i) Z() int
Constants ¶
const Epsilon = 1.0E-6
Epsilon is the default epsilon value for float comparisons.
Variables ¶
This section is empty.
Functions ¶
func CartesianToSpherical ¶
CartesianToSpherical converts cartesian coordinates into spherical coordinates. Returns the radius, azimuth (angle on XY-plane) and inclination.
func EqualEps ¶
Equalf compares two floats for equality, using the given epsilon as the relative tolerance. Performs a relative difference comparison (see https://floating-point-gui.de/errors/comparison/ and https://stackoverflow.com/q/4915462/2224996)
func Equalf ¶
Equalf compares two floats for equality. Uses the default Epsilon as relative tolerance.
func IsPointOnLeft ¶
IsPointOnLeft returns true if the give point lies to the left of line a->b; If the point lies directly on the line, false is returned.
func IsPointOnLine ¶
IsPointOnLine returns true if the give point lies to the line a->b; Uses the default Epsilon as relative tolerance.
func IsPointOnLineEps ¶
IsPointOnLine returns true if the give point lies to the line a->b; Uses the given Epsilon as relative tolerance.
func Lerp ¶
Lerp performs a linear interpolation between a and b. The parameter t should be in range [0, 1].
func NormalizeDegrees ¶
NormalizeDegrees returns the angle in degrees in the range [0, 360[.
func NormalizeRadians ¶
NormalizeRadians returns the angle in radians in the range [0, 2*PI[.
func PointToLineDistance2D ¶
PointToLineDistance2D returns the distance between a point and an infinitely long line passing through a and b.
func PointToLineSegmentDistance2D ¶
PointToLineSegmentDistance2D returns the distance between a point and a line segment between a and b.
Types ¶
type Mat2f ¶
type Mat2f [4]float32
Mat2f is a 2x2 float32 matrix. Values are stored in column major order: [<col0>, <col1>]
func Mat2fFromCols ¶
Mat2fFromCols creates a new 2x2 matrix from column vectors.
func Mat2fFromRows ¶
Mat2fFromRows creates a new 2x2 matrix from row vectors.
func (Mat2f) Equal ¶
Equal compares two matrices component-wise. Uses the default Epsilon as relative tolerance.
func (Mat2f) EqualEps ¶
Equal compares two matrices component-wise, using the given epsilon as a relative tolerance.
func (Mat2f) Inverse ¶
Inverse calculates the inverse matrix. If the matrix cannot be inverted (singular), the identity matrix and false is returned.
func (Mat2f) Mat3f ¶
Mat3f extends the matrix to 3x3. The diagonal cell is set to 1, all other values are 0.
func (Mat2f) Mat4f ¶
Mat4f extends the matrix to 4x4. The diagonal cells are set to 1, all other values are 0.
type Mat3f ¶
type Mat3f [9]float32
Mat3f is a 3x3 float32 matrix. Values are stored in column major order: [<col0>, <col1>, <col2>]
0, 3, 6 1, 4, 7 2, 5, 8
func Mat3fFromCols ¶
Mat3fFromCols creates a new 3x3 matrix from column vectors.
func Mat3fFromRows ¶
Mat3fFromCols creates a new 3x3 matrix from row vectors.
func (Mat3f) Equal ¶
Equal compares two matrices component-wise. Uses the default Epsilon as relative tolerance.
func (Mat3f) EqualEps ¶
Equal compares two matrices component-wise, using the given epsilon as a relative tolerance.
func (Mat3f) Inverse ¶
Inverse calculates the inverse matrix. If the matrix cannot be inverted (singular), the identity matrix and false is returned.
func (Mat3f) InverseTranspose ¶
InverseTranspose inverts and transposes the matrix in a single step. If the matrix cannot be inverted (singular), the identity matrix and false is returned.
func (Mat3f) Mat4f ¶
Mat4f extends the matrix to 4x4. The diagonal cell is set to 1, all other values are 0.
type Mat4f ¶
type Mat4f [16]float32
Mat4f is a 4x4 float32 matrix. Values are stored in column major order: [<col0>, <col1>, <col2>, <col4>]
0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15
func LookAt ¶
LookAt returns a transformation matrix for a viewer, looking towards the target, with a defined upwards vector.
func Mat4fFromCols ¶
Mat4fFromCols creates a new 4x4 matrix from column vectors.
func Mat4fFromRotation ¶
Mat4fFromRotation creates a new 4x4 matrix, representing a rotation around a given axis.
func Mat4fFromRotationTranslation ¶
Mat4fFromRotationTranslation creates a new 4x4 matrix, representing a rotation and translation.
func Mat4fFromRotationTranslationScale ¶
Mat4fFromRotationTranslationScale creates a new 4x4 matrix, representing a rotation, translation and scaling.
func Mat4fFromRotationTranslationScaleOrigin ¶
Mat4fFromRotationTranslationScale creates a new 4x4 matrix, representing a rotation, translation and scaling. Rotation and scaling is performed around the given origin.
func Mat4fFromRows ¶
Mat4fFromRows creates a new 4x4 matrix from row vectors.
func Mat4fFromScaling ¶
Mat4fFromScaling returns a 4x4 matrix with the given scaling.
func Mat4fFromTranslation ¶
Mat4fFromTranslation returns the 4x4 matrix with the given translation vector.
func Mat4fFromXRotation ¶
Mat4fFromXRotation returns the 4x4 matrix with a rotation around the X-axis.
func Mat4fFromYRotation ¶
Mat4fFromYRotation returns the 4x4 matrix with a rotation around the Y-axis.
func Mat4fFromZRotation ¶
Mat4fFromZRotation returns the 4x4 matrix with a rotation around the Z-axis.
func Perspective ¶
Perspective returns a perspective projection matrix. The field-of-view is in radians.
func (Mat4f) Equal ¶
Equal compares two matrices component-wise. Uses the default Epsilon as relative tolerance.
func (Mat4f) EqualEps ¶
Equal compares two matrices component-wise, using the given epsilon as a relative tolerance.
func (Mat4f) Inverse ¶
Inverse calculates the inverse matrix. If the matrix cannot be inverted (singular), the identity matrix and false is returned.
func (Mat4f) InverseAffine ¶
InverseAffine calculates the inverse of an affine matrix. If the matrix cannot be inverted (singular), the identity matrix and false is returned.
func (Mat4f) InverseTranspose ¶
InverseTranspose inverts and transposes the matrix in a single step. If the matrix cannot be inverted (singular), the identity matrix and false is returned.
func (Mat4f) Mat2f ¶
Mat2f shrinks the matrix to 2x2. The right columns and bottom rows are removed.
func (Mat4f) SetScaling ¶
SetScaling sets the scaling of the matrix.
func (Mat4f) SetTranslation ¶
SetTranslation sets the translation vector of the matrix.
func (Mat4f) Translation ¶
Translation returns the translation vector of the matrix.
type MatStack4f ¶
type MatStack4f struct {
// contains filtered or unexported fields
}
MatStack4f represents a stack of 4x4 matrices.
func NewMatStack4f ¶
func NewMatStack4f() *MatStack4f
NewMatStack4f creates a new matrix stack containing only the identity matrix.
func (*MatStack4f) MulLeft ¶
func (m *MatStack4f) MulLeft(mat Mat4f)
MulLeft multiplies the given matrix with the top element and overwrites the top element with the result.
func (*MatStack4f) MulRight ¶
func (m *MatStack4f) MulRight(mat Mat4f)
MulRight multiplies the top element with the given matrix.
func (*MatStack4f) Pop ¶
func (m *MatStack4f) Pop() error
Pop removes the current top element from the stack. Returns an error if the stack contains only one element.
func (*MatStack4f) Push ¶
func (m *MatStack4f) Push()
Push stores the current top on the stack by duplicating it.
func (*MatStack4f) PushIdent ¶
func (m *MatStack4f) PushIdent()
PushIdent is equivalent to Push(), SetIdent().
func (*MatStack4f) PushMulLeft ¶
func (m *MatStack4f) PushMulLeft(mat Mat4f)
PushMulLeft is equivalent to Push(), MulLeft().
func (*MatStack4f) PushMulRight ¶
func (m *MatStack4f) PushMulRight(mat Mat4f)
PushMulRight is equivalent to Push(), MulRight().
func (*MatStack4f) PushSet ¶
func (m *MatStack4f) PushSet(mat Mat4f)
PushSet is equivalent to Push(), Set().
func (*MatStack4f) Set ¶
func (m *MatStack4f) Set(mat Mat4f)
Set overwrites the top element with a new matrix.
func (*MatStack4f) SetIdent ¶
func (m *MatStack4f) SetIdent()
SetIdent overwrites the top element with the identity matrix.
func (MatStack4f) Size ¶
func (m MatStack4f) Size() int
Size returns the current size of the matrix stack
func (MatStack4f) Top ¶
func (m MatStack4f) Top() Mat4f
Top returns the current top element without modifying the stack.
type Quat ¶
Quat represents a Quaternion.
func QuatFromAxisAngle ¶
QuatFromAxisAngle returns a quaternion representing a rotation around a given axis.
func QuatFromEuler ¶
QuatFromEuler returns a quaternion based on the given euler rotations. Axis: yaw: Z, pitch: Y, roll: X
func (Quat) AngleTo ¶
AngleTo returns the angle between two quaternions by comparing one of their axis.
func (Quat) Axis ¶
Axis returns the quaternion's rotation axis. The returned axis is not normalized. If there is no rotation, the axis can be zero.
func (Quat) AxisRotation ¶
AxisRotation returns the quaternion's rotation angle and axis.
func (Quat) Conjugate ¶
Conjugate returns the conjugated quaternion. This is a rotation with the same angle, but the axis is mirrored.
func (Quat) Equals ¶
Equals compares two quaternions. Uses the default Epsilon as relative tolerance.
func (Quat) EqualsEps ¶
EqualsEps compares two quaternions, using the given epsilon as a relative tolerance.
func (Quat) Inverse ¶
Inverse returns the inverse quaternion. This is the rotation around the same axis, but in the opposite direction.
func (Quat) Lerp ¶
Lerp performs a linear interpolation to another quaternion. The parameter t should be in range [0, 1].
func (Quat) Slerp ¶
Slerp performs a spherical linear interpolation to another quaternion. The parameter t should be in range [0, 1].
func (Quat) SquareLength ¶
SquareLength returns the quaternion's squared length.
func (Quat) ToEuler ¶
ToEuler converts the quaternion into euler rotations. Axis: yaw: Z, pitch: Y, roll: X
type Rectf ¶
Rectf represents a 2D, axis-aligned rectangle.
func RectfFromCorners ¶
RectfFromCorners creates a new rectangle given two opposite corners. If necessary, coordinates are swapped to create a normalized rectangle.
func RectfFromEdges ¶
RectfFromEdges creates a new rectangle with the given edge positions. If necessary, edges are swapped to create a normalized rectangle.
func RectfFromPosSize ¶
RectfFromPosSize creates a new rectangle with the given size and position. Negative dimensions are inverted to create a normalized rectangle.
func (Rectf) Add ¶
Add moves the rectangle with the given vector by adding it to the min- and max- components.
func (Rectf) ContainsPoint ¶
ContainsPoint checks if a given point resides within the rectangle. If the point is on an edge, it is also considered to be contained within the rectangle.
func (Rectf) ContainsRectf ¶
ContainsRectf checks if this rectangle completely contains another rectangle.
func (Rectf) Intersects ¶
Intersects checks if this rectangle intersects another rectangle. Touching rectangles where floats are exactly equal are not considered to intersect.
func (Rectf) Normalize ¶
Normalize ensures that the Min position is smaller than the Max position in every dimension.
func (Rectf) PointDistance ¶
PointDistance returns the distance between the rectangle and a point. If the point is contained within the rectangle, 0 is returned. Otherwise, the distance between the point and the nearest edge or corner is returned.
func (Rectf) Recti ¶
Recti returns an integer representation of the rectangle. Decimals are truncated.
func (Rectf) Round ¶
Round returns an integer representation of the rectangle. Decimals are rounded.
func (Rectf) SetPos ¶
SetPos changes the rectangle position by modifying min, but keeps the rectangle's size.
func (Rectf) SquarePointDistance ¶
SquarePointDistance returns the squared distance between the rectangle and a point. If the point is contained within the rectangle, 0 is returned. Otherwise, the squared distance between the point and the nearest edge or corner is returned.
type Recti ¶
Recti represents a 2D, axis-aligned rectangle.
func RectiFromCorners ¶
RectiFromCorners creates a new rectangle given two opposite corners.
func RectiFromEdges ¶
RectfFromEdges creates a new rectangle with the given edge positions.
func RectiFromPosSize ¶
RectiFromPosSize creates a new rectangle with the given size and position. Negative dimensions are correctly inverted.
func (Recti) Add ¶
Add moves the rectangle with the given vector by adding it to the min- and max- components.
func (Recti) ContainsPoint ¶
Contains checks if a given point resides within the rectangle. If the point is on an edge, it is also considered to be contained within the rectangle.
func (Recti) ContainsRecti ¶
ContainsRecti checks if this rectangle completely contains another rectangle.
func (Recti) Normalize ¶
Normalize ensures that the Min position is smaller than the Max position in every dimension.
func (Recti) Overlaps ¶
Overlaps checks if this rectangle overlaps another rectangle. Touching rectangles where floats are exactly equal are not considered to overlap.
func (Recti) OverlapsOrTouches ¶
OverlapsOrTouches checks if this rectangle overlaps or touches another rectangle.
func (Recti) PointDistance ¶
PointDistance returns the distance between the rectangle and a point. If the point is contained within the rectangle, 0 is returned. Otherwise, the distance between the point and the nearest edge or corner is returned.
func (Recti) SetPos ¶
SetPos changes the rectangle position by modifying min, but keeps the rectangle's size.
func (Recti) SquarePointDistance ¶
SquarePointDistance returns the squared distance between the rectangle and a point. If the point is contained within the rectangle, 0 is returned. Otherwise, the squared distance between the point and the nearest edge or corner is returned.
type Vec2f ¶
type Vec2f [2]float32
func AngleToVector ¶
AngleToVector returns a 2D vector with the given length and angle to the x-axis.
func PolarToCartesian2D ¶
PolarToCartesian2D converts length and angle into a 2D position.
func (Vec2f) Equal ¶
Equal compares two vectors component-wise. Uses the default Epsilon as relative tolerance.
func (Vec2f) EqualEps ¶
EqualEps compares two vectors component-wise, using the given epsilon as a relative tolerance.
func (Vec2f) FlatAngle ¶
FlatAngle returns the angle of a vector in radians. This is the angle between the vector and the x-axis.
func (Vec2f) IsCollinear ¶
IsCollinear returns true if the given vector is collinear (pointing in the same direction). Uses the given Epsilon as relative tolerance.
func (Vec2f) IsCollinearEps ¶
IsCollinearEps returns true if the given vector is collinear (pointing in the same direction). Uses the given Epsilon as relative tolerance.
func (Vec2f) IsOrthogonal ¶
IsOrthogonal returns true if the vector is horizontal or vertical (one of its components is zero).
func (Vec2f) IsParallel ¶
IsParallel returns true if the given vector is parallel. Vectors that point in opposite directions are also parallel. Uses the default Epsilon as relative tolerance.
func (Vec2f) IsParallelEps ¶
IsParallel returns true if the given vector is parallel. Vectors that point in opposite directions are also parallel. Uses the given Epsilon as relative tolerance.
func (Vec2f) IsZero ¶
IsZero returns true if all components are zero. Uses the default Epsilon as relative tolerance.
func (Vec2f) Lerp ¶
Lerp performs a linear interpolation between two vectors. The parameter t should be in range [0, 1].
func (Vec2f) MagCross ¶
MagCross returns the length of the cross product vector. This is equal to the magnitude of a 3D cross product vector, with the Z position implicitly set to zero. It represents twice the signed area between the two vectors.
func (Vec2f) NormalVec ¶
NormalVec returns a normal vector on the 2D plane that is either on the left or right hand side.
func (Vec2f) Normalize ¶
Normalize the vector. Its length will be 1 afterwards. If the vector's length is zero, a zero vector will be returned.
func (Vec2f) Project ¶
Project returns a vector representing the projection of vector v onto "other".
func (Vec2f) SquareDistance ¶
SquareDistance returns the squared euclidean distance to another position.
func (Vec2f) SquareLength ¶
SquareLength returns the vector's squared length.
type Vec2i ¶
type Vec2i [2]int
func (Vec2i) AddScalarf ¶
AddScalarf performs a scalar addition.
func (Vec2i) DivScalarf ¶
DivScalarf performs a scalar division.
func (Vec2i) IsCollinear ¶
IsCollinear returns true if the given vector is collinear (pointing in the same direction).
func (Vec2i) IsOrthogonal ¶
IsOrthogonal returns true if the vector is horizontal or vertical (one of its components is zero).
func (Vec2i) IsParallel ¶
IsParallel returns true if the given vector is parallel. Vectors that point in opposite directions are also parallel (but not collinear).
func (Vec2i) MagCross ¶
MagCross returns the length of the cross product vector. This is equal to the magnitude of a 3D cross product vector, with the Z position implicitly set to zero. It represents twice the signed area between the two vectors.
func (Vec2i) MulScalarf ¶
MulScalar performs a scalar multiplication.
func (Vec2i) NormalVec ¶
NormalVec returns a normal vector on the 2D plane that is either on the left or right hand side.
func (Vec2i) Project ¶
Project returns a vector representing the projection of vector v onto "other".
func (Vec2i) SquareDistance ¶
SquareDistance returns the squared euclidean distance to another position.
func (Vec2i) SquareLength ¶
SquareLength returns the vector's squared length.
func (Vec2i) SubScalarf ¶
SubScalarf performs a scalar subtraction.
type Vec3f ¶
type Vec3f [3]float32
func SphericalToCartesian ¶
SphericalToCartesian converts spherical coordinates into cartesian coordinates.
func (Vec3f) Equal ¶
Equal compares two vectors component-wise. Uses the default Epsilon as relative tolerance.
func (Vec3f) EqualEps ¶
EqualEps compares two vectors component-wise, using the given epsilon as a relative tolerance.
func (Vec3f) IsCollinear ¶
IsCollinear returns true if the given vector is collinear (pointing in the same direction). Uses the given Epsilon as relative tolerance.
func (Vec3f) IsCollinearEps ¶
IsCollinearEps returns true if the given vector is collinear (pointing in the same direction). Uses the given Epsilon as relative tolerance.
func (Vec3f) IsOrthogonal ¶
IsOrthogonal returns true if the vector is parallel to the X, Y or Z axis (one of its components is zero).
func (Vec3f) IsParallel ¶
IsParallel returns true if the given vector is parallel. Vectors that point in opposite directions are also parallel. Uses the default Epsilon as relative tolerance.
func (Vec3f) IsParallelEps ¶
IsParallel returns true if the given vector is parallel. Vectors that point in opposite directions are also parallel. Uses the given Epsilon as relative tolerance.
func (Vec3f) IsZero ¶
IsZero returns true if all components are zero. Uses the default Epsilon as relative tolerance.
func (Vec3f) Lerp ¶
Lerp performs a linear interpolation between two vectors. The parameter t should be in range [0, 1].
func (Vec3f) Normalize ¶
Normalize the vector. Its length will be 1 afterwards. If the vector's length is zero, a zero vector will be returned.
func (Vec3f) Project ¶
Project returns a vector representing the projection of vector v onto "other".
func (Vec3f) RotationTo ¶
RotationTo returns the shortest rotation to the destination vector.
func (Vec3f) SquareDistance ¶
SquareDistance returns the squared euclidean distance to another position.
func (Vec3f) SquareLength ¶
SquareLength returns the vector's squared length.
type Vec3i ¶
type Vec3i [3]int
func (Vec3i) AddScalarf ¶
AddScalarf performs a scalar addition.
func (Vec3i) DivScalarf ¶
DivScalarf performs a scalar division.
func (Vec3i) IsCollinear ¶
IsCollinear returns true if the given vector is collinear (pointing in the same direction). Uses the given Epsilon as relative tolerance.
func (Vec3i) IsOrthogonal ¶ added in v0.2.0
IsOrthogonal returns true if the vector is parallel to the X, Y or Z axis (one of its components is zero).
func (Vec3i) IsParallel ¶
IsParallel returns true if the given vector is parallel. Vectors that point in opposite directions are also parallel (but not collinear).
func (Vec3i) MulScalarf ¶
MulScalar performs a scalar multiplication.
func (Vec3i) SquareDistance ¶
SquareDistance returns the squared euclidean distance to another position.
func (Vec3i) SquareLength ¶
SquareLength returns the vector's squared length.
func (Vec3i) SubScalarf ¶
SubScalarf performs a scalar subtraction.
type Vec4f ¶
type Vec4f [4]float32
func (Vec4f) Equal ¶
Equal compares two vectors component-wise. Uses the default Epsilon as relative tolerance.
func (Vec4f) EqualEps ¶
EqualEps compares two vectors component-wise, using the given epsilon as a relative tolerance.
func (Vec4f) IsZero ¶
IsZero returns true if all components are zero. Uses the default Epsilon as relative tolerance.
func (Vec4f) Lerp ¶
Lerp performs a linear interpolation between two vectors. The parameter t should be in range [0, 1].
func (Vec4f) Normalize ¶
Normalize the vector. Its length will be 1 afterwards. If the vector's length is zero, a zero vector will be returned.
func (Vec4f) Project ¶
Project returns a vector representing the projection of vector v onto "other".
func (Vec4f) SquareDistance ¶
SquareDistance returns the squared euclidean distance to another position.
func (Vec4f) SquareLength ¶
SquareLength returns the vector's squared length.
type Vec4i ¶
type Vec4i [4]int
func (Vec4i) SquareDistance ¶
SquareDistance returns the squared euclidean distance to another position.
func (Vec4i) SquareLength ¶
SquareLength returns the vector's squared length.