Documentation ¶
Overview ¶
math32 is our version of the G3N math32 32-bit, 3D rendering-based math library.
Initially copied from G3N: github.com/g3n/engine/math32 Copyright 2016 The G3N Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
A major modification from the G3N version is to use value-based logic instead of pointer-based self-modification in the Vector classes, As used in e.g., go-gl/mathgl (which uses slice-based vectors instead of the more intuitive and likely more efficient struct-based ones here).
The pointer-based approach was retained for the Matrix classes, which are larger and that is likely more performant.
Many names were shortened, consistent with more idiomatic Go naming. and again with the go-gl/mathgl library
Package math32 is a float32 based vector, matrix, and math package for 2D & 3D graphics.
Index ¶
- Constants
- Variables
- func Abs(x float32) float32
- func Acos(x float32) float32
- func Acosh(x float32) float32
- func Asin(x float32) float32
- func Asinh(x float32) float32
- func Atan(x float32) float32
- func Atan2(y, x float32) float32
- func Atanh(x float32) float32
- func Cbrt(x float32) float32
- func Ceil(x float32) float32
- func Clamp(x, a, b float32) float32
- func ClampInt(x, a, b int) int
- func ContainsPoint(point, a, b, c Vector3) bool
- func CopyFloat32s(trg *[]float32, src []float32)
- func CopyFloat64s(trg *[]float64, src []float64)
- func Copysign(f, sign float32) float32
- func Cos(x float32) float32
- func Cosh(x float32) float32
- func DegToRad(degrees float32) float32
- func Dim(x, y float32) float32
- func Erf(x float32) float32
- func Erfc(x float32) float32
- func Erfcinv(x float32) float32
- func Erfinv(x float32) float32
- func Exp(x float32) float32
- func Exp2(x float32) float32
- func Expm1(x float32) float32
- func FMA(x, y, z float32) float32
- func FastExp(x float32) float32
- func FitGeomInWindow(stPos, stSz, winPos, winSz int) (pos, sz int)
- func Floor(x float32) float32
- func Frexp(f float32) (frac float32, exp int)
- func FromFixed(x fixed.Int26_6) float32
- func Gamma(x float32) float32
- func Hypot(p, q float32) float32
- func Ilogb(x float32) float32
- func Inf(sign int) float32
- func IntMultiple(val, mod float32) float32
- func IntMultipleGE(val, mod float32) float32
- func IsInf(x float32, sign int) bool
- func IsNaN(x float32) bool
- func J0(x float32) float32
- func J1(x float32) float32
- func Jn(n int, x float32) float32
- func Ldexp(frac float32, exp int) float32
- func Lerp(start, stop, amount float32) float32
- func Lgamma(x float32) (lgamma float32, sign int)
- func Log(x float32) float32
- func Log10(x float32) float32
- func Log1p(x float32) float32
- func Log2(x float32) float32
- func Logb(x float32) float32
- func Max(x, y float32) float32
- func MaxPos(a, b float32) float32
- func Min(x, y float32) float32
- func MinPos(a, b float32) float32
- func Mod(x, y float32) float32
- func Modf(f float32) (it float32, frac float32)
- func NaN() float32
- func Nextafter(x, y float32) float32
- func ParseAngle32(pstr string) (float32, error)
- func ParseFloat32(pstr string) (float32, error)
- func PointDim(pt image.Point, dim Dims) int
- func PointsCheckN(pts []float32, n int, errmsg string) error
- func Pow(x, y float32) float32
- func Pow10(n int) float32
- func RadToDeg(radians float32) float32
- func ReadPoints(pstr string) []float32
- func RectFromPosSizeMax(pos, size Vector2) image.Rectangle
- func RectFromPosSizeMin(pos, size Vector2) image.Rectangle
- func RectInNotEmpty(r, b image.Rectangle) bool
- func Remainder(x, y float32) float32
- func Round(x float32) float32
- func RoundToEven(x float32) float32
- func SRGBFromLinear(lin float32) float32
- func SRGBToLinear(sr float32) float32
- func SetPointDim(pt *image.Point, dim Dims, value int)
- func Sign(x float32) float32
- func Signbit(x float32) bool
- func Sin(x float32) float32
- func Sincos(x float32) (sin, cos float32)
- func Sinh(x float32) float32
- func Sqrt(x float32) float32
- func Tan(x float32) float32
- func Tanh(x float32) float32
- func ToFixed(x float32) fixed.Int26_6
- func ToFixedPoint(x, y float32) fixed.Point26_6
- func Trunc(x float32) float32
- func Truncate(val float32, prec int) float32
- func Truncate64(val float64, prec int) float64
- func Y0(x float32) float32
- func Y1(x float32) float32
- func Yn(n int, x float32) float32
- type ArrayF32
- func (a *ArrayF32) Append(v ...float32)
- func (a *ArrayF32) AppendVector2(v ...Vector2)
- func (a *ArrayF32) AppendVector3(v ...Vector3)
- func (a *ArrayF32) AppendVector4(v ...Vector4)
- func (a *ArrayF32) CopyFrom(src ArrayF32)
- func (a ArrayF32) GetMatrix4(pos int, m *Matrix4)
- func (a ArrayF32) GetVector2(pos int, v *Vector2)
- func (a ArrayF32) GetVector3(pos int, v *Vector3)
- func (a ArrayF32) GetVector4(pos int, v *Vector4)
- func (a *ArrayF32) NumBytes() int
- func (a ArrayF32) Set(pos int, v ...float32)
- func (a ArrayF32) SetVector2(pos int, v Vector2)
- func (a ArrayF32) SetVector3(pos int, v Vector3)
- func (a ArrayF32) SetVector4(pos int, v Vector4)
- type ArrayU32
- type Box2
- func (b Box2) Canon() Box2
- func (b Box2) Center() Vector2
- func (b Box2) ClampPoint(point Vector2) Vector2
- func (b Box2) ContainsBox(box Box2) bool
- func (b Box2) ContainsPoint(point Vector2) bool
- func (b Box2) DistanceToPoint(point Vector2) float32
- func (b *Box2) ExpandByBox(box Box2)
- func (b *Box2) ExpandByPoint(point Vector2)
- func (b *Box2) ExpandByScalar(scalar float32)
- func (b *Box2) ExpandByVector(vector Vector2)
- func (b Box2) Intersect(other Box2) Box2
- func (b Box2) IntersectsBox(other Box2) bool
- func (b *Box2) IsEmpty() bool
- func (b Box2) MulMatrix2(m Matrix2) Box2
- func (b Box2) ProjectX(v float32) float32
- func (b Box2) ProjectY(v float32) float32
- func (b *Box2) Set(min, max *Vector2)
- func (b *Box2) SetEmpty()
- func (b *Box2) SetFromCenterAndSize(center, size Vector2)
- func (b *Box2) SetFromPoints(points []Vector2)
- func (b *Box2) SetFromRect(rect image.Rectangle)
- func (b Box2) Size() Vector2
- func (b Box2) ToRect() image.Rectangle
- func (b Box2) Translate(offset Vector2) Box2
- func (b Box2) Union(other Box2) Box2
- type Box3
- func (b Box3) Center() Vector3
- func (b Box3) ClampPoint(point Vector3) Vector3
- func (b Box3) ContainsBox(box Box3) bool
- func (b Box3) ContainsPoint(point Vector3) bool
- func (b Box3) DistanceToPoint(point Vector3) float32
- func (b *Box3) ExpandByBox(box Box3)
- func (b *Box3) ExpandByPoint(point Vector3)
- func (b *Box3) ExpandByPoints(points []Vector3)
- func (b *Box3) ExpandByScalar(scalar float32)
- func (b *Box3) ExpandByVector(vector Vector3)
- func (b Box3) GetBoundingSphere() Sphere
- func (b Box3) Intersect(other Box3) Box3
- func (b Box3) IntersectsBox(other Box3) bool
- func (b Box3) IsEmpty() bool
- func (b Box3) MVProjToNDC(m *Matrix4) Box3
- func (b Box3) MulMatrix4(m *Matrix4) Box3
- func (b Box3) MulQuat(q Quat) Box3
- func (b *Box3) Set(min, max *Vector3)
- func (b *Box3) SetEmpty()
- func (b *Box3) SetFromCenterAndSize(center, size Vector3)
- func (b *Box3) SetFromPoints(points []Vector3)
- func (b Box3) Size() Vector3
- func (b Box3) Translate(offset Vector3) Box3
- func (b Box3) Union(other Box3) Box3
- type Dims
- func (i Dims) Desc() string
- func (i Dims) Int64() int64
- func (i Dims) MarshalText() ([]byte, error)
- func (d Dims) Other() Dims
- func (i *Dims) SetInt64(in int64)
- func (i *Dims) SetString(s string) error
- func (i Dims) String() string
- func (i *Dims) UnmarshalText(text []byte) error
- func (i Dims) Values() []enums.Enum
- type Frustum
- type Geom2DInt
- type Line2
- type Line3
- type Matrix2
- func (a Matrix2) ExtractRot() float32
- func (a Matrix2) ExtractScale() (scx, scy float32)
- func (a Matrix2) Inverse() Matrix2
- func (m Matrix2) IsIdentity() bool
- func (a Matrix2) Mul(b Matrix2) Matrix2
- func (a Matrix2) MulCenter(b Matrix2, ctr Vector2) Matrix2
- func (a Matrix2) MulFixedAsPoint(fp fixed.Point26_6) fixed.Point26_6
- func (a Matrix2) MulVector2AsPoint(v Vector2) Vector2
- func (a Matrix2) MulVector2AsPointCenter(v, ctr Vector2) Vector2
- func (a Matrix2) MulVector2AsVector(v Vector2) Vector2
- func (a Matrix2) Rotate(angle float32) Matrix2
- func (a Matrix2) Scale(x, y float32) Matrix2
- func (a *Matrix2) SetMul(b Matrix2)
- func (a *Matrix2) SetMulCenter(b Matrix2, ctr Vector2)
- func (a *Matrix2) SetString(str string) error
- func (a Matrix2) Shear(x, y float32) Matrix2
- func (a Matrix2) Skew(x, y float32) Matrix2
- func (a *Matrix2) String() string
- func (a Matrix2) Translate(x, y float32) Matrix2
- type Matrix3
- func (m *Matrix3) CopyFrom(src Matrix3)
- func (m *Matrix3) Determinant() float32
- func (m *Matrix3) FromArray(array []float32, offset int)
- func (m Matrix3) Inverse() Matrix3
- func (m Matrix3) InverseTry() (Matrix3, error)
- func (m Matrix3) Mul(other Matrix3) Matrix3
- func (m *Matrix3) MulMatrices(a, b Matrix3)
- func (m Matrix3) MulScalar(s float32) Matrix3
- func (a Matrix3) MulVector2AsPoint(v Vector2) Vector2
- func (a Matrix3) MulVector2AsVector(v Vector2) Vector2
- func (m *Matrix3) MulVector3Array(array []float32, start, count int)
- func (m *Matrix3) ScaleCols(v Vector3) *Matrix3
- func (m *Matrix3) Set(n11, n12, n13, n21, n22, n23, n31, n32, n33 float32)
- func (m *Matrix3) SetFromMatrix2(src Matrix2)
- func (m *Matrix3) SetFromMatrix4(src *Matrix4)
- func (m *Matrix3) SetIdentity()
- func (m *Matrix3) SetInverse(src Matrix3) error
- func (m *Matrix3) SetMul(other Matrix3)
- func (m *Matrix3) SetMulScalar(s float32)
- func (m *Matrix3) SetNormalMatrix(src *Matrix4) error
- func (m *Matrix3) SetRotationFromQuat(q Quat)
- func (m *Matrix3) SetScaleCols(v Vector3)
- func (m *Matrix3) SetTranspose()
- func (m *Matrix3) SetZero()
- func (m Matrix3) ToArray(array []float32, offset int)
- func (m Matrix3) Transpose() Matrix3
- type Matrix4
- func (m *Matrix4) CopyFrom(src *Matrix4)
- func (m *Matrix4) CopyPos(src *Matrix4)
- func (m *Matrix4) Decompose() (pos Vector3, quat Quat, scale Vector3)
- func (m *Matrix4) Determinant() float32
- func (m *Matrix4) ExtractBasis() (xAxis, yAxis, zAxis Vector3)
- func (m *Matrix4) ExtractRotation(src *Matrix4)
- func (m *Matrix4) FromArray(array []float32, offset int)
- func (m *Matrix4) GetMaxScaleOnAxis() float32
- func (m *Matrix4) Inverse() (*Matrix4, error)
- func (m *Matrix4) LookAt(eye, target, up Vector3)
- func (m *Matrix4) Mul(other *Matrix4) *Matrix4
- func (m *Matrix4) MulMatrices(a, b *Matrix4)
- func (m *Matrix4) MulScalar(s float32)
- func (m *Matrix4) MulVector3Array(array []float32, start, count int)
- func (m *Matrix4) Pos() Vector3
- func (m *Matrix4) ScaleCols(v Vector3) *Matrix4
- func (m *Matrix4) Set(...)
- func (m *Matrix4) SetBasis(xAxis, yAxis, zAxis Vector3)
- func (m *Matrix4) SetFromMatrix3(src *Matrix3)
- func (m *Matrix4) SetFrustum(left, right, bottom, top, near, far float32)
- func (m *Matrix4) SetIdentity()
- func (m *Matrix4) SetInverse(src *Matrix4) error
- func (m *Matrix4) SetMul(other *Matrix4)
- func (m *Matrix4) SetOrthographic(width, height, near, far float32)
- func (m *Matrix4) SetPerspective(fov, aspect, near, far float32)
- func (m *Matrix4) SetPos(v Vector3)
- func (m *Matrix4) SetRotationAxis(axis *Vector3, angle float32)
- func (m *Matrix4) SetRotationFromEuler(euler Vector3)
- func (m *Matrix4) SetRotationFromQuat(q Quat)
- func (m *Matrix4) SetRotationX(theta float32)
- func (m *Matrix4) SetRotationY(theta float32)
- func (m *Matrix4) SetRotationZ(theta float32)
- func (m *Matrix4) SetScale(x, y, z float32)
- func (m *Matrix4) SetScaleCols(v Vector3)
- func (m *Matrix4) SetTransform(pos Vector3, quat Quat, scale Vector3)
- func (m *Matrix4) SetTranslation(x, y, z float32)
- func (m *Matrix4) SetTranspose()
- func (m *Matrix4) SetVkFrustum(left, right, bottom, top, near, far float32)
- func (m *Matrix4) SetVkPerspective(fov, aspect, near, far float32)
- func (m *Matrix4) SetZero()
- func (m *Matrix4) ToArray(array []float32, offset int)
- func (m *Matrix4) Transpose() *Matrix4
- type Plane
- func (p *Plane) CoplanarPoint() Vector3
- func (p *Plane) DistanceToPoint(point Vector3) float32
- func (p *Plane) DistanceToSphere(sphere Sphere) float32
- func (p *Plane) IntersectLine(line Line3) (Vector3, bool)
- func (p *Plane) IsIntersectionLine(line Line3) bool
- func (p *Plane) Negate()
- func (p *Plane) Normalize()
- func (p *Plane) Set(normal Vector3, offset float32)
- func (p *Plane) SetDims(x, y, z, w float32)
- func (p *Plane) SetFromCoplanarPoints(a, b, c Vector3)
- func (p *Plane) SetFromNormalAndCoplanarPoint(normal Vector3, point Vector3)
- func (p *Plane) SetTranslate(offset Vector3)
- type Quat
- func (q *Quat) Conjugate() Quat
- func (q *Quat) Dot(other Quat) float32
- func (q *Quat) FromArray(array []float32, offset int)
- func (q *Quat) GenGoNew() string
- func (q *Quat) GenGoSet(path string) string
- func (q *Quat) Inverse() Quat
- func (q *Quat) IsIdentity() bool
- func (q *Quat) IsNil() bool
- func (q Quat) Length() float32
- func (q Quat) LengthSq() float32
- func (q *Quat) Mul(other Quat) Quat
- func (q *Quat) MulQuats(a, b Quat)
- func (q *Quat) Normalize()
- func (q *Quat) NormalizeFast()
- func (q *Quat) Set(x, y, z, w float32)
- func (q *Quat) SetConjugate()
- func (q *Quat) SetFromAxisAngle(axis Vector3, angle float32)
- func (q *Quat) SetFromEuler(euler Vector3)
- func (q *Quat) SetFromRotationMatrix(m *Matrix4)
- func (q *Quat) SetFromUnitVectors(vFrom, vTo Vector3)
- func (q *Quat) SetIdentity()
- func (q *Quat) SetInverse()
- func (q *Quat) SetMul(other Quat)
- func (q *Quat) Slerp(other Quat, t float32)
- func (q Quat) String() string
- func (q *Quat) ToArray(array []float32, offset int)
- func (q *Quat) ToAxisAngle() Vector4
- func (q *Quat) ToEuler() Vector3
- type Ray
- func (ray *Ray) ApplyMatrix4(mat4 *Matrix4)
- func (ray *Ray) At(t float32) Vector3
- func (ray *Ray) ClosestPointToPoint(point Vector3) Vector3
- func (ray *Ray) DistanceSquaredToPoint(point Vector3) float32
- func (ray *Ray) DistanceSquaredToSegment(v0, v1 Vector3, optPointOnRay, optPointOnSegment *Vector3) float32
- func (ray *Ray) DistanceToPlane(plane Plane) float32
- func (ray *Ray) DistanceToPoint(point Vector3) float32
- func (ray *Ray) IntersectBox(box Box3) (Vector3, bool)
- func (ray *Ray) IntersectPlane(plane Plane) (Vector3, bool)
- func (ray *Ray) IntersectSphere(sphere Sphere) (Vector3, bool)
- func (ray *Ray) IntersectTriangle(a, b, c Vector3, backfaceCulling bool) (Vector3, bool)
- func (ray *Ray) IsIntersectPlane(plane Plane) bool
- func (ray *Ray) IsIntersectionSphere(sphere Sphere) bool
- func (ray *Ray) Recast(t float32)
- func (ray *Ray) Set(origin, dir Vector3)
- type Sphere
- func (s *Sphere) ClampPoint(point Vector3) Vector3
- func (s *Sphere) ContainsPoint(point Vector3) bool
- func (s *Sphere) DistanceToPoint(point Vector3) float32
- func (s *Sphere) GetBoundingBox() Box3
- func (s *Sphere) IntersectSphere(other Sphere) bool
- func (s *Sphere) IsEmpty(sphere *Sphere) bool
- func (s *Sphere) MulMatrix4(mat *Matrix4)
- func (s *Sphere) Set(center Vector3, radius float32)
- func (s *Sphere) SetFromBox(box Box3)
- func (s *Sphere) SetFromPoints(points []Vector3, optCenter *Vector3)
- func (s *Sphere) Translate(offset Vector3)
- type Triangle
- func (t *Triangle) Area() float32
- func (t *Triangle) BarycoordFromPoint(point Vector3) Vector3
- func (t *Triangle) ContainsPoint(point Vector3) bool
- func (t *Triangle) Midpoint() Vector3
- func (t *Triangle) Normal() Vector3
- func (t *Triangle) Plane() Plane
- func (t *Triangle) Set(a, b, c Vector3)
- func (t *Triangle) SetFromPointsAndIndices(points []Vector3, i0, i1, i2 int)
- type Vector2
- func (v Vector2) Abs() Vector2
- func (v Vector2) Add(other Vector2) Vector2
- func (a Vector2) AddDim(d Dims, value float32) Vector2
- func (v Vector2) AddScalar(s float32) Vector2
- func (v Vector2) AngleTo(other Vector2) float32
- func (v Vector2) Ceil() Vector2
- func (v *Vector2) Clamp(min, max Vector2)
- func (v Vector2) CosTo(other Vector2) float32
- func (v Vector2) Cross(other Vector2) float32
- func (v Vector2) Dim(dim Dims) float32
- func (v Vector2) DistanceTo(other Vector2) float32
- func (v Vector2) DistanceToSquared(other Vector2) float32
- func (v Vector2) Div(other Vector2) Vector2
- func (a Vector2) DivDim(d Dims, value float32) Vector2
- func (v Vector2) DivScalar(scalar float32) Vector2
- func (v Vector2) Dot(other Vector2) float32
- func (v Vector2) Floor() Vector2
- func (v *Vector2) FromSlice(slice []float32, offset int)
- func (v Vector2) InTriangle(p0, p1, p2 Vector2) bool
- func (v Vector2) Length() float32
- func (v Vector2) LengthSquared() float32
- func (v Vector2) Lerp(other Vector2, alpha float32) Vector2
- func (v Vector2) Max(other Vector2) Vector2
- func (v Vector2) Min(other Vector2) Vector2
- func (v Vector2) Mul(other Vector2) Vector2
- func (a Vector2) MulDim(d Dims, value float32) Vector2
- func (v Vector2) MulScalar(s float32) Vector2
- func (v Vector2) Negate() Vector2
- func (v Vector2) Normal() Vector2
- func (v Vector2) Round() Vector2
- func (v *Vector2) Set(x, y float32)
- func (v *Vector2) SetAdd(other Vector2)
- func (v *Vector2) SetAddScalar(s float32)
- func (v *Vector2) SetDim(dim Dims, value float32)
- func (v *Vector2) SetDiv(other Vector2)
- func (v *Vector2) SetDivScalar(scalar float32)
- func (a *Vector2) SetFixed(pt fixed.Point26_6)
- func (v *Vector2) SetFromVector2i(vi Vector2i)
- func (v *Vector2) SetMax(other Vector2)
- func (v *Vector2) SetMin(other Vector2)
- func (v *Vector2) SetMul(other Vector2)
- func (v *Vector2) SetMulScalar(s float32)
- func (a *Vector2) SetPoint(pt image.Point)
- func (v *Vector2) SetScalar(scalar float32)
- func (v *Vector2) SetSub(other Vector2)
- func (v *Vector2) SetSubScalar(s float32)
- func (v *Vector2) SetZero()
- func (a Vector2) String() string
- func (v Vector2) Sub(other Vector2) Vector2
- func (a Vector2) SubDim(d Dims, value float32) Vector2
- func (v Vector2) SubScalar(s float32) Vector2
- func (a Vector2) ToFixed() fixed.Point26_6
- func (a Vector2) ToPoint() image.Point
- func (a Vector2) ToPointCeil() image.Point
- func (a Vector2) ToPointFloor() image.Point
- func (a Vector2) ToPointRound() image.Point
- func (v Vector2) ToSlice(slice []float32, offset int)
- func (v Vector2) WindowToNDC(size, off Vector2, flipY bool) Vector3
- type Vector2i
- func (v Vector2i) Add(other Vector2i) Vector2i
- func (v Vector2i) AddScalar(s int32) Vector2i
- func (v *Vector2i) Clamp(min, max Vector2i)
- func (v Vector2i) Dim(dim Dims) int32
- func (v Vector2i) Div(other Vector2i) Vector2i
- func (v Vector2i) DivScalar(scalar int32) Vector2i
- func (v *Vector2i) FromSlice(array []int32, offset int)
- func (v Vector2i) Max(other Vector2i) Vector2i
- func (v Vector2i) Min(other Vector2i) Vector2i
- func (v Vector2i) Mul(other Vector2i) Vector2i
- func (v Vector2i) MulScalar(s int32) Vector2i
- func (v Vector2i) Negate() Vector2i
- func (v *Vector2i) Set(x, y int32)
- func (v *Vector2i) SetAdd(other Vector2i)
- func (v *Vector2i) SetAddScalar(s int32)
- func (v *Vector2i) SetDim(dim Dims, value int32)
- func (v *Vector2i) SetDiv(other Vector2i)
- func (v *Vector2i) SetDivScalar(scalar int32)
- func (v *Vector2i) SetFromVector2(vf Vector2)
- func (v *Vector2i) SetMax(other Vector2i)
- func (v *Vector2i) SetMin(other Vector2i)
- func (v *Vector2i) SetMul(other Vector2i)
- func (v *Vector2i) SetMulScalar(s int32)
- func (v *Vector2i) SetScalar(scalar int32)
- func (v *Vector2i) SetSub(other Vector2i)
- func (v *Vector2i) SetSubScalar(s int32)
- func (v *Vector2i) SetZero()
- func (v Vector2i) Sub(other Vector2i) Vector2i
- func (v Vector2i) SubScalar(s int32) Vector2i
- func (v Vector2i) ToSlice(array []int32, offset int)
- type Vector3
- func BarycoordFromPoint(point, a, b, c Vector3) Vector3
- func NewEulerAnglesFromMatrix(m *Matrix4) Vector3
- func NewVector3Color(clr color.Color) Vector3
- func Normal(a, b, c Vector3) Vector3
- func Vec3(x, y, z float32) Vector3
- func Vector3FromVector4(v Vector4) Vector3
- func Vector3Scalar(scalar float32) Vector3
- func (v Vector3) Abs() Vector3
- func (v Vector3) Add(other Vector3) Vector3
- func (v Vector3) AddScalar(s float32) Vector3
- func (v Vector3) AngleTo(other Vector3) float32
- func (v Vector3) Ceil() Vector3
- func (v *Vector3) Clamp(min, max Vector3)
- func (v Vector3) CosTo(other Vector3) float32
- func (v Vector3) Cross(other Vector3) Vector3
- func (v Vector3) Dim(dim Dims) float32
- func (v Vector3) DistanceTo(other Vector3) float32
- func (v Vector3) DistanceToSquared(other Vector3) float32
- func (v Vector3) Div(other Vector3) Vector3
- func (v Vector3) DivScalar(scalar float32) Vector3
- func (v Vector3) Dot(other Vector3) float32
- func (v Vector3) Floor() Vector3
- func (v *Vector3) FromSlice(array []float32, offset int)
- func (v *Vector3) GenGoSet(path string) string
- func (v Vector3) Length() float32
- func (v Vector3) LengthSquared() float32
- func (v Vector3) Lerp(other Vector3, alpha float32) Vector3
- func (v Vector3) Max(other Vector3) Vector3
- func (v Vector3) Min(other Vector3) Vector3
- func (v Vector3) Mul(other Vector3) Vector3
- func (v Vector3) MulMatrix3(m *Matrix3) Vector3
- func (v Vector3) MulMatrix4(m *Matrix4) Vector3
- func (v Vector3) MulMatrix4AsVector4(m *Matrix4, w float32) Vector3
- func (v Vector3) MulProjection(m *Matrix4) Vector3
- func (v Vector3) MulQuat(q Quat) Vector3
- func (v Vector3) MulScalar(s float32) Vector3
- func (v Vector3) NDCToWindow(size, off Vector2, near, far float32, flipY bool) Vector3
- func (v Vector3) Negate() Vector3
- func (v Vector3) Normal() Vector3
- func (v *Vector3) ProjectOnPlane(planeNormal Vector3) Vector3
- func (v *Vector3) ProjectOnVector(other Vector3) Vector3
- func (v *Vector3) RandomTangents() (Vector3, Vector3)
- func (v *Vector3) Reflect(normal Vector3) Vector3
- func (v Vector3) Round() Vector3
- func (v Vector3) SRGBFromLinear() Vector3
- func (v Vector3) SRGBToLinear() Vector3
- func (v *Vector3) Set(x, y, z float32)
- func (v *Vector3) SetAdd(other Vector3)
- func (v *Vector3) SetAddScalar(s float32)
- func (v *Vector3) SetColor(clr color.Color)
- func (v *Vector3) SetDim(dim Dims, value float32)
- func (v *Vector3) SetDiv(other Vector3)
- func (v *Vector3) SetDivScalar(scalar float32)
- func (v *Vector3) SetEulerAnglesFromMatrix(m *Matrix4)
- func (v *Vector3) SetEulerAnglesFromQuat(q Quat)
- func (v *Vector3) SetFromMatrixPos(m *Matrix4)
- func (v *Vector3) SetFromVector3i(vi Vector3i)
- func (v *Vector3) SetFromVector4(other Vector4)
- func (v *Vector3) SetMax(other Vector3)
- func (v *Vector3) SetMin(other Vector3)
- func (v *Vector3) SetMul(other Vector3)
- func (v *Vector3) SetMulScalar(s float32)
- func (v *Vector3) SetNormal()
- func (v *Vector3) SetScalar(scalar float32)
- func (v *Vector3) SetSub(other Vector3)
- func (v *Vector3) SetSubScalar(s float32)
- func (v *Vector3) SetZero()
- func (a Vector3) String() string
- func (v Vector3) Sub(other Vector3) Vector3
- func (v Vector3) SubScalar(s float32) Vector3
- func (v Vector3) ToSlice(array []float32, offset int)
- type Vector3i
- func (v Vector3i) Add(other Vector3i) Vector3i
- func (v Vector3i) AddScalar(s int32) Vector3i
- func (v *Vector3i) Clamp(min, max Vector3i)
- func (v Vector3i) Dim(dim Dims) int32
- func (v Vector3i) Div(other Vector3i) Vector3i
- func (v Vector3i) DivScalar(scalar int32) Vector3i
- func (v *Vector3i) FromSlice(array []int32, offset int)
- func (v Vector3i) Max(other Vector3i) Vector3i
- func (v Vector3i) Min(other Vector3i) Vector3i
- func (v Vector3i) Mul(other Vector3i) Vector3i
- func (v Vector3i) MulScalar(s int32) Vector3i
- func (v Vector3i) Negate() Vector3i
- func (v *Vector3i) Set(x, y, z int32)
- func (v *Vector3i) SetAdd(other Vector3i)
- func (v *Vector3i) SetAddScalar(s int32)
- func (v *Vector3i) SetDim(dim Dims, value int32)
- func (v *Vector3i) SetDiv(other Vector3i)
- func (v *Vector3i) SetDivScalar(scalar int32)
- func (v *Vector3i) SetFromVector3(vf Vector3)
- func (v *Vector3i) SetMax(other Vector3i)
- func (v *Vector3i) SetMin(other Vector3i)
- func (v *Vector3i) SetMul(other Vector3i)
- func (v *Vector3i) SetMulScalar(s int32)
- func (v *Vector3i) SetScalar(scalar int32)
- func (v *Vector3i) SetSub(other Vector3i)
- func (v *Vector3i) SetSubScalar(s int32)
- func (v *Vector3i) SetZero()
- func (v Vector3i) Sub(other Vector3i) Vector3i
- func (v Vector3i) SubScalar(s int32) Vector3i
- func (v Vector3i) ToSlice(array []int32, offset int)
- type Vector4
- func (v Vector4) Add(other Vector4) Vector4
- func (v Vector4) AddScalar(s float32) Vector4
- func (v Vector4) Ceil() Vector4
- func (v *Vector4) Clamp(min, max Vector4)
- func (v Vector4) Dim(dim Dims) float32
- func (v Vector4) Div(other Vector4) Vector4
- func (v Vector4) DivScalar(scalar float32) Vector4
- func (v Vector4) Dot(other Vector4) float32
- func (v Vector4) Floor() Vector4
- func (v *Vector4) FromSlice(array []float32, offset int)
- func (v Vector4) Length() float32
- func (v Vector4) LengthSquared() float32
- func (v Vector4) Lerp(other Vector4, alpha float32) Vector4
- func (v Vector4) Max(other Vector4) Vector4
- func (v Vector4) Min(other Vector4) Vector4
- func (v Vector4) Mul(other Vector4) Vector4
- func (v Vector4) MulMatrix4(m *Matrix4) Vector4
- func (v Vector4) MulScalar(s float32) Vector4
- func (v Vector4) Negate() Vector4
- func (v Vector4) Normal() Vector4
- func (v Vector4) PerspDiv() Vector3
- func (v Vector4) Round() Vector4
- func (v Vector4) SRGBFromLinear() Vector4
- func (v Vector4) SRGBToLinear() Vector4
- func (v *Vector4) Set(x, y, z, w float32)
- func (v *Vector4) SetAdd(other Vector4)
- func (v *Vector4) SetAddScalar(s float32)
- func (v *Vector4) SetAxisAngleFromQuat(q Quat)
- func (v *Vector4) SetColor(clr color.Color)
- func (v *Vector4) SetDim(dim Dims, value float32)
- func (v *Vector4) SetDiv(other Vector4)
- func (v *Vector4) SetDivScalar(s float32)
- func (v *Vector4) SetFromVector2(other Vector2)
- func (v *Vector4) SetFromVector3(other Vector3, w float32)
- func (v *Vector4) SetMax(other Vector4)
- func (v *Vector4) SetMin(other Vector4)
- func (v *Vector4) SetMul(other Vector4)
- func (v *Vector4) SetMulScalar(s float32)
- func (v *Vector4) SetNormal()
- func (v *Vector4) SetScalar(scalar float32)
- func (v *Vector4) SetSub(other Vector4)
- func (v *Vector4) SetSubScalar(s float32)
- func (v *Vector4) SetZero()
- func (v Vector4) String() string
- func (v Vector4) Sub(other Vector4) Vector4
- func (v Vector4) SubScalar(s float32) Vector4
- func (v Vector4) ToSlice(array []float32, offset int)
Constants ¶
const ( E = math.E Pi = math.Pi Phi = math.Phi Sqrt2 = math.Sqrt2 SqrtE = math.SqrtE SqrtPi = math.SqrtPi SqrtPhi = math.SqrtPhi Ln2 = math.Ln2 Log2E = math.Log2E Ln10 = math.Ln10 Log10E = math.Log10E )
Mathematical constants.
const ( MaxFloat32 = math.MaxFloat32 SmallestNonzeroFloat32 = math.SmallestNonzeroFloat32 )
Floating-point limit values. Max is the largest finite value representable by the type. SmallestNonzero is the smallest positive, non-zero value representable by the type.
const ( // DegToRadFactor is the number of radians per degree. DegToRadFactor = Pi / 180 // RadToDegFactor is the number of degrees per radian. RadToDegFactor = 180 / Pi )
Variables ¶
var Infinity = float32(math.Inf(1))
Infinity is positive infinity.
Functions ¶
func Acos ¶
Acos returns the arccosine, in radians, of x.
Special case is:
Acos(x) = NaN if x < -1 or x > 1
func Acosh ¶
Acosh returns the inverse hyperbolic cosine of x.
Special cases are:
Acosh(+Inf) = +Inf Acosh(x) = NaN if x < 1 Acosh(NaN) = NaN
func Asin ¶
Asin returns the arcsine, in radians, of x.
Special cases are:
Asin(±0) = ±0 Asin(x) = NaN if x < -1 or x > 1
func Asinh ¶
Asinh returns the inverse hyperbolic sine of x.
Special cases are:
Asinh(±0) = ±0 Asinh(±Inf) = ±Inf Asinh(NaN) = NaN
func Atan ¶
Atan returns the arctangent, in radians, of x.
Special cases are:
Atan(±0) = ±0 Atan(±Inf) = ±Pi/2
func Atan2 ¶
Atan2 returns the arc tangent of y/x, using the signs of the two to determine the quadrant of the return value. Special cases are (in order):
Atan2(y, NaN) = NaN Atan2(NaN, x) = NaN Atan2(+0, x>=0) = +0 Atan2(-0, x>=0) = -0 Atan2(+0, x<=-0) = +Pi Atan2(-0, x<=-0) = -Pi Atan2(y>0, 0) = +Pi/2 Atan2(y<0, 0) = -Pi/2 Atan2(+Inf, +Inf) = +Pi/4 Atan2(-Inf, +Inf) = -Pi/4 Atan2(+Inf, -Inf) = 3Pi/4 Atan2(-Inf, -Inf) = -3Pi/4 Atan2(y, +Inf) = 0 Atan2(y>0, -Inf) = +Pi Atan2(y<0, -Inf) = -Pi Atan2(+Inf, x) = +Pi/2 Atan2(-Inf, x) = -Pi/2
func Atanh ¶
Atanh returns the inverse hyperbolic tangent of x.
Special cases are:
Atanh(1) = +Inf Atanh(±0) = ±0 Atanh(-1) = -Inf Atanh(x) = NaN if x < -1 or x > 1 Atanh(NaN) = NaN
func Cbrt ¶
Cbrt returns the cube root of x.
Special cases are:
Cbrt(±0) = ±0 Cbrt(±Inf) = ±Inf Cbrt(NaN) = NaN
func Ceil ¶
Ceil returns the least integer value greater than or equal to x.
Special cases are:
Ceil(±0) = ±0 Ceil(±Inf) = ±Inf Ceil(NaN) = NaN
func ContainsPoint ¶
ContainsPoint returns whether a triangle contains a point.
func CopyFloat32s ¶
CopyFloat32s copies a []float32 slice from src into target, ensuring that the target is the correct size.
func CopyFloat64s ¶
CopyFloat64s copies a []float64 slice from src into target, ensuring that the target is the correct size.
func Cos ¶
Cos returns the cosine of the radian argument x.
Special cases are:
Cos(±Inf) = NaN Cos(NaN) = NaN
func Cosh ¶
Cosh returns the hyperbolic cosine of x.
Special cases are:
Cosh(±0) = 1 Cosh(±Inf) = +Inf Cosh(NaN) = NaN
func Dim ¶
Dim returns the maximum of x-y or 0.
Special cases are:
Dim(+Inf, +Inf) = NaN Dim(-Inf, -Inf) = NaN Dim(x, NaN) = Dim(NaN, x) = NaN
func Erf ¶
Erf returns the error function of x.
Special cases are:
Erf(+Inf) = 1 Erf(-Inf) = -1 Erf(NaN) = NaN
func Erfc ¶
Erfc returns the complementary error function of x.
Special cases are:
Erfc(+Inf) = 0 Erfc(-Inf) = 2 Erfc(NaN) = NaN
func Erfcinv ¶
Erfcinv returns the inverse of Erfc(x).
Special cases are:
Erfcinv(0) = +Inf Erfcinv(2) = -Inf Erfcinv(x) = NaN if x < 0 or x > 2 Erfcinv(NaN) = NaN
func Erfinv ¶
Erfinv returns the inverse error function of x.
Special cases are:
Erfinv(1) = +Inf Erfinv(-1) = -Inf Erfinv(x) = NaN if x < -1 or x > 1 Erfinv(NaN) = NaN
func Exp ¶
Exp returns e**x, the base-e exponential of x.
Special cases are:
Exp(+Inf) = +Inf Exp(NaN) = NaN
Very large values overflow to 0 or +Inf. Very small values underflow to 1.
func Expm1 ¶
Expm1 returns e**x - 1, the base-e exponential of x minus 1. It is more accurate than Exp(x) - 1 when x is near zero.
Special cases are:
Expm1(+Inf) = +Inf Expm1(-Inf) = -1 Expm1(NaN) = NaN
Very large values overflow to -1 or +Inf.
func FMA ¶
FMA returns x * y + z, computed with only one rounding. (That is, FMA returns the fused multiply add of x, y, and z.)
func FastExp ¶
FastExp is a quartic spline approximation to the Exp function, by N.N. Schraudolph It does not have any of the sanity checking of a standard method -- returns nonsense when arg is out of range. Runs in 2.23ns vs. 6.3ns for 64bit which is faster than math32.Exp actually.
func FitGeomInWindow ¶
FitGeomInWindow returns a position and size for a region (sub-window) within a larger window geom (pos and size) that fits entirely within that window to the extent possible, given an initial starting position and size. The position is first adjusted to try to fit the size, and then the size is adjusted to make it fit if it is still too big.
func Floor ¶
Floor returns the greatest integer value less than or equal to x.
Special cases are:
Floor(±0) = ±0 Floor(±Inf) = ±Inf Floor(NaN) = NaN
func Frexp ¶
Frexp breaks f into a normalized fraction and an integral power of two. It returns frac and exp satisfying f == frac × 2**exp, with the absolute value of frac in the interval [½, 1).
Special cases are:
Frexp(±0) = ±0, 0 Frexp(±Inf) = ±Inf, 0 Frexp(NaN) = NaN, 0
func Gamma ¶
Gamma returns the Gamma function of x.
Special cases are:
Gamma(+Inf) = +Inf Gamma(+0) = +Inf Gamma(-0) = -Inf Gamma(x) = NaN for integer x < 0 Gamma(-Inf) = NaN Gamma(NaN) = NaN
func Hypot ¶
Hypot returns Sqrt(p*p + q*q), taking care to avoid unnecessary overflow and underflow.
Special cases are:
Hypot(±Inf, q) = +Inf Hypot(p, ±Inf) = +Inf Hypot(NaN, q) = NaN Hypot(p, NaN) = NaN
func Ilogb ¶
Ilogb returns the binary exponent of x as an integer.
Special cases are:
Ilogb(±Inf) = MaxInt32 Ilogb(0) = MinInt32 Ilogb(NaN) = MaxInt32
func IntMultiple ¶
IntMultiple returns the interger multiple of mod closest to given value: Round(val / mod) * mod
func IntMultipleGE ¶
IntMultipleGE returns the interger multiple of mod >= given value: Ceil(val / mod) * mod
func IsInf ¶
IsInf reports whether f is an infinity, according to sign. If sign > 0, IsInf reports whether f is positive infinity. If sign < 0, IsInf reports whether f is negative infinity. If sign == 0, IsInf reports whether f is either infinity.
func J0 ¶
J0 returns the order-zero Bessel function of the first kind.
Special cases are:
J0(±Inf) = 0 J0(0) = 1 J0(NaN) = NaN
func J1 ¶
J1 returns the order-one Bessel function of the first kind.
Special cases are:
J1(±Inf) = 0 J1(NaN) = NaN
func Jn ¶
Jn returns the order-n Bessel function of the first kind.
Special cases are:
Jn(n, ±Inf) = 0 Jn(n, NaN) = NaN
func Ldexp ¶
Ldexp is the inverse of Frexp. It returns frac × 2**exp.
Special cases are:
Ldexp(±0, exp) = ±0 Ldexp(±Inf, exp) = ±Inf Ldexp(NaN, exp) = NaN
func Lgamma ¶
Lgamma returns the natural logarithm and sign (-1 or +1) of Gamma(x).
Special cases are:
Lgamma(+Inf) = +Inf Lgamma(0) = +Inf Lgamma(-integer) = +Inf Lgamma(-Inf) = -Inf Lgamma(NaN) = NaN
func Log ¶
Log returns the natural logarithm of x.
Special cases are:
Log(+Inf) = +Inf Log(0) = -Inf Log(x < 0) = NaN Log(NaN) = NaN
func Log1p ¶
Log1p returns the natural logarithm of 1 plus its argument x. It is more accurate than Log(1 + x) when x is near zero.
Special cases are:
Log1p(+Inf) = +Inf Log1p(±0) = ±0 Log1p(-1) = -Inf Log1p(x < -1) = NaN Log1p(NaN) = NaN
func Logb ¶
Logb returns the binary exponent of x.
Special cases are:
Logb(±Inf) = +Inf Logb(0) = -Inf Logb(NaN) = NaN
func Max ¶
Max returns the larger of x or y.
Special cases are:
Max(x, +Inf) = Max(+Inf, x) = +Inf Max(x, NaN) = Max(NaN, x) = NaN Max(+0, ±0) = Max(±0, +0) = +0 Max(-0, -0) = -0
Note that this differs from the built-in function max when called with NaN and +Inf.
func Min ¶
Min returns the smaller of x or y.
Special cases are:
Min(x, -Inf) = Min(-Inf, x) = -Inf Min(x, NaN) = Min(NaN, x) = NaN Min(-0, ±0) = Min(±0, -0) = -0
Note that this differs from the built-in function min when called with NaN and -Inf.
func Mod ¶
Mod returns the floating-point remainder of x/y. The magnitude of the result is less than y and its sign agrees with that of x.
Special cases are:
Mod(±Inf, y) = NaN Mod(NaN, y) = NaN Mod(x, 0) = NaN Mod(x, ±Inf) = x Mod(x, NaN) = NaN
func Modf ¶
Modf returns integer and fractional floating-point numbers that sum to f. Both values have the same sign as f.
Special cases are:
Modf(±Inf) = ±Inf, NaN Modf(NaN) = NaN, NaN
func Nextafter ¶
Nextafter returns the next representable float32 value after x towards y.
Special cases are:
Nextafter32(x, x) = x Nextafter32(NaN, y) = NaN Nextafter32(x, NaN) = NaN
func ParseAngle32 ¶
ParseAngle32 returns radians angle from string that can specify units (deg, grad, rad) -- deg is assumed if not specified
func ParseFloat32 ¶
ParseFloat32 logs any strconv.ParseFloat errors
func PointDim ¶
PointDim returns the given dimension of the given image.Point.
func PointsCheckN ¶
PointsCheckN checks the number of points read and emits an error if not equal to n
func Pow ¶
Pow returns x**y, the base-x exponential of y.
Special cases are (in order):
Pow(x, ±0) = 1 for any x Pow(1, y) = 1 for any y Pow(x, 1) = x for any x Pow(NaN, y) = NaN Pow(x, NaN) = NaN Pow(±0, y) = ±Inf for y an odd integer < 0 Pow(±0, -Inf) = +Inf Pow(±0, +Inf) = +0 Pow(±0, y) = +Inf for finite y < 0 and not an odd integer Pow(±0, y) = ±0 for y an odd integer > 0 Pow(±0, y) = +0 for finite y > 0 and not an odd integer Pow(-1, ±Inf) = 1 Pow(x, +Inf) = +Inf for |x| > 1 Pow(x, -Inf) = +0 for |x| > 1 Pow(x, +Inf) = +0 for |x| < 1 Pow(x, -Inf) = +Inf for |x| < 1 Pow(+Inf, y) = +Inf for y > 0 Pow(+Inf, y) = +0 for y < 0 Pow(-Inf, y) = Pow(-0, -y) Pow(x, y) = NaN for finite x < 0 and finite non-integer y
func Pow10 ¶
Pow10 returns 10**n, the base-10 exponential of n.
Special cases are:
Pow10(n) = 0 for n < -323 Pow10(n) = +Inf for n > 308
func ReadPoints ¶
ReadPoints reads a set of floating point values from a SVG format number string -- returns a slice or nil if there was an error
func RectFromPosSizeMax ¶
RectFromPosSizeMax returns an image.Rectangle from the floor of pos and ceil of size.
func RectFromPosSizeMin ¶
RectFromPosSizeMin returns an image.Rectangle from the ceil of pos and floor of size.
func RectInNotEmpty ¶
RectInNotEmpty returns true if rect r is contained within b box and r is not empty. The existing image.Rectangle.In method returns true if r is empty, but we typically expect that case to be false (out of range box)
func Remainder ¶
Remainder returns the IEEE 754 floating-point remainder of x/y.
Special cases are:
Remainder(±Inf, y) = NaN Remainder(NaN, y) = NaN Remainder(x, 0) = NaN Remainder(x, ±Inf) = x Remainder(x, NaN) = NaN
func Round ¶
Round returns the nearest integer, rounding half away from zero.
Special cases are:
Round(±0) = ±0 Round(±Inf) = ±Inf Round(NaN) = NaN
func RoundToEven ¶
RoundToEven returns the nearest integer, rounding ties to even.
Special cases are:
RoundToEven(±0) = ±0 RoundToEven(±Inf) = ±Inf RoundToEven(NaN) = NaN
func SRGBFromLinear ¶
SRGBFromLinear converts a color with linear gamma correction to SRGB standard 2.4 gamma with offsets.
func SRGBToLinear ¶
SRGBToLinear converts a color with SRGB gamma correction to SRGB standard 2.4 gamma with offsets
func SetPointDim ¶
SetPointDim sets the given dimension of the given image.Point to the given value.
func Sin ¶
Sin returns the sine of the radian argument x.
Special cases are:
Sin(±0) = ±0 Sin(±Inf) = NaN Sin(NaN) = NaN
func Sincos ¶
Sincos returns Sin(x), Cos(x).
Special cases are:
Sincos(±0) = ±0, 1 Sincos(±Inf) = NaN, NaN Sincos(NaN) = NaN, NaN
func Sinh ¶
Sinh returns the hyperbolic sine of x.
Special cases are:
Sinh(±0) = ±0 Sinh(±Inf) = ±Inf Sinh(NaN) = NaN
func Sqrt ¶
Sqrt returns the square root of x.
Special cases are:
Sqrt(+Inf) = +Inf Sqrt(±0) = ±0 Sqrt(x < 0) = NaN Sqrt(NaN) = NaN
func Tan ¶
Tan returns the tangent of the radian argument x.
Special cases are:
Tan(±0) = ±0 Tan(±Inf) = NaN Tan(NaN) = NaN
func Tanh ¶
Tanh returns the hyperbolic tangent of x.
Special cases are:
Tanh(±0) = ±0 Tanh(±Inf) = ±1 Tanh(NaN) = NaN
func ToFixedPoint ¶
ToFixedPoint converts float32 x,y values to a fixed.Point26_6
func Trunc ¶
Trunc returns the integer value of x.
Special cases are:
Trunc(±0) = ±0 Trunc(±Inf) = ±Inf Trunc(NaN) = NaN
func Truncate ¶
Truncate rounds a float32 number to the given level of precision, which the number of significant digits to include in the result.
func Truncate64 ¶
Truncate64 rounds a float64 number to the given level of precision, which the number of significant digits to include in the result.
func Y0 ¶
Y0 returns the order-zero Bessel function of the second kind.
Special cases are:
Y0(+Inf) = 0 Y0(0) = -Inf Y0(x < 0) = NaN Y0(NaN) = NaN
Types ¶
type ArrayF32 ¶
type ArrayF32 []float32
ArrayF32 is a slice of float32 with additional convenience methods for other math32 data types. Use slicesx.SetLength to set length efficiently.
func NewArrayF32 ¶
NewArrayF32 creates a returns a new array of floats with the specified initial size and capacity
func (*ArrayF32) AppendVector2 ¶
AppendVector2 appends any number of Vector2 to the array
func (*ArrayF32) AppendVector3 ¶
AppendVector3 appends any number of Vector3 to the array
func (*ArrayF32) AppendVector4 ¶
AppendVector4 appends any number of Vector4 to the array
func (ArrayF32) GetMatrix4 ¶
GetMatrix4 stores in the specified Matrix4 the values from the array starting at the specified pos.
func (ArrayF32) GetVector2 ¶
GetVector2 stores in the specified Vector2 the values from the array starting at the specified pos.
func (ArrayF32) GetVector3 ¶
GetVector3 stores in the specified Vector3 the values from the array starting at the specified pos.
func (ArrayF32) GetVector4 ¶
GetVector4 stores in the specified Vector4 the values from the array starting at the specified pos.
func (ArrayF32) Set ¶
Set sets the values of the array starting at the specified pos from the specified values
func (ArrayF32) SetVector2 ¶
SetVector2 sets the values of the array at the specified pos from the XY values of the specified Vector2
func (ArrayF32) SetVector3 ¶
SetVector3 sets the values of the array at the specified pos from the XYZ values of the specified Vector3
func (ArrayF32) SetVector4 ¶
SetVector4 sets the values of the array at the specified pos from the XYZ values of the specified Vector4
type ArrayU32 ¶
type ArrayU32 []uint32
ArrayU32 is a slice of uint32 with additional convenience methods. Use slicesx.SetLength to set length efficiently.
func NewArrayU32 ¶
NewArrayU32 creates a returns a new array of uint32 with the specified initial size and capacity
type Box2 ¶
Box2 represents a 2D bounding box defined by two points: the point with minimum coordinates and the point with maximum coordinates.
func B2FromFixed ¶ added in v0.1.1
func B2FromFixed(rect fixed.Rectangle26_6) Box2
B2FromFixed returns a new Box2 from the given fixed.Rectangle26_6.
func B2FromRect ¶
B2FromRect returns a new Box2 from the given image.Rectangle.
func (Box2) Canon ¶
Canon returns the canonical version of the box. The returned rectangle has minimum and maximum coordinates swapped if necessary so that it is well-formed.
func (Box2) ClampPoint ¶
ClampPoint calculates a new point which is the specified point clamped inside this box.
func (Box2) ContainsBox ¶
ContainsBox returns if this bounding box contains other box.
func (Box2) ContainsPoint ¶
ContainsPoint returns if this bounding box contains the specified point.
func (Box2) DistanceToPoint ¶ added in v0.1.4
DistanceToPoint returns the distance from this box to the specified point.
func (*Box2) ExpandByBox ¶
ExpandByBox may expand this bounding box to include the specified box
func (*Box2) ExpandByPoint ¶
ExpandByPoint may expand this bounding box to include the specified point.
func (*Box2) ExpandByScalar ¶
ExpandByScalar expands this bounding box by the specified scalar.
func (*Box2) ExpandByVector ¶
ExpandByVector expands this bounding box by the specified vector.
func (Box2) IntersectsBox ¶
IntersectsBox returns if other box intersects this one.
func (Box2) MulMatrix2 ¶
MulMatrix2 multiplies the specified matrix to the vertices of this bounding box and computes the resulting spanning Box2 of the transformed points
func (Box2) ProjectX ¶ added in v0.1.1
ProjectX projects normalized value along the X dimension of this box
func (Box2) ProjectY ¶ added in v0.1.1
ProjectY projects normalized value along the Y dimension of this box
func (*Box2) Set ¶
Set sets this bounding box minimum and maximum coordinates. If either min or max are nil, then corresponding values are set to +/- Infinity.
func (*Box2) SetEmpty ¶
func (b *Box2) SetEmpty()
SetEmpty set this bounding box to empty (min / max +/- Infinity)
func (*Box2) SetFromCenterAndSize ¶
SetFromCenterAndSize set this bounding box from a center point and size. Size is a vector from the minimum point to the maximum point.
func (*Box2) SetFromPoints ¶
SetFromPoints set this bounding box from the specified array of points.
func (*Box2) SetFromRect ¶
SetFromRect set this bounding box from an image.Rectangle
func (Box2) Size ¶
Size calculates the size of this bounding box: the vector from its minimum point to its maximum point.
func (Box2) ToRect ¶
ToRect returns image.Rectangle version of this bbox, using floor for min and Ceil for max.
type Box3 ¶
Box3 represents a 3D bounding box defined by two points: the point with minimum coordinates and the point with maximum coordinates.
func B3Empty ¶
func B3Empty() Box3
B3Empty returns a new Box3 with empty minimum and maximum values.
func (Box3) ClampPoint ¶
ClampPoint returns a new point which is the specified point clamped inside this box.
func (Box3) ContainsBox ¶
ContainsBox returns if this bounding box contains other box.
func (Box3) ContainsPoint ¶
ContainsPoint returns if this bounding box contains the specified point.
func (Box3) DistanceToPoint ¶ added in v0.1.4
DistanceToPoint returns the distance from this box to the specified point.
func (*Box3) ExpandByBox ¶
ExpandByBox may expand this bounding box to include the specified box
func (*Box3) ExpandByPoint ¶
ExpandByPoint may expand this bounding box to include the specified point.
func (*Box3) ExpandByPoints ¶
ExpandByPoints may expand this bounding box from the specified array of points.
func (*Box3) ExpandByScalar ¶
ExpandByScalar expands this bounding box by the specified scalar subtracting from min and adding to max.
func (*Box3) ExpandByVector ¶
ExpandByVector expands this bounding box by the specified vector subtracting from min and adding to max.
func (Box3) GetBoundingSphere ¶
GetBoundingSphere returns a bounding sphere to this bounding box.
func (Box3) IntersectsBox ¶
IntersectsBox returns if other box intersects this one.
func (Box3) MVProjToNDC ¶
MVProjToNDC projects bounding box through given MVP model-view-projection Matrix4 with perspective divide to return normalized display coordinates (NDC).
func (Box3) MulMatrix4 ¶
MulMatrix4 multiplies the specified matrix to the vertices of this bounding box and computes the resulting spanning Box3 of the transformed points
func (Box3) MulQuat ¶
MulQuat multiplies the specified quaternion to the vertices of this bounding box and computes the resulting spanning Box3 of the transformed points
func (*Box3) Set ¶
Set sets this bounding box minimum and maximum coordinates. If either min or max are nil, then corresponding values are set to +/- Infinity.
func (*Box3) SetEmpty ¶
func (b *Box3) SetEmpty()
SetEmpty set this bounding box to empty (min / max +/- Infinity)
func (*Box3) SetFromCenterAndSize ¶
SetFromCenterAndSize sets this bounding box from a center point and size. Size is a vector from the minimum point to the maximum point.
func (*Box3) SetFromPoints ¶
SetFromPoints sets this bounding box from the specified array of points.
func (Box3) Size ¶
Size calculates the size of this bounding box: the vector from its minimum point to its maximum point.
type Dims ¶
type Dims int32 //enums:enum
Dims is a list of vector dimension (component) names
const DimsN Dims = 4
DimsN is the highest valid value for type Dims, plus one.
func DimsValues ¶
func DimsValues() []Dims
DimsValues returns all possible values for the type Dims.
func (Dims) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Dims) SetString ¶
SetString sets the Dims value from its string representation, and returns an error if the string is invalid.
func (*Dims) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Frustum ¶
type Frustum struct {
Planes [6]Plane
}
Frustum represents a frustum
func NewFrustum ¶
NewFrustum returns a pointer to a new Frustum object made of 6 explicit planes
func NewFrustumFromMatrix ¶
NewFrustumFromMatrix creates and returns a Frustum based on the provided matrix
func (*Frustum) ContainsPoint ¶
ContainsPoint determines whether the frustum contains the specified point
func (*Frustum) IntersectsBox ¶
IntersectsBox determines whether the specified box is intersecting the frustum
func (*Frustum) IntersectsSphere ¶
IntersectsSphere determines whether the specified sphere is intersecting the frustum
func (*Frustum) SetFromMatrix ¶
SetFromMatrix sets the frustum's planes based on the specified Matrix4
type Geom2DInt ¶
Geom2DInt defines a geometry in 2D dots units (int) -- this is just a more convenient format than image.Rectangle for cases where the size and position are independently updated (e.g., Viewport)
func (*Geom2DInt) FitInWindow ¶
FitInWindow returns a position and size for a region (sub-window) within a larger window geom that fits entirely within that window to the extent possible, for the initial "ideal" starting position and size. The position is first adjusted to try to fit the size, and then the size is adjusted to make it fit if it is still too big.
type Line2 ¶ added in v0.3.3
Line2 represents a 2D line segment defined by a start and an end point.
func NewLine2 ¶ added in v0.3.3
NewLine2 creates and returns a new Line2 with the specified start and end points.
func (*Line2) ClosestPointToPoint ¶ added in v0.3.3
ClosestPointToPoint returns the point along the line that is closest to the given point.
func (*Line2) Delta ¶ added in v0.3.3
Delta calculates the vector from the start to end point of this line segment.
func (*Line2) Length ¶ added in v0.3.3
Length returns the length from the start point to the end point.
func (*Line2) LengthSquared ¶ added in v0.3.3
LengthSquared returns the square of the distance from the start point to the end point.
type Line3 ¶
Line3 represents a 3D line segment defined by a start and an end point.
func (*Line3) DistanceSquared ¶ added in v0.1.4
DistanceSquared returns the square of the distance from the start point to the end point.
func (*Line3) MulMatrix4 ¶
MulMatrix4 returns specified matrix multiplied to this line segment start and end points.
type Matrix2 ¶
type Matrix2 struct {
XX, YX, XY, YY, X0, Y0 float32
}
Matrix2 is a 3x2 matrix.
func Translate2D ¶
Translate2D returns a Matrix2 2D matrix with given translations
func (Matrix2) ExtractRot ¶
ExtractRot extracts the rotation component from a given matrix
func (Matrix2) ExtractScale ¶
ExtractXYScale extracts the X and Y scale factors after undoing any rotation present -- i.e., in the original X, Y coordinates
func (Matrix2) IsIdentity ¶
func (Matrix2) MulCenter ¶
MulCenter multiplies the Matrix2, first subtracting given translation center point from the translation components, and then adding it back in.
func (Matrix2) MulFixedAsPoint ¶
MulFixedAsPoint multiplies the fixed point as a point, including adding translations.
func (Matrix2) MulVector2AsPoint ¶
MulVector2AsPoint multiplies the Vector2 as a point, including adding translations.
func (Matrix2) MulVector2AsPointCenter ¶
MulVector2AsPointCenter multiplies the Vector2 as a point relative to given center-point including adding translations.
func (Matrix2) MulVector2AsVector ¶
MulVector2AsVector multiplies the Vector2 as a vector without adding translations. This is for directional vectors and not points.
func (*Matrix2) SetMulCenter ¶
SetMulCenter sets the matrix to the result of Matrix2.MulCenter.
type Matrix3 ¶
type Matrix3 [9]float32
Matrix3 is 3x3 matrix organized internally as column matrix.
func Matrix3FromMatrix2 ¶
func Matrix3FromMatrix4 ¶
func Matrix3Rotate2D ¶
Rotate2D returns a Matrix2 2D matrix with given rotation, specified in radians
func Matrix3Scale2D ¶
Matrix3Scale2D returns a Matrix3 2D matrix with given scaling factors
func Matrix3Translate2D ¶
Matrix3Translate2D returns a Matrix3 2D matrix with given translations
func (*Matrix3) CopyFrom ¶
CopyFrom copies from source matrix into this matrix (a regular = assign does not copy data, just the pointer!)
func (*Matrix3) Determinant ¶
Determinant calculates and returns the determinant of this matrix.
func (Matrix3) Inverse ¶
Inverse returns the inverse of this matrix. If the matrix cannot be inverted it silently sets this matrix to the identity matrix. See Try version for error.
func (Matrix3) InverseTry ¶
InverseTry returns the inverse of this matrix. If the matrix cannot be inverted returns error and sets this matrix to the identity matrix.
func (*Matrix3) MulMatrices ¶
MulMatrices sets ths matrix as matrix multiplication a by b (i.e., a*b).
func (Matrix3) MulScalar ¶
MulScalar returns each of this matrix's components multiplied by the specified scalar, leaving the original matrix unchanged.
func (Matrix3) MulVector2AsPoint ¶
MulVector2AsPoint multiplies the Vector2 as a point, including adding translations.
func (Matrix3) MulVector2AsVector ¶
MulVector2AsVector multiplies the Vector2 as a vector without adding translations. This is for directional vectors and not points.
func (*Matrix3) MulVector3Array ¶
MulVector3Array multiplies count vectors (i.e., 3 sequential array values per each increment in count) in the array starting at start index by this matrix.
func (*Matrix3) ScaleCols ¶
ScaleCols returns matrix with columns multiplied by the vector components. This can be used when multiplying this matrix by a diagonal matrix if we store the diagonal components as a vector.
func (*Matrix3) Set ¶
Set sets all the elements of the matrix row by row starting at row1, column1, row1, column2, row1, column3 and so forth.
func (*Matrix3) SetFromMatrix2 ¶
SetFromMatrix2 sets the matrix elements based on a Matrix2.
func (*Matrix3) SetFromMatrix4 ¶
SetFromMatrix4 sets the matrix elements based on a Matrix4.
func (*Matrix3) SetIdentity ¶
func (m *Matrix3) SetIdentity()
SetIdentity sets this matrix as the identity matrix.
func (*Matrix3) SetInverse ¶
SetInverse sets this matrix to the inverse of the src matrix. If the src matrix cannot be inverted returns error and sets this matrix to the identity matrix.
func (*Matrix3) SetMulScalar ¶
SetMulScalar multiplies each of this matrix's components by the specified scalar.
func (*Matrix3) SetNormalMatrix ¶
SetNormalMatrix set this matrix to the matrix that can transform the normal vectors from the src matrix which is used transform the vertices (e.g., a ModelView matrix). If the src matrix cannot be inverted returns error.
func (*Matrix3) SetRotationFromQuat ¶
SetRotationFromQuat sets this matrix as a rotation matrix from the specified Quat.
func (*Matrix3) SetScaleCols ¶
SetScaleCols multiplies the matrix columns by the vector components. This can be used when multiplying this matrix by a diagonal matrix if we store the diagonal components as a vector.
func (*Matrix3) SetTranspose ¶
func (m *Matrix3) SetTranspose()
SetTranspose transposes this matrix.
type Matrix4 ¶
type Matrix4 [16]float32
Matrix4 is 4x4 matrix organized internally as column matrix.
func NewLookAt ¶
NewLookAt returns Matrix4 matrix as view transform matrix with origin at eye, looking at target and using the up vector.
func (*Matrix4) CopyFrom ¶
CopyFrom copies from source matrix into this matrix (a regular = assign does not copy data, just the pointer!)
func (*Matrix4) Decompose ¶
Decompose updates the position vector, quaternion and scale from this transformation matrix.
func (*Matrix4) Determinant ¶
Determinant calculates and returns the determinant of this matrix.
func (*Matrix4) ExtractBasis ¶
ExtractBasis returns the x,y,z basis vectors of this matrix.
func (*Matrix4) ExtractRotation ¶
ExtractRotation sets this matrix as rotation matrix from the src transformation matrix.
func (*Matrix4) GetMaxScaleOnAxis ¶
GetMaxScaleOnAxis returns the maximum scale value of the 3 axes.
func (*Matrix4) Inverse ¶
Inverse returns the inverse of this matrix. If the matrix cannot be inverted returns error and sets this matrix to the identity matrix.
func (*Matrix4) LookAt ¶
LookAt sets this matrix as view transform matrix with origin at eye, looking at target and using the up vector.
func (*Matrix4) MulMatrices ¶
MulMatrices sets this matrix as matrix multiplication a by b (i.e. a*b).
func (*Matrix4) MulScalar ¶
SetMulScalar multiplies each element of this matrix by the specified scalar.
func (*Matrix4) MulVector3Array ¶
MulVector3Array multiplies count vectors (i.e., 3 sequential array values per each increment in count) in the array starting at start index by this matrix.
func (*Matrix4) ScaleCols ¶
ScaleCols returns matrix with first column of this matrix multiplied by the vector X component, the second column by the vector Y component and the third column by the vector Z component. The matrix fourth column is unchanged.
func (*Matrix4) Set ¶
func (m *Matrix4) Set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 float32)
Set sets all the elements of this matrix row by row starting at row1, column1, row1, column2, row1, column3 and so forth.
func (*Matrix4) SetFromMatrix3 ¶
SetFromMatrix3 sets the matrix elements based on a Matrix3, filling in 0's for missing off-diagonal elements, and 1 on the diagonal.
func (*Matrix4) SetFrustum ¶
SetFrustum sets this matrix to a projection frustum matrix bounded by the specified planes.
func (*Matrix4) SetIdentity ¶
func (m *Matrix4) SetIdentity()
SetIdentity sets this matrix as the identity matrix.
func (*Matrix4) SetInverse ¶
SetInverse sets this matrix to the inverse of the src matrix. If the src matrix cannot be inverted returns error and sets this matrix to the identity matrix.
func (*Matrix4) SetOrthographic ¶
SetOrthographic sets this matrix to an orthographic projection matrix.
func (*Matrix4) SetPerspective ¶
SetPerspective sets this matrix to a perspective projection matrix with the specified field of view in degrees, aspect ratio (width/height) and near and far planes.
func (*Matrix4) SetPos ¶
SetPos sets this transformation matrix position fields from the specified vector v.
func (*Matrix4) SetRotationAxis ¶
SetRotationAxis sets this matrix to a rotation matrix of the specified angle around the specified axis.
func (*Matrix4) SetRotationFromEuler ¶
SetRotationFromEuler set this a matrix as a rotation matrix from the specified euler angles.
func (*Matrix4) SetRotationFromQuat ¶
SetRotationFromQuat sets this matrix as a rotation matrix from the specified quaternion.
func (*Matrix4) SetRotationX ¶
SetRotationX sets this matrix to a rotation matrix of angle theta around the X axis.
func (*Matrix4) SetRotationY ¶
SetRotationY sets this matrix to a rotation matrix of angle theta around the Y axis.
func (*Matrix4) SetRotationZ ¶
SetRotationZ sets this matrix to a rotation matrix of angle theta around the Z axis.
func (*Matrix4) SetScale ¶
SetScale sets this matrix to a scale transformation matrix using the specified x, y and z values.
func (*Matrix4) SetScaleCols ¶
SetScaleCols multiplies the first column of this matrix by the vector X component, the second column by the vector Y component and the third column by the vector Z component. The matrix fourth column is unchanged.
func (*Matrix4) SetTransform ¶
SetTransform sets this matrix to a transformation matrix for the specified position, rotation specified by the quaternion and scale.
func (*Matrix4) SetTranslation ¶
SetTranslation sets this matrix to a translation matrix from the specified x, y and z values.
func (*Matrix4) SetTranspose ¶
func (m *Matrix4) SetTranspose()
SetTranspose transposes this matrix.
func (*Matrix4) SetVkFrustum ¶
SetVkFrustum sets this matrix to a projection frustum matrix bounded by the specified planes. This version is for use with Vulkan, and does the equivalent of GLM_DEPTH_ZERO_ONE in glm and also multiplies the Y axis by -1, preserving the original OpenGL Y-up system. OpenGL provides a "natural" coordinate system for the physical world so it is useful to retain that for the world system and just convert on the way out to the render using this projection matrix.
func (*Matrix4) SetVkPerspective ¶
SetVkPerspective sets this matrix to a vulkan appropriate perspective projection matrix, assuming the use of the OpenGL Y-up coordinate system for the geometry points. OpenGL provides a "natural" coordinate system for the physical world so it is useful to retain that for the world system and just convert on the way out to the render using this projection matrix. The specified field of view is in degrees, aspect ratio (width/height) and near and far planes.
type Plane ¶
Plane represents a plane in 3D space by its normal vector and a constant offset. When the the normal vector is the unit vector the offset is the distance from the origin.
func (*Plane) CoplanarPoint ¶
CoplanarPoint returns a point in the plane that is the closest point from the origin.
func (*Plane) DistanceToPoint ¶ added in v0.1.4
DistanceToPoint returns the distance of this plane from point.
func (*Plane) DistanceToSphere ¶ added in v0.1.4
DistanceToSphere returns the distance of this place from the sphere.
func (*Plane) IntersectLine ¶
IntersectLine calculates the point in the plane which intersets the specified line. Returns false if the line does not intersects the plane.
func (*Plane) IsIntersectionLine ¶
IsIntersectionLine returns the line intersects this plane.
func (*Plane) Normalize ¶
func (p *Plane) Normalize()
Normalize normalizes this plane normal vector and adjusts the offset. Note: will lead to a divide by zero if the plane is invalid.
func (*Plane) SetFromCoplanarPoints ¶
SetFromCoplanarPoints sets this plane from three coplanar points.
func (*Plane) SetFromNormalAndCoplanarPoint ¶
SetFromNormalAndCoplanarPoint sets this plane from a normal vector and a point on the plane.
func (*Plane) SetTranslate ¶
SetTranslate translates this plane in the direction of its normal by offset.
type Quat ¶
Quat is quaternion with X,Y,Z and W components.
func NewQuatAxisAngle ¶
NewQuatAxisAngle returns a new quaternion from given axis and angle rotation (radians).
func NewQuatEuler ¶
NewQuatEuler returns a new quaternion from given Euler angles.
func (*Quat) GenGoSet ¶
GenGoSet returns code to set values in object at given path (var.member etc)
func (*Quat) IsIdentity ¶
IsIdentity returns if this is an identity quaternion.
func (*Quat) NormalizeFast ¶
func (q *Quat) NormalizeFast()
NormalizeFast approximates normalizing this quaternion. Works best when the quaternion is already almost-normalized.
func (*Quat) SetConjugate ¶
func (q *Quat) SetConjugate()
SetConjugate sets this quaternion to its conjugate.
func (*Quat) SetFromAxisAngle ¶
SetFromAxisAngle sets this quaternion with the rotation specified by the given axis and angle.
func (*Quat) SetFromEuler ¶
SetFromEuler sets this quaternion from the specified vector with Euler angles for each axis. It is assumed that the Euler angles are in XYZ order.
func (*Quat) SetFromRotationMatrix ¶
SetFromRotationMatrix sets this quaternion from the specified rotation matrix.
func (*Quat) SetFromUnitVectors ¶
SetFromUnitVectors sets this quaternion to the rotation from vector vFrom to vTo. The vectors must be normalized.
func (*Quat) SetIdentity ¶
func (q *Quat) SetIdentity()
SetIdentity sets this quanternion to the identity quaternion.
func (*Quat) SetInverse ¶
func (q *Quat) SetInverse()
SetInverse sets this quaternion to its inverse.
func (*Quat) Slerp ¶
Slerp sets this quaternion to another quaternion which is the spherically linear interpolation from this quaternion to other using t.
func (*Quat) ToAxisAngle ¶
ToAxisAngle returns the Vector4 holding axis and angle of this Quaternion
type Ray ¶
Ray represents an oriented 3D line segment defined by an origin point and a direction vector.
func NewRay ¶
NewRay creates and returns a pointer to a Ray object with the specified origin and direction vectors. If a nil pointer is supplied for any of the parameters, the zero vector will be used.
func (*Ray) ApplyMatrix4 ¶
MulMatrix4 multiplies this ray origin and direction by the specified matrix4, basically transforming this ray coordinates.
func (*Ray) At ¶
At calculates the point in the ray which is at the specified t distance from the origin along its direction.
func (*Ray) ClosestPointToPoint ¶
ClosestPointToPoint calculates the point in the ray which is closest to the specified point.
func (*Ray) DistanceSquaredToPoint ¶ added in v0.1.4
DistanceSquaredToPoint returns the smallest squared distance from the ray direction vector to the specified point. If the ray was pointed directly at the point this distance would be 0.
func (*Ray) DistanceSquaredToSegment ¶ added in v0.1.4
func (ray *Ray) DistanceSquaredToSegment(v0, v1 Vector3, optPointOnRay, optPointOnSegment *Vector3) float32
DistanceSquaredToSegment returns the smallest squared distance from this ray to the line segment from v0 to v1. If optPointOnRay Vector3 is not nil, it is set with the coordinates of the point on the ray. if optPointOnSegment Vector3 is not nil, it is set with the coordinates of the point on the segment.
func (*Ray) DistanceToPlane ¶ added in v0.1.4
DistanceToPlane returns the distance of this ray origin to its intersection point in the plane. If the ray does not intersects the plane, returns NaN.
func (*Ray) DistanceToPoint ¶ added in v0.1.4
DistanceToPoint returns the smallest distance from the ray direction vector to the specified point.
func (*Ray) IntersectBox ¶
IntersectBox calculates the point which is the intersection of this ray with the specified box. If no intersection is found false is returned.
func (*Ray) IntersectPlane ¶
IntersectPlane calculates the point which is the intersection of this ray with the specified plane. If no intersection is found false is returned.
func (*Ray) IntersectSphere ¶
IntersectSphere calculates the point which is the intersection of this ray with the specified sphere. If no intersection is found it returns false.
func (*Ray) IntersectTriangle ¶
IntersectTriangle returns if this ray intersects the triangle with the face defined by points a, b, c. Returns true if it intersects and the point parameter with the intersected point coordinates. If backfaceCulling is false it ignores the intersection if the face is not oriented in the ray direction.
func (*Ray) IsIntersectPlane ¶
IsIntersectPlane returns if this ray intersects the specified plane.
func (*Ray) IsIntersectionSphere ¶
IsIntersectionSphere returns if this ray intersects with the specified sphere.
type Sphere ¶
type Sphere struct { Center Vector3 // center of the sphere Radius float32 // radius of the sphere }
Sphere represents a 3D sphere defined by its center point and a radius
func NewSphere ¶
NewSphere creates and returns a pointer to a new sphere with the specified center and radius.
func (*Sphere) ClampPoint ¶
ClampPoint clamps the specified point inside the sphere. If the specified point is inside the sphere, it is the clamped point. Otherwise the clamped point is the the point in the sphere surface in the nearest of the specified point.
func (*Sphere) ContainsPoint ¶
ContainsPoint returns if this sphere contains the specified point.
func (*Sphere) DistanceToPoint ¶ added in v0.1.4
DistanceToPoint returns the distance from the sphere surface to the specified point.
func (*Sphere) GetBoundingBox ¶
GetBoundingBox calculates a Box3 which bounds this sphere.
func (*Sphere) IntersectSphere ¶
IntersectSphere returns if other sphere intersects this one.
func (*Sphere) MulMatrix4 ¶
MulMatrix4 applies the specified matrix transform to this sphere.
func (*Sphere) SetFromBox ¶
SetFromBox sets the center and radius of this sphere to surround given box
func (*Sphere) SetFromPoints ¶
SetFromPoints sets this sphere from the specified points array and optional center.
type Triangle ¶
Triangle represents a triangle made of three vertices.
func NewTriangle ¶
NewTriangle returns a new Triangle object.
func (*Triangle) BarycoordFromPoint ¶
BarycoordFromPoint returns the barycentric coordinates for the specified point.
func (*Triangle) ContainsPoint ¶
ContainsPoint returns whether the triangle contains a point.
func (*Triangle) SetFromPointsAndIndices ¶
SetFromPointsAndIndices sets the triangle's vertices based on the specified points and indices.
type Vector2 ¶
Vector2 is a 2D vector/point with X and Y components.
func FromPoint ¶ added in v0.3.3
FromPoint returns a new Vector2 from the given image.Point.
func Vector2FromFixed ¶
Vector2FromFixed returns a new Vector2 from the given fixed.Point26_6.
func Vector2Scalar ¶
Vector2Scalar returns a new Vector2 with all components set to the given scalar value.
func (Vector2) Add ¶
Add adds the other given vector to this one and returns the result as a new vector.
func (Vector2) AddDim ¶
AddDim returns the vector with the given value added on the given dimension.
func (Vector2) AddScalar ¶
AddScalar adds scalar s to each component of this vector and returns new vector.
func (Vector2) AngleTo ¶
AngleTo returns the angle between this vector and other. Returns angles in range of -PI to PI (not 0 to 2 PI).
func (*Vector2) Clamp ¶
Clamp sets this vector's components to be no less than the corresponding components of min and not greater than the corresponding component of max. Assumes min < max; if this assumption isn't true, it will not operate correctly.
func (Vector2) CosTo ¶
CosTo returns the cosine (normalized dot product) between this vector and other.
func (Vector2) DistanceTo ¶ added in v0.1.3
DistanceTo returns the distance between these two vectors as points.
func (Vector2) DistanceToSquared ¶ added in v0.1.3
DistanceToSquared returns the squared distance between these two vectors as points.
func (Vector2) Div ¶
Div divides each component of this vector by the corresponding one from other vector and returns resulting vector.
func (Vector2) DivDim ¶
DivDim returns the vector with the given value divided by on the given dimension.
func (Vector2) DivScalar ¶
DivScalar divides each component of this vector by the scalar s and returns resulting vector. If scalar is zero, returns zero.
func (*Vector2) FromSlice ¶ added in v0.1.3
FromSlice sets this vector's components from the given slice, starting at offset.
func (Vector2) InTriangle ¶
InTriangle returns whether the vector is inside the specified triangle.
func (Vector2) LengthSquared ¶ added in v0.1.3
LengthSquared returns the length squared of this vector. LengthSquared can be used to compare the lengths of vectors without the need to perform a square root.
func (Vector2) Lerp ¶
Lerp returns vector with each components as the linear interpolated value of alpha between itself and the corresponding other component.
func (Vector2) Mul ¶
Mul multiplies each component of this vector by the corresponding one from other and returns resulting vector.
func (Vector2) MulDim ¶
MulDim returns the vector with the given value multiplied by on the given dimension.
func (Vector2) MulScalar ¶
MulScalar multiplies each component of this vector by the scalar s and returns resulting vector.
func (*Vector2) SetAddScalar ¶
SetAddScalar sets this to addition with scalar.
func (*Vector2) SetDivScalar ¶
SetDivScalar sets this to division by scalar.
func (*Vector2) SetFixed ¶
SetFixed sets the vector from the given fixed.Point26_6.
func (*Vector2) SetFromVector2i ¶
SetFromVector2i sets from a Vector2i (int32) vector.
func (*Vector2) SetMax ¶
SetMax sets this vector components to the maximum value of itself and other vector.
func (*Vector2) SetMin ¶
SetMin sets this vector components to the minimum values of itself and other vector.
func (*Vector2) SetMul ¶
SetMul sets this to multiplication with other vector (i.e., *= or times-equals).
func (*Vector2) SetMulScalar ¶
SetMulScalar sets this to multiplication by scalar.
func (*Vector2) SetPoint ¶
SetPoint sets the vector from the given image.Point.
func (*Vector2) SetSub ¶
SetSub sets this to subtraction with other vector (i.e., -= or minus-equals).
func (*Vector2) SetSubScalar ¶
SetSubScalar sets this to subtraction of scalar.
func (*Vector2) SetZero ¶
func (v *Vector2) SetZero()
SetZero sets all of the vector's components to zero.
func (Vector2) SubDim ¶
SubDim returns the vector with the given value subtracted on the given dimension.
func (Vector2) SubScalar ¶
SubScalar subtracts scalar s from each component of this vector and returns new vector.
func (Vector2) ToFixed ¶ added in v0.1.3
ToFixed returns the vector as a fixed.Point26_6.
func (Vector2) ToPoint ¶
ToPoint returns the vector as an image.Point.
func (Vector2) ToPointCeil ¶
ToPointCeil returns the vector as an image.Point with all values [Ceil]ed.
func (Vector2) ToPointFloor ¶
ToPointFloor returns the vector as an image.Point with all values [Floor]ed.
func (Vector2) ToPointRound ¶
ToPointRound returns the vector as an image.Point with all values [Round]ed.
func (Vector2) ToSlice ¶ added in v0.1.3
ToSlice copies this vector's components to the given slice, starting at offset.
func (Vector2) WindowToNDC ¶
WindowToNDC converts window (pixel) coordinates to normalized display coordinates (NDC), using given window size parameters. The Z depth coordinate (0-1) must be set manually or by reading from framebuffer flipY if true means flip the Y axis (top = 0 for windows vs. bottom = 0 for 3D coords)
type Vector2i ¶
Vector2i is a 2D vector/point with X and Y int32 components.
func Vector2iScalar ¶
Vector2iScalar returns a new Vector2i with all components set to the given scalar value.
func (Vector2i) Add ¶
Add adds the other given vector to this one and returns the result as a new vector.
func (Vector2i) AddScalar ¶
AddScalar adds scalar s to each component of this vector and returns new vector.
func (*Vector2i) Clamp ¶
Clamp sets this vector's components to be no less than the corresponding components of min and not greater than the corresponding component of max. Assumes min < max; if this assumption isn't true, it will not operate correctly.
func (Vector2i) Div ¶
Div divides each component of this vector by the corresponding one from other vector and returns resulting vector.
func (Vector2i) DivScalar ¶
DivScalar divides each component of this vector by the scalar s and returns resulting vector. If scalar is zero, returns zero.
func (*Vector2i) FromSlice ¶ added in v0.1.3
FromSlice sets this vector's components from the given slice, starting at offset.
func (Vector2i) Mul ¶
Mul multiplies each component of this vector by the corresponding one from other and returns resulting vector.
func (Vector2i) MulScalar ¶
MulScalar multiplies each component of this vector by the scalar s and returns resulting vector.
func (*Vector2i) SetAddScalar ¶
SetAddScalar sets this to addition with scalar.
func (*Vector2i) SetDivScalar ¶
SetDivScalar sets this to division by scalar.
func (*Vector2i) SetFromVector2 ¶
SetFromVector2 sets from a Vector2 (float32) vector.
func (*Vector2i) SetMax ¶
SetMax sets this vector components to the maximum value of itself and other vector.
func (*Vector2i) SetMin ¶
SetMin sets this vector components to the minimum values of itself and other vector.
func (*Vector2i) SetMul ¶
SetMul sets this to multiplication with other vector (i.e., *= or times-equals).
func (*Vector2i) SetMulScalar ¶
SetMulScalar sets this to multiplication by scalar.
func (*Vector2i) SetSub ¶
SetSub sets this to subtraction with other vector (i.e., -= or minus-equals).
func (*Vector2i) SetSubScalar ¶
SetSubScalar sets this to subtraction of scalar.
func (*Vector2i) SetZero ¶
func (v *Vector2i) SetZero()
SetZero sets all of the vector's components to zero.
type Vector3 ¶
Vector3 is a 3D vector/point with X, Y and Z components.
func BarycoordFromPoint ¶
BarycoordFromPoint returns the barycentric coordinates for the specified point.
func NewEulerAnglesFromMatrix ¶
NewEulerAnglesFromMatrix returns a Vector3 with components as the Euler angles from the specified pure rotation matrix.
func NewVector3Color ¶
NewVector3Color returns a Vector3 from Go standard color.Color (R,G,B components only)
func Vector3FromVector4 ¶
Vector3FromVector4 returns a new Vector3 from the given Vector4.
func Vector3Scalar ¶
Vector3Scalar returns a new Vector3 with all components set to the given scalar value.
func (Vector3) Add ¶
Add adds the other given vector to this one and returns the result as a new vector.
func (Vector3) AddScalar ¶
AddScalar adds scalar s to each component of this vector and returns new vector.
func (Vector3) AngleTo ¶
AngleTo returns the angle between this vector and other. Returns angles in range of -PI to PI (not 0 to 2 PI).
func (*Vector3) Clamp ¶
Clamp sets this vector's components to be no less than the corresponding components of min and not greater than the corresponding component of max. Assumes min < max; if this assumption isn't true, it will not operate correctly.
func (Vector3) CosTo ¶
CosTo returns the cosine (normalized dot product) between this vector and other.
func (Vector3) DistanceTo ¶ added in v0.1.3
DistanceTo returns the distance between these two vectors as points.
func (Vector3) DistanceToSquared ¶ added in v0.1.3
DistanceToSquared returns the squared distance between these two vectors as points.
func (Vector3) Div ¶
Div divides each component of this vector by the corresponding one from other vector and returns resulting vector.
func (Vector3) DivScalar ¶
DivScalar divides each component of this vector by the scalar s and returns resulting vector. If scalar is zero, returns zero.
func (*Vector3) FromSlice ¶ added in v0.1.3
FromSlice sets this vector's components from the given slice, starting at offset.
func (*Vector3) GenGoSet ¶
GenGoSet returns code to set values in object at given path (var.member etc).
func (Vector3) LengthSquared ¶ added in v0.1.3
LengthSquared returns the length squared of this vector. LengthSquared can be used to compare the lengths of vectors without the need to perform a square root.
func (Vector3) Lerp ¶
Lerp returns vector with each components as the linear interpolated value of alpha between itself and the corresponding other component.
func (Vector3) Mul ¶
Mul multiplies each component of this vector by the corresponding one from other and returns resulting vector.
func (Vector3) MulMatrix3 ¶
MulMatrix3 returns the vector multiplied by the given 3x3 matrix.
func (Vector3) MulMatrix4 ¶
MulMatrix4 returns the vector multiplied by the given 4x4 matrix.
func (Vector3) MulMatrix4AsVector4 ¶
MulMatrix4AsVector4 returns 3-dim vector multiplied by specified 4x4 matrix using a 4-dim vector with given 4th dimensional value, then reduced back to a 3-dimensional vector. This is somehow different from just straight MulMatrix4 on the 3-dim vector. Use 0 for normals and 1 for positions as the 4th dim to set.
func (Vector3) MulProjection ¶
MulProjection returns vector multiplied by the projection matrix m.
func (Vector3) MulQuat ¶
MulQuat returns vector multiplied by specified quaternion and then by the quaternion inverse. It basically applies the rotation encoded in the quaternion to this vector.
func (Vector3) MulScalar ¶
MulScalar multiplies each component of this vector by the scalar s and returns resulting vector.
func (Vector3) NDCToWindow ¶
NDCToWindow converts normalized display coordinates (NDC) to window (pixel) coordinates, using given window size parameters. near, far are 0, 1 by default (glDepthRange defaults). flipY if true means flip the Y axis (top = 0 for windows vs. bottom = 0 for 3D coords)
func (*Vector3) ProjectOnPlane ¶
ProjectOnPlane returns vector projected on the plane specified by normal vector.
func (*Vector3) ProjectOnVector ¶
ProjectOnVector returns vector projected on other vector.
func (*Vector3) RandomTangents ¶
RandomTangents computes and returns two arbitrary tangents to the vector.
func (*Vector3) Reflect ¶
Reflect returns vector reflected relative to the normal vector (assumed to be already normalized).
func (Vector3) SRGBFromLinear ¶
SRGBFromLinear returns an SRGB color space value from a linear source
func (Vector3) SRGBToLinear ¶
SRGBToLinear returns a linear color space value from a SRGB source
func (*Vector3) SetAddScalar ¶
SetAddScalar sets this to addition with scalar.
func (*Vector3) SetDivScalar ¶
SetDivScalar sets this to division by scalar.
func (*Vector3) SetEulerAnglesFromMatrix ¶
SetEulerAnglesFromMatrix sets this vector components to the Euler angles from the specified pure rotation matrix.
func (*Vector3) SetEulerAnglesFromQuat ¶
SetEulerAnglesFromQuat sets this vector components to the Euler angles from the specified quaternion.
func (*Vector3) SetFromMatrixPos ¶
SetFromMatrixPos set this vector from the translation coordinates in the specified transformation matrix.
func (*Vector3) SetFromVector3i ¶
SetFromVector3i sets from a Vector3i (int32) vector.
func (*Vector3) SetFromVector4 ¶
SetFromVector4 sets this vector from a Vector4
func (*Vector3) SetMax ¶
SetMax sets this vector components to the maximum value of itself and other vector.
func (*Vector3) SetMin ¶
SetMin sets this vector components to the minimum values of itself and other vector.
func (*Vector3) SetMul ¶
SetMul sets this to multiplication with other vector (i.e., *= or times-equals).
func (*Vector3) SetMulScalar ¶
SetMulScalar sets this to multiplication by scalar.
func (*Vector3) SetNormal ¶
func (v *Vector3) SetNormal()
SetNormal normalizes this vector so its length will be 1.
func (*Vector3) SetSub ¶
SetSub sets this to subtraction with other vector (i.e., -= or minus-equals).
func (*Vector3) SetSubScalar ¶
SetSubScalar sets this to subtraction of scalar.
func (*Vector3) SetZero ¶
func (v *Vector3) SetZero()
SetZero sets all of the vector's components to zero.
type Vector3i ¶
Vector3i is a 3D vector/point with X, Y and Z int32 components.
func Vector3iScalar ¶
Vector3iScalar returns a new Vector3i with all components set to the given scalar value.
func (Vector3i) Add ¶
Add adds the other given vector to this one and returns the result as a new vector.
func (Vector3i) AddScalar ¶
AddScalar adds scalar s to each component of this vector and returns new vector.
func (*Vector3i) Clamp ¶
Clamp sets this vector's components to be no less than the corresponding components of min and not greater than the corresponding component of max. Assumes min < max; if this assumption isn't true, it will not operate correctly.
func (Vector3i) Div ¶
Div divides each component of this vector by the corresponding one from other vector and returns resulting vector.
func (Vector3i) DivScalar ¶
DivScalar divides each component of this vector by the scalar s and returns resulting vector. If scalar is zero, returns zero.
func (*Vector3i) FromSlice ¶ added in v0.1.3
FromSlice sets this vector's components from the given slice, starting at offset.
func (Vector3i) Mul ¶
Mul multiplies each component of this vector by the corresponding one from other and returns resulting vector.
func (Vector3i) MulScalar ¶
MulScalar multiplies each component of this vector by the scalar s and returns resulting vector.
func (*Vector3i) SetAddScalar ¶
SetAddScalar sets this to addition with scalar.
func (*Vector3i) SetDivScalar ¶
SetDivScalar sets this to division by scalar.
func (*Vector3i) SetFromVector3 ¶
SetFromVector3 sets from a Vector3 (float32) vector.
func (*Vector3i) SetMax ¶
SetMax sets this vector components to the maximum value of itself and other vector.
func (*Vector3i) SetMin ¶
SetMin sets this vector components to the minimum values of itself and other vector.
func (*Vector3i) SetMul ¶
SetMul sets this to multiplication with other vector (i.e., *= or times-equals).
func (*Vector3i) SetMulScalar ¶
SetMulScalar sets this to multiplication by scalar.
func (*Vector3i) SetSub ¶
SetSub sets this to subtraction with other vector (i.e., -= or minus-equals).
func (*Vector3i) SetSubScalar ¶
SetSubScalar sets this to subtraction of scalar.
func (*Vector3i) SetZero ¶
func (v *Vector3i) SetZero()
SetZero sets all of the vector's components to zero.
type Vector4 ¶
Vector4 is a vector/point in homogeneous coordinates with X, Y, Z and W components.
func NewVector4Color ¶
NewVector4Color returns a Vector4 from Go standard color.Color (full R,G,B,A components)
func Vector4FromVector3 ¶
Vector4FromVector3 returns a new Vector4 from the given Vector3 and w component.
func Vector4Scalar ¶
Vector4Scalar returns a new Vector4 with all components set to the given scalar value.
func (Vector4) Add ¶
Add adds the other given vector to this one and returns the result as a new vector.
func (Vector4) AddScalar ¶
AddScalar adds scalar s to each component of this vector and returns new vector.
func (*Vector4) Clamp ¶
Clamp sets this vector's components to be no less than the corresponding components of min and not greater than the corresponding component of max. Assumes min < max; if this assumption isn't true, it will not operate correctly.
func (Vector4) Div ¶
Div divides each component of this vector by the corresponding one from other vector and returns resulting vector.
func (Vector4) DivScalar ¶
DivScalar divides each component of this vector by the scalar s and returns resulting vector. If scalar is zero, returns zero.
func (*Vector4) FromSlice ¶ added in v0.1.3
FromSlice sets this vector's components from the given slice, starting at offset.
func (Vector4) LengthSquared ¶ added in v0.1.3
LengthSquared returns the length squared of this vector. LengthSquared can be used to compare the lengths of vectors without the need to perform a square root.
func (Vector4) Lerp ¶
Lerp returns vector with each components as the linear interpolated value of alpha between itself and the corresponding other component.
func (Vector4) Mul ¶
Mul multiplies each component of this vector by the corresponding one from other and returns resulting vector.
func (Vector4) MulMatrix4 ¶
MulMatrix4 returns vector multiplied by specified 4x4 matrix.
func (Vector4) MulScalar ¶
MulScalar multiplies each component of this vector by the scalar s and returns resulting vector.
func (Vector4) PerspDiv ¶
PerspDiv returns the 3-vector of normalized display coordinates (NDC) from given 4-vector By dividing by the 4th W component
func (Vector4) SRGBFromLinear ¶
SRGBFromLinear returns an SRGB color space value from a linear source
func (Vector4) SRGBToLinear ¶
SRGBToLinear returns a linear color space value from a SRGB source
func (*Vector4) SetAddScalar ¶
SetAddScalar sets this to addition with scalar.
func (*Vector4) SetAxisAngleFromQuat ¶
SetAxisAngleFromQuat set this vector to be the axis (x, y, z) and angle (w) of a rotation specified the quaternion q. Assumes q is normalized.
func (*Vector4) SetDivScalar ¶
SetDivScalar sets this to division by scalar.
func (*Vector4) SetFromVector2 ¶
SetFromVector2 sets this vector from a Vector2 with 0,1 for Z,W
func (*Vector4) SetFromVector3 ¶
SetFromVector3 sets this vector from a Vector3 and W
func (*Vector4) SetMax ¶
SetMax sets this vector components to the maximum value of itself and other vector.
func (*Vector4) SetMin ¶
SetMin sets this vector components to the minimum values of itself and other vector.
func (*Vector4) SetMul ¶
SetMul sets this to multiplication with other vector (i.e., *= or times-equals).
func (*Vector4) SetMulScalar ¶
SetMulScalar sets this to multiplication by scalar.
func (*Vector4) SetNormal ¶
func (v *Vector4) SetNormal()
SetNormal normalizes this vector so its length will be 1.
func (*Vector4) SetScalar ¶ added in v0.1.3
SetScalar sets all vector components to the same scalar value.
func (*Vector4) SetSub ¶
SetSub sets this to subtraction with other vector (i.e., -= or minus-equals).
func (*Vector4) SetSubScalar ¶
SetSubScalar sets this to subtraction of scalar.
func (*Vector4) SetZero ¶
func (v *Vector4) SetZero()
SetZero sets all of the vector's components to zero, except for the W component, which it sets to 1, as is standard.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package minmax provides a struct that holds Min and Max values.
|
Package minmax provides a struct that holds Min and Max values. |
Package vecint has vector types for emergent, including Vector2i which is a 2D vector with int values, using the API based on math32.Vector2i.
|
Package vecint has vector types for emergent, including Vector2i which is a 2D vector with int values, using the API based on math32.Vector2i. |