Documentation ¶
Overview ¶
mat32 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 ideomatic Go naming. and again with the go-gl/mathgl library
Index ¶
- Constants
- Variables
- func Abs(v float32) float32
- func Acos(v float32) float32
- func Asin(v float32) float32
- func Atan(v float32) float32
- func Atan2(y, x float32) float32
- func Ceil(v float32) float32
- func Clamp(x, a, b float32) float32
- func ClampInt(x, a, b int) int
- func ContainsPoint(point, a, b, c Vec3) bool
- func CopyFloat32s(trg *[]float32, src []float32)
- func CopyFloat64s(trg *[]float64, src []float64)
- func Cos(v float32) float32
- func DegToRad(degrees float32) float32
- func Floor(v float32) float32
- func FromFixed(x fixed.Int26_6) float32
- func Inf(sign int) float32
- func IntMultiple(val, mod float32) float32
- func IntMultiple64(val, mod float64) float64
- func IsNaN(v float32) bool
- func Max(a, b float32) float32
- func Max32i(a, b int32) int32
- func Min(a, b float32) float32
- func Min32i(a, b int32) int32
- func MinPos(a, b float32) float32
- func Mod(a, b float32) float32
- func NaN() float32
- func ParseAngle32(pstr string) (float32, error)
- func ParseFloat32(pstr string) (float32, error)
- func PointsCheckN(pts []float32, n int, errmsg string) error
- func Pow(a, b float32) float32
- func RadToDeg(radians float32) float32
- func ReadPoints(pstr string) []float32
- func RectFromPosSizeMax(pos, sz Vec2) image.Rectangle
- func RectFromPosSizeMin(pos, sz Vec2) image.Rectangle
- func Round(v float32) float32
- func SetMax(a *float32, b float32)
- func SetMin(a *float32, b float32)
- func Sign(v float32) float32
- func Sin(v float32) float32
- func Sqrt(v float32) float32
- func Tan(v float32) float32
- func ToFixed(x float32) fixed.Int26_6
- func ToFixedPoint(x, y float32) fixed.Point26_6
- func Truncate(val float32, prec int) float32
- func Truncate64(val float64, prec int) float64
- type ArrayF32
- func (a *ArrayF32) Append(v ...float32)
- func (a *ArrayF32) AppendVec2(v ...Vec2)
- func (a *ArrayF32) AppendVec3(v ...Vec3)
- func (a *ArrayF32) AppendVec4(v ...Vec4)
- func (a *ArrayF32) Bytes() int
- func (a *ArrayF32) CopyFrom(src ArrayF32)
- func (a *ArrayF32) Extend(addLen int)
- func (a ArrayF32) GetMat4(pos int, m *Mat4)
- func (a ArrayF32) GetVec2(pos int, v *Vec2)
- func (a ArrayF32) GetVec3(pos int, v *Vec3)
- func (a ArrayF32) GetVec4(pos int, v *Vec4)
- func (a *ArrayF32) Len() int
- func (a ArrayF32) Set(pos int, v ...float32)
- func (a ArrayF32) SetVec2(pos int, v Vec2)
- func (a ArrayF32) SetVec3(pos int, v Vec3)
- func (a ArrayF32) SetVec4(pos int, v Vec4)
- func (a *ArrayF32) Size() int
- type ArrayU32
- type Box2
- func (b *Box2) Center() Vec2
- func (b *Box2) ClampPoint(point Vec2) Vec2
- func (b *Box2) ContainsBox(box Box2) bool
- func (b *Box2) ContainsPoint(point Vec2) bool
- func (b *Box2) DistToPoint(point Vec2) float32
- func (b *Box2) ExpandByPoint(point Vec2)
- func (b *Box2) ExpandByScalar(scalar float32)
- func (b *Box2) ExpandByVector(vector Vec2)
- func (b *Box2) Intersect(other Box2) Box2
- func (b *Box2) IsEmpty() bool
- func (b *Box2) IsEqual(other Box2) bool
- func (b *Box2) IsIntersectionBox(other Box2) bool
- func (b *Box2) Set(min, max *Vec2)
- func (b *Box2) SetEmpty()
- func (b *Box2) SetFromCenterAndSize(center, size Vec2)
- func (b *Box2) SetFromPoints(points []Vec2)
- func (b *Box2) Size() Vec2
- func (b *Box2) Translate(offset Vec2) Box2
- func (b *Box2) Union(other Box2) Box2
- type Box3
- func (b *Box3) Center() Vec3
- func (b *Box3) ClampPoint(point Vec3) Vec3
- func (b *Box3) ContainsBox(box Box3) bool
- func (b *Box3) ContainsPoint(point Vec3) bool
- func (b *Box3) DistToPoint(point Vec3) float32
- func (b *Box3) Expand(box Box3)
- func (b *Box3) ExpandByPoint(point Vec3)
- func (b *Box3) ExpandByPoints(points []Vec3)
- func (b *Box3) ExpandByScalar(scalar float32)
- func (b *Box3) ExpandByVector(vector Vec3)
- func (b *Box3) GetBoundingSphere() Sphere
- func (b *Box3) Intersect(other Box3) Box3
- func (b *Box3) IsEmpty() bool
- func (b *Box3) IsEqual(other Box3) bool
- func (b *Box3) IsIntersectionBox(other Box3) bool
- func (b *Box3) MVProjToNDC(m *Mat4) Box3
- func (b *Box3) MulMat4(m *Mat4) Box3
- func (b *Box3) MulQuat(q Quat) Box3
- func (b *Box3) Set(min, max *Vec3)
- func (b *Box3) SetEmpty()
- func (b *Box3) SetFromCenterAndSize(center, size Vec3)
- func (b *Box3) SetFromPoints(points []Vec3)
- func (b *Box3) Size() Vec3
- func (b *Box3) Translate(offset Vec3) Box3
- func (b *Box3) Union(other Box3) Box3
- type Dims
- type Frustum
- type Line3
- type Mat2
- func (a Mat2) ExtractRot() float32
- func (a Mat2) ExtractScale() (scx, scy float32)
- func (a Mat2) Mul(b Mat2) Mat2
- func (a Mat2) MulVec2AsPt(v Vec2) Vec2
- func (a Mat2) MulVec2AsVec(v Vec2) Vec2
- func (a Mat2) Rotate(angle float32) Mat2
- func (a Mat2) Scale(x, y float32) Mat2
- func (a *Mat2) SetString(str string) error
- func (a Mat2) Shear(x, y float32) Mat2
- func (a Mat2) Skew(x, y float32) Mat2
- func (a Mat2) Translate(x, y float32) Mat2
- type Mat3
- func (m *Mat3) Determinant() float32
- func (m *Mat3) FromArray(array []float32, offset int)
- func (m *Mat3) Inverse() (*Mat3, error)
- func (m *Mat3) Mul(other *Mat3) *Mat3
- func (m *Mat3) MulMatrices(a, b *Mat3)
- func (m *Mat3) MulScalar(s float32)
- func (m *Mat3) MulVec3Array(array []float32, start, count int)
- func (m *Mat3) ScaleCols(v Vec3) *Mat3
- func (m *Mat3) Set(n11, n12, n13, n21, n22, n23, n31, n32, n33 float32)
- func (m *Mat3) SetFromMat4(src *Mat4)
- func (m *Mat3) SetIdentity()
- func (m *Mat3) SetInverse(src *Mat3) error
- func (m *Mat3) SetMul(other *Mat3)
- func (m *Mat3) SetMulScalar(s float32)
- func (m *Mat3) SetNormalMatrix(src *Mat4) error
- func (m *Mat3) SetRotationFromQuat(q Quat)
- func (m *Mat3) SetScaleCols(v Vec3)
- func (m *Mat3) SetTranspose()
- func (m *Mat3) SetZero()
- func (m *Mat3) ToArray(array []float32, offset int)
- func (m *Mat3) Transpose() *Mat3
- type Mat4
- func (m *Mat4) CopyPos(src *Mat4)
- func (m *Mat4) Decompose() (pos Vec3, quat Quat, scale Vec3)
- func (m *Mat4) Determinant() float32
- func (m *Mat4) ExtractBasis() (xAxis, yAxis, zAxis Vec3)
- func (m *Mat4) ExtractRotation(src *Mat4)
- func (m *Mat4) FromArray(array []float32, offset int)
- func (m *Mat4) GetMaxScaleOnAxis() float32
- func (m *Mat4) Inverse() (*Mat4, error)
- func (m *Mat4) LookAt(eye, target, up Vec3)
- func (m *Mat4) Mul(other *Mat4) *Mat4
- func (m *Mat4) MulMatrices(a, b *Mat4)
- func (m *Mat4) MulScalar(s float32)
- func (m *Mat4) MulVec3Array(array []float32, start, count int)
- func (m *Mat4) Pos() Vec3
- func (m *Mat4) ScaleCols(v Vec3) *Mat4
- func (m *Mat4) Set(...)
- func (m *Mat4) SetBasis(xAxis, yAxis, zAxis Vec3)
- func (m *Mat4) SetFromMat3(src *Mat3)
- func (m *Mat4) SetFrustum(left, right, bottom, top, near, far float32)
- func (m *Mat4) SetIdentity()
- func (m *Mat4) SetInverse(src *Mat4) error
- func (m *Mat4) SetMul(other *Mat4)
- func (m *Mat4) SetOrthographic(width, height, near, far float32)
- func (m *Mat4) SetPerspective(fov, aspect, near, far float32)
- func (m *Mat4) SetPos(v Vec3)
- func (m *Mat4) SetRotationAxis(axis *Vec3, angle float32)
- func (m *Mat4) SetRotationFromEuler(euler Vec3)
- func (m *Mat4) SetRotationFromQuat(q Quat)
- func (m *Mat4) SetRotationX(theta float32)
- func (m *Mat4) SetRotationY(theta float32)
- func (m *Mat4) SetRotationZ(theta float32)
- func (m *Mat4) SetScale(x, y, z float32)
- func (m *Mat4) SetScaleCols(v Vec3)
- func (m *Mat4) SetTransform(pos Vec3, quat Quat, scale Vec3)
- func (m *Mat4) SetTranslation(x, y, z float32)
- func (m *Mat4) SetTranspose()
- func (m *Mat4) SetZero()
- func (m *Mat4) ToArray(array []float32, offset int)
- func (m *Mat4) Transpose() *Mat4
- type Plane
- func (p *Plane) CoplanarPoint() Vec3
- func (p *Plane) DistToPoint(point Vec3) float32
- func (p *Plane) DistToSphere(sphere Sphere) float32
- func (p *Plane) IntersectLine(line Line3) (Vec3, bool)
- func (p *Plane) IsEqual(other *Plane) bool
- func (p *Plane) IsIntersectionLine(line Line3) bool
- func (p *Plane) Negate()
- func (p *Plane) Normalize()
- func (p *Plane) Set(normal Vec3, offset float32)
- func (p *Plane) SetDims(x, y, z, w float32)
- func (p *Plane) SetFromCoplanarPoints(a, b, c Vec3)
- func (p *Plane) SetFromNormalAndCoplanarPoint(normal Vec3, point Vec3)
- func (p *Plane) SetTranslate(offset Vec3)
- 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) IsEqual(other Quat) bool
- 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 Vec3, angle float32)
- func (q *Quat) SetFromEuler(euler Vec3)
- func (q *Quat) SetFromRotationMatrix(m *Mat4)
- func (q *Quat) SetFromUnitVectors(vFrom, vTo Vec3)
- 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) ToArray(array []float32, offset int)
- func (q *Quat) ToAxisAngle() Vec4
- func (q *Quat) ToEuler() Vec3
- type Ray
- func (ray *Ray) ApplyMat4(mat4 *Mat4)
- func (ray *Ray) At(t float32) Vec3
- func (ray *Ray) ClosestPointToPoint(point Vec3) Vec3
- func (ray *Ray) DistSqToPoint(point Vec3) float32
- func (ray *Ray) DistSqToSegment(v0, v1 Vec3, optPointOnRay, optPointOnSegment *Vec3) float32
- func (ray *Ray) DistToPlane(plane Plane) float32
- func (ray *Ray) DistToPoint(point Vec3) float32
- func (ray *Ray) IntersectBox(box Box3) (Vec3, bool)
- func (ray *Ray) IntersectPlane(plane Plane) (Vec3, bool)
- func (ray *Ray) IntersectSphere(sphere Sphere) (Vec3, bool)
- func (ray *Ray) IntersectTriangle(a, b, c Vec3, backfaceCulling bool) (Vec3, bool)
- func (ray *Ray) IsEqual(other Ray) bool
- func (ray *Ray) IsIntersectPlane(plane Plane) bool
- func (ray *Ray) IsIntersectionBox(box Box3) bool
- func (ray *Ray) IsIntersectionSphere(sphere Sphere) bool
- func (ray *Ray) Recast(t float32)
- func (ray *Ray) Set(origin, dir Vec3)
- type Sphere
- func (s *Sphere) ClampPoint(point Vec3) Vec3
- func (s *Sphere) ContainsPoint(point Vec3) bool
- func (s *Sphere) DistToPoint(point Vec3) float32
- func (s *Sphere) GetBoundingBox() Box3
- func (s *Sphere) IntersectSphere(other Sphere) bool
- func (s *Sphere) IsEmpty(sphere *Sphere) bool
- func (s *Sphere) MulMat4(mat *Mat4)
- func (s *Sphere) Set(center Vec3, radius float32)
- func (s *Sphere) SetFromBox(box Box3)
- func (s *Sphere) SetFromPoints(points []Vec3, optCenter *Vec3)
- func (s *Sphere) Translate(offset Vec3)
- type Spline
- type Triangle
- func (t *Triangle) Area() float32
- func (t *Triangle) BarycoordFromPoint(point Vec3) Vec3
- func (t *Triangle) ContainsPoint(point Vec3) bool
- func (t *Triangle) IsEqual(tri Triangle) bool
- func (t *Triangle) Midpoint() Vec3
- func (t *Triangle) Normal() Vec3
- func (t *Triangle) Plane() Plane
- func (t *Triangle) Set(a, b, c Vec3)
- func (t *Triangle) SetFromPointsAndIndices(points []Vec3, i0, i1, i2 int)
- type Vec2
- func (v Vec2) Abs() Vec2
- func (v Vec2) Add(other Vec2) Vec2
- func (v Vec2) AddScalar(s float32) Vec2
- func (v Vec2) AlmostEqual(other Vec2, tol float32) bool
- func (v Vec2) Ceil() Vec2
- func (v *Vec2) Clamp(min, max Vec2)
- func (v *Vec2) ClampScalar(minVal, maxVal float32)
- func (v Vec2) Dim(dim Dims) float32
- func (v Vec2) DistTo(other Vec2) float32
- func (v Vec2) DistToSquared(other Vec2) float32
- func (v Vec2) Div(other Vec2) Vec2
- func (v Vec2) DivScalar(scalar float32) Vec2
- func (v Vec2) Dot(other Vec2) float32
- func (a Vec2) Fixed() fixed.Point26_6
- func (v Vec2) Floor() Vec2
- func (v *Vec2) FromArray(array []float32, offset int)
- func (v Vec2) InTriangle(p0, p1, p2 Vec2) bool
- func (v Vec2) IsEqual(other Vec2) bool
- func (v Vec2) IsNil() bool
- func (v Vec2) Length() float32
- func (v Vec2) LengthSq() float32
- func (v Vec2) Lerp(other Vec2, alpha float32) Vec2
- func (v Vec2) Max(other Vec2) Vec2
- func (v Vec2) Min(other Vec2) Vec2
- func (a Vec2) MinPos(b Vec2) Vec2
- func (v Vec2) Mul(other Vec2) Vec2
- func (v Vec2) MulScalar(s float32) Vec2
- func (v Vec2) Negate() Vec2
- func (v Vec2) Normal() Vec2
- func (v *Vec2) Normalize()
- func (v Vec2) Round() Vec2
- func (v *Vec2) Set(x, y float32)
- func (v *Vec2) SetAdd(other Vec2)
- func (a *Vec2) SetAddDim(d Dims, val float32)
- func (v *Vec2) SetAddScalar(s float32)
- func (v *Vec2) SetByName(name string, value float32)
- func (v *Vec2) SetCeil()
- func (v *Vec2) SetDim(dim Dims, value float32)
- func (v *Vec2) SetDiv(other Vec2)
- func (a *Vec2) SetDivDim(d Dims, val float32)
- func (v *Vec2) SetDivScalar(s float32)
- func (a *Vec2) SetFixed(pt fixed.Point26_6)
- func (v *Vec2) SetFloor()
- func (v *Vec2) SetFromVec2i(vi Vec2i)
- func (v *Vec2) SetLength(l float32)
- func (v *Vec2) SetLerp(other Vec2, alpha float32)
- func (v *Vec2) SetMax(other Vec2)
- func (a *Vec2) SetMaxDim(d Dims, val float32)
- func (v *Vec2) SetMaxScalar(val float32)
- func (v *Vec2) SetMin(other Vec2)
- func (a *Vec2) SetMinDim(d Dims, val float32)
- func (v *Vec2) SetMinPos(b Vec2)
- func (a *Vec2) SetMinPosDim(d Dims, val float32)
- func (v *Vec2) SetMinPosScalar(val float32)
- func (v *Vec2) SetMinScalar(val float32)
- func (v *Vec2) SetMul(other Vec2)
- func (a *Vec2) SetMulDim(d Dims, val float32)
- func (v *Vec2) SetMulScalar(s float32)
- func (v *Vec2) SetNegate()
- func (v *Vec2) SetNormal()
- func (a *Vec2) SetPoint(pt image.Point)
- func (v *Vec2) SetRound()
- func (v *Vec2) SetScalar(s float32)
- func (v *Vec2) SetSub(other Vec2)
- func (a *Vec2) SetSubDim(d Dims, val float32)
- func (v *Vec2) SetSubScalar(s float32)
- func (v *Vec2) SetZero()
- func (a Vec2) String() string
- func (v Vec2) Sub(other Vec2) Vec2
- func (v Vec2) SubScalar(s float32) Vec2
- func (v Vec2) ToArray(array []float32, offset int)
- func (a Vec2) ToPoint() image.Point
- func (a Vec2) ToPointCeil() image.Point
- func (a Vec2) ToPointFloor() image.Point
- func (a Vec2) ToPointRound() image.Point
- func (v Vec2) WindowToNDC(size, off Vec2, flipY bool) Vec3
- type Vec2i
- func (v Vec2i) Add(other Vec2i) Vec2i
- func (v Vec2i) AddScalar(s int32) Vec2i
- func (v *Vec2i) Clamp(min, max Vec2i)
- func (v *Vec2i) ClampScalar(minVal, maxVal int32)
- func (v Vec2i) Dim(dim Dims) int32
- func (v Vec2i) Div(other Vec2i) Vec2i
- func (v Vec2i) DivScalar(scalar int32) Vec2i
- func (v *Vec2i) FromArray(array []int32, offset int)
- func (v Vec2i) IsEqual(other Vec2i) bool
- func (v Vec2i) IsNil() bool
- func (v Vec2i) Max(other Vec2i) Vec2i
- func (v Vec2i) Min(other Vec2i) Vec2i
- func (v Vec2i) Mul(other Vec2i) Vec2i
- func (v Vec2i) MulScalar(s int32) Vec2i
- func (v Vec2i) Negate() Vec2i
- func (v *Vec2i) Set(x, y int32)
- func (v *Vec2i) SetAdd(other Vec2i)
- func (v *Vec2i) SetAddScalar(s int32)
- func (v *Vec2i) SetByName(name string, value int32)
- func (v *Vec2i) SetDim(dim Dims, value int32)
- func (v *Vec2i) SetDiv(other Vec2i)
- func (v *Vec2i) SetDivScalar(s int32)
- func (v *Vec2i) SetFromVec2(vf Vec2)
- func (v *Vec2i) SetMax(other Vec2i)
- func (v *Vec2i) SetMin(other Vec2i)
- func (v *Vec2i) SetMul(other Vec2i)
- func (v *Vec2i) SetMulScalar(s int32)
- func (v *Vec2i) SetNegate()
- func (v *Vec2i) SetScalar(s int32)
- func (v *Vec2i) SetSub(other Vec2i)
- func (v *Vec2i) SetSubScalar(s int32)
- func (v *Vec2i) SetZero()
- func (v Vec2i) Sub(other Vec2i) Vec2i
- func (v Vec2i) SubScalar(s int32) Vec2i
- func (v Vec2i) ToArray(array []int32, offset int)
- type Vec3
- func (v Vec3) Abs() Vec3
- func (v Vec3) Add(other Vec3) Vec3
- func (v Vec3) AddScalar(s float32) Vec3
- func (v *Vec3) AlmostEqual(other Vec3, tol float32) bool
- func (v Vec3) AngleTo(other Vec3) float32
- func (v Vec3) Ceil() Vec3
- func (v *Vec3) Clamp(min, max Vec3)
- func (v *Vec3) ClampScalar(minVal, maxVal float32)
- func (v Vec3) CosTo(other Vec3) float32
- func (v Vec3) Cross(other Vec3) Vec3
- func (v Vec3) Dim(dim Dims) float32
- func (v Vec3) DistTo(other Vec3) float32
- func (v Vec3) DistToSquared(other Vec3) float32
- func (v Vec3) Div(other Vec3) Vec3
- func (v Vec3) DivScalar(scalar float32) Vec3
- func (v Vec3) Dot(other Vec3) float32
- func (v Vec3) Floor() Vec3
- func (v *Vec3) FromArray(array []float32, offset int)
- func (v *Vec3) GenGoNew() string
- func (v *Vec3) GenGoSet(path string) string
- func (v Vec3) IsEqual(other Vec3) bool
- func (v Vec3) IsNil() bool
- func (v Vec3) Length() float32
- func (v Vec3) LengthSq() float32
- func (v Vec3) Lerp(other Vec3, alpha float32) Vec3
- func (v Vec3) MVProjToNDC(m *Mat4, w float32) Vec3
- func (v Vec3) Max(other Vec3) Vec3
- func (v Vec3) Min(other Vec3) Vec3
- func (v Vec3) Mul(other Vec3) Vec3
- func (v Vec3) MulMat3(m *Mat3) Vec3
- func (v Vec3) MulMat4(m *Mat4) Vec3
- func (v Vec3) MulMat4AsVec4(m *Mat4, w float32) Vec3
- func (v Vec3) MulProjection(m *Mat4) Vec3
- func (v Vec3) MulQuat(q Quat) Vec3
- func (v Vec3) MulScalar(s float32) Vec3
- func (v Vec3) NDCToWindow(size, off Vec2, near, far float32, flipY bool) Vec3
- func (v Vec3) Negate() Vec3
- func (v Vec3) Normal() Vec3
- func (v *Vec3) Normalize()
- func (v *Vec3) ProjectOnPlane(planeNormal Vec3) Vec3
- func (v *Vec3) ProjectOnVector(other Vec3) Vec3
- func (v *Vec3) RandomTangents() (Vec3, Vec3)
- func (v *Vec3) Reflect(normal Vec3) Vec3
- func (v Vec3) RotateAxisAngle(axis Vec3, angle float32) Vec3
- func (v Vec3) Round() Vec3
- func (v *Vec3) Set(x, y, z float32)
- func (v *Vec3) SetAdd(other Vec3)
- func (v *Vec3) SetAddScalar(s float32)
- func (v *Vec3) SetByName(name string, value float32)
- func (v *Vec3) SetCeil()
- func (v *Vec3) SetDim(dim Dims, value float32)
- func (v *Vec3) SetDiv(other Vec3)
- func (v *Vec3) SetDivScalar(s float32)
- func (v *Vec3) SetEulerAnglesFromMatrix(m *Mat4)
- func (v *Vec3) SetEulerAnglesFromQuat(q Quat)
- func (v *Vec3) SetFloor()
- func (v *Vec3) SetFromMatrixCol(index int, m *Mat4)
- func (v *Vec3) SetFromMatrixPos(m *Mat4)
- func (v *Vec3) SetFromVec3i(vi Vec3i)
- func (v *Vec3) SetFromVec4(other Vec4)
- func (v *Vec3) SetLength(l float32)
- func (v *Vec3) SetLerp(other Vec3, alpha float32)
- func (v *Vec3) SetMax(other Vec3)
- func (v *Vec3) SetMin(other Vec3)
- func (v *Vec3) SetMul(other Vec3)
- func (v *Vec3) SetMulMat3(m *Mat3)
- func (v *Vec3) SetMulMat4(m *Mat4)
- func (v *Vec3) SetMulQuat(q Quat)
- func (v *Vec3) SetMulScalar(s float32)
- func (v *Vec3) SetNegate()
- func (v *Vec3) SetNormal()
- func (v *Vec3) SetRotateAxisAngle(axis Vec3, angle float32)
- func (v *Vec3) SetRound()
- func (v *Vec3) SetScalar(s float32)
- func (v *Vec3) SetSub(other Vec3)
- func (v *Vec3) SetSubScalar(s float32)
- func (v *Vec3) SetZero()
- func (v Vec3) Sub(other Vec3) Vec3
- func (v Vec3) SubScalar(s float32) Vec3
- func (v Vec3) ToArray(array []float32, offset int)
- type Vec3i
- func (v Vec3i) Add(other Vec3i) Vec3i
- func (v Vec3i) AddScalar(s int32) Vec3i
- func (v *Vec3i) Clamp(min, max Vec3i)
- func (v *Vec3i) ClampScalar(minVal, maxVal int32)
- func (v Vec3i) Dim(dim Dims) int32
- func (v Vec3i) Div(other Vec3i) Vec3i
- func (v Vec3i) DivScalar(scalar int32) Vec3i
- func (v *Vec3i) FromArray(array []int32, offset int)
- func (v Vec3i) IsEqual(other Vec3i) bool
- func (v Vec3i) IsNil() bool
- func (v Vec3i) Max(other Vec3i) Vec3i
- func (v Vec3i) Min(other Vec3i) Vec3i
- func (v Vec3i) Mul(other Vec3i) Vec3i
- func (v Vec3i) MulScalar(s int32) Vec3i
- func (v Vec3i) Negate() Vec3i
- func (v *Vec3i) Set(x, y, z int32)
- func (v *Vec3i) SetAdd(other Vec3i)
- func (v *Vec3i) SetAddScalar(s int32)
- func (v *Vec3i) SetByName(name string, value int32)
- func (v *Vec3i) SetDim(dim Dims, value int32)
- func (v *Vec3i) SetDiv(other Vec3i)
- func (v *Vec3i) SetDivScalar(s int32)
- func (v *Vec3i) SetFromVec3(vf Vec3)
- func (v *Vec3i) SetMax(other Vec3i)
- func (v *Vec3i) SetMin(other Vec3i)
- func (v *Vec3i) SetMul(other Vec3i)
- func (v *Vec3i) SetMulScalar(s int32)
- func (v *Vec3i) SetNegate()
- func (v *Vec3i) SetScalar(s int32)
- func (v *Vec3i) SetSub(other Vec3i)
- func (v *Vec3i) SetSubScalar(s int32)
- func (v *Vec3i) SetZero()
- func (v Vec3i) Sub(other Vec3i) Vec3i
- func (v Vec3i) SubScalar(s int32) Vec3i
- func (v Vec3i) ToArray(array []int32, offset int)
- type Vec4
- func (v Vec4) Add(other Vec4) Vec4
- func (v Vec4) AddScalar(s float32) Vec4
- func (v *Vec4) AlmostEqual(other Vec4, tol float32) bool
- func (v Vec4) Ceil() Vec4
- func (v *Vec4) Clamp(min, max Vec4)
- func (v *Vec4) ClampScalar(minVal, maxVal float32)
- func (v Vec4) Dim(dim Dims) float32
- func (v Vec4) Div(other Vec4) Vec4
- func (v Vec4) DivScalar(scalar float32) Vec4
- func (v Vec4) Dot(other Vec4) float32
- func (v Vec4) Floor() Vec4
- func (v *Vec4) FromArray(array []float32, offset int)
- func (v *Vec4) IsEqual(other Vec4) bool
- func (v Vec4) IsNil() bool
- func (v Vec4) Length() float32
- func (v Vec4) LengthSq() float32
- func (v Vec4) Lerp(other Vec4, alpha float32) Vec4
- func (v Vec4) Max(other Vec4) Vec4
- func (v Vec4) Min(other Vec4) Vec4
- func (v Vec4) Mul(other Vec4) Vec4
- func (v Vec4) MulMat4(m *Mat4) Vec4
- func (v Vec4) MulScalar(s float32) Vec4
- func (v Vec4) Negate() Vec4
- func (v Vec4) Normal() Vec4
- func (v *Vec4) Normalize()
- func (v Vec4) PerspDiv() Vec3
- func (v Vec4) Round() Vec4
- func (v *Vec4) Set(x, y, z, w float32)
- func (v *Vec4) SetAdd(other Vec4)
- func (v *Vec4) SetAddScalar(s float32)
- func (v *Vec4) SetAxisAngleFromQuat(q Quat)
- func (v *Vec4) SetAxisFromRotationMatrix(m *Mat4)
- func (v *Vec4) SetByName(name string, value float32)
- func (v *Vec4) SetCeil()
- func (v *Vec4) SetDim(dim Dims, value float32)
- func (v *Vec4) SetDiv(other Vec4)
- func (v *Vec4) SetDivScalar(s float32)
- func (v *Vec4) SetFloor()
- func (v *Vec4) SetFromVec3(other Vec3, w float32)
- func (v *Vec4) SetLength(l float32)
- func (v *Vec4) SetLerp(other *Vec4, alpha float32)
- func (v *Vec4) SetMax(other Vec4)
- func (v *Vec4) SetMin(other Vec4)
- func (v *Vec4) SetMul(other Vec4)
- func (v *Vec4) SetMulScalar(s float32)
- func (v *Vec4) SetNegate()
- func (v *Vec4) SetNormal()
- func (v *Vec4) SetRound()
- func (v *Vec4) SetSub(other Vec4)
- func (v *Vec4) SetSubScalar(s float32)
- func (v *Vec4) SetZero()
- func (v Vec4) Sub(other Vec4) Vec4
- func (v Vec4) SubScalar(s float32) Vec4
- func (v Vec4) ToArray(array []float32, offset int)
Constants ¶
const DegToRadFactor = math.Pi / 180
const Pi = math.Pi
const RadToDegFactor = 180.0 / math.Pi
Variables ¶
var ( Vec2Zero = Vec2{0, 0} Vec2X = Vec2{1, 0} Vec2Y = Vec2{0, 1} )
var ( Vec3Zero = Vec3{0, 0, 0} Vec3X = Vec3{1, 0, 0} Vec3Y = Vec3{0, 1, 0} Vec3Z = Vec3{0, 0, 1} )
var ( Vec4Zero = Vec4{0, 0, 0, 0} Vec4X = Vec4{1, 0, 0, 0} Vec4Y = Vec4{0, 1, 0, 0} Vec4Z = Vec4{0, 0, 1, 0} Vec4W = Vec4{0, 0, 0, 1} )
var Infinity = float32(math.Inf(1))
var KiT_Dims = kit.Enums.AddEnum(DimsN, kit.NotBitFlag, nil)
Functions ¶
func ContainsPoint ¶
ContainsPoint returns whether a triangle contains a point.
func CopyFloat32s ¶
CopyFloat32s copies a []float32 slice from src into target
func CopyFloat64s ¶
CopyFloat64s copies a []float64 slice from src into target
func IntMultiple ¶ added in v0.9.11
IntMultiple returns the interger multiple of mod closest to given value: int(Round(val / mod)) * mod
func IntMultiple64 ¶ added in v0.9.11
IntMultiple64 returns the interger multiple of mod closest to given value: int(Round(val / mod)) * mod
func MinPos ¶ added in v0.9.11
MinPos returns the minimum of the two values, excluding any that are <= 0
func ParseAngle32 ¶ added in v0.9.11
ParseAngle32 returns radians angle from string that can specify units (deg, grad, rad) -- deg is assumed if not specified
func ParseFloat32 ¶ added in v0.9.11
ParseFloat32 logs any strconv.ParseFloat errors
func PointsCheckN ¶ added in v0.9.11
PointsCheckN checks the number of points read and emits an error if not equal to n
func ReadPoints ¶ added in v0.9.11
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 ¶ added in v0.9.11
RectFromPosSizeMax returns an image.Rectangle from max dims of pos, size (floor on pos, ceil on size)
func RectFromPosSizeMin ¶ added in v0.9.11
RectFromPosSizeMin returns an image.Rectangle from min dims of pos, size (ceil on pos, floor on size)
func ToFixedPoint ¶ added in v0.9.11
ToFixedPoint converts float32 x,y values to a fixed.Point26_6
func Truncate ¶ added in v0.9.11
Truncate truncates a floating point number to given level of precision -- slow.. uses string conversion
func Truncate64 ¶ added in v0.9.11
Truncate64 truncates a floating point number to given level of precision -- slow.. uses string conversion
Types ¶
type ArrayF32 ¶
type ArrayF32 []float32
ArrayF32 is a slice of float32 with additional convenience methods
func NewArrayF32 ¶
NewArrayF32 creates a returns a new array of floats with the specified initial size and capacity
func (*ArrayF32) AppendVec2 ¶
AppendVec2 appends any number of Vec2 to the array
func (*ArrayF32) AppendVec3 ¶
AppendVec3 appends any number of Vec3 to the array
func (*ArrayF32) AppendVec4 ¶
AppendVec4 appends any number of Vec4 to the array
func (*ArrayF32) Extend ¶
Extend appends given number of new float elements to end of existing array
func (ArrayF32) GetMat4 ¶
GetMat4 stores in the specified Mat4 the values from the array starting at the specified pos.
func (ArrayF32) GetVec2 ¶
GetVec2 stores in the specified Vec2 the values from the array starting at the specified pos.
func (ArrayF32) GetVec3 ¶
GetVec3 stores in the specified Vec3 the values from the array starting at the specified pos.
func (ArrayF32) GetVec4 ¶
GetVec4 stores in the specified Vec4 the values from the array starting at the specified pos.
func (*ArrayF32) Len ¶
Len returns the number of float32 elements in the array It is equivalent to Size()
func (ArrayF32) Set ¶
Set sets the values of the array starting at the specified pos from the specified values
func (ArrayF32) SetVec2 ¶
SetVec2 sets the values of the array at the specified pos from the XY values of the specified Vec2
func (ArrayF32) SetVec3 ¶
SetVec3 sets the values of the array at the specified pos from the XYZ values of the specified Vec3
type ArrayU32 ¶
type ArrayU32 []uint32
ArrayU32 is a slice of uint32 with additional convenience methods
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 NewBox2 ¶
NewBox2 creates and returns a new Box2 defined by its minimum and maximum coordinates.
func NewEmptyBox2 ¶
func NewEmptyBox2() Box2
NewEmptyBox2 creates and returns a new Box2 with empty min / max
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) DistToPoint ¶
DistToPoint returns the distance from this box to the specified point.
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) IsIntersectionBox ¶
IsIntersectionBox returns if other box intersects this one.
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) Size ¶
Size calculates the size of this bounding box: the vector from its minimum point to its maximum point.
type Box3 ¶
Box3 represents a 3D bounding box defined by two points: the point with minimum coordinates and the point with maximum coordinates.
func NewBox3 ¶
NewBox3 creates and returns a new Box3 defined by its minimum and maximum coordinates.
func NewEmptyBox3 ¶
func NewEmptyBox3() Box3
NewEmptyBox3 creates and returns a new Box3 with empty min / max
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) DistToPoint ¶
DistToPoint returns the distance from this box to the specified point.
func (*Box3) Expand ¶ added in v0.9.11
Expand 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 ¶ added in v0.9.11
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) IsIntersectionBox ¶
IsIntersectionBox returns if other box intersects this one.
func (*Box3) MVProjToNDC ¶ added in v0.9.9
MVProjToNDC projects bounding box through given MVP model-view-projection Mat4 with perspective divide to return normalized display coordinates (NDC).
func (*Box3) MulMat4 ¶
MulMat4 multiplies the specified matrix to the vertices of this bounding box and computes the resulting spanning Box3 of the transformed points
func (*Box3) MulQuat ¶ added in v0.9.9
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 int
Dims is a list of vector dimension (component) names
func (*Dims) FromString ¶
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 Mat4
type Line3 ¶
Line3 represents a 3D line segment defined by a start and an end point.
func (*Line3) DistSq ¶
DistSq returns the square of the distance from the start point to the end point.
type Mat2 ¶ added in v0.9.11
type Mat2 struct {
XX, YX, XY, YY, X0, Y0 float32
}
func Identity2D ¶ added in v0.9.11
func Identity2D() Mat2
func Translate2D ¶ added in v0.9.11
func (Mat2) ExtractRot ¶ added in v0.9.11
ExtractRot extracts the rotation component from a given matrix
func (Mat2) ExtractScale ¶ added in v0.9.11
ExtractXYScale extracts the X and Y scale factors after undoing any rotation present -- i.e., in the original X, Y coordinates
func (Mat2) MulVec2AsPt ¶ added in v0.9.11
MulVec2AsPt multiplies the Vec2 as a point, including adding translations.
func (Mat2) MulVec2AsVec ¶ added in v0.9.11
MulVec2AsVec multiplies the Vec2 as a vector -- does not add translations. This is for directional vectors and not points.
type Mat3 ¶
type Mat3 [9]float32
Mat3 is 3x3 matrix organized internally as column matrix
func NewMat3 ¶
func NewMat3() *Mat3
NewMat3 creates and returns a pointer to a new Mat3 initialized as the identity matrix.
func (*Mat3) Determinant ¶
Determinant calculates and returns the determinant of this matrix.
func (*Mat3) 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 (*Mat3) MulMatrices ¶
MulMatrices sets ths matrix as matrix multiplication a by b (i.e., b*a).
func (*Mat3) MulScalar ¶
MulScalar returns each of this matrix's components multiplied by the specified scalar.
func (*Mat3) MulVec3Array ¶
MulVec3Array 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 (*Mat3) 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 (*Mat3) Set ¶
Set sets all the elements of the matrix row by row starting at row1, column1, row1, column2, row1, column3 and so forth.
func (*Mat3) SetFromMat4 ¶
SetFromMat4 sets the matrix elements based on a Mat4.
func (*Mat3) SetIdentity ¶
func (m *Mat3) SetIdentity()
SetIdentity sets this matrix as the identity matrix.
func (*Mat3) 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 (*Mat3) SetMulScalar ¶
SetMulScalar multiplies each of this matrix's components by the specified scalar.
func (*Mat3) 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 (*Mat3) SetRotationFromQuat ¶
SetRotationFromQuat sets this matrix as a rotation matrix from the specified quaternion.
func (*Mat3) 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.
type Mat4 ¶
type Mat4 [16]float32
Mat4 is 4x4 matrix organized internally as column matrix.
func NewLookAt ¶
NewLookAt returns Mat4 matrix as view transform matrix with origin at eye, looking at target and using the up vector.
func NewMat4 ¶
func NewMat4() *Mat4
NewMat4 creates and returns a pointer to a new Mat4 initialized as the identity matrix.
func (*Mat4) Decompose ¶
Decompose updates the position vector, quaternion and scale from this transformation matrix.
func (*Mat4) Determinant ¶
Determinant calculates and returns the determinat of this matrix.
func (*Mat4) ExtractBasis ¶
ExtractBasis returns the x,y,z basis vectors of this matrix.
func (*Mat4) ExtractRotation ¶
ExtractRotation sets this matrix as rotation matrix from the src transformation matrix.
func (*Mat4) GetMaxScaleOnAxis ¶
GetMaxScaleOnAxis returns the maximum scale value of the 3 axes.
func (*Mat4) 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 (*Mat4) LookAt ¶
LookAt sets this matrix as view transform matrix with origin at eye, looking at target and using the up vector.
func (*Mat4) MulMatrices ¶
MulMatrices sets this matrix as matrix multiplication a by b (i.e. b*a).
func (*Mat4) MulScalar ¶
SetMulScalar multiplies each element of this matrix by the specified scalar.
func (*Mat4) MulVec3Array ¶
MulVec3Array 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 (*Mat4) 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 (*Mat4) Set ¶
func (m *Mat4) 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 (*Mat4) SetFromMat3 ¶
SetFromMat3 sets the matrix elements based on a Mat3, filling in 0's for missing elements
func (*Mat4) SetFrustum ¶
SetFrustum sets this matrix to a projection frustum matrix bounded by the specified planes.
func (*Mat4) SetIdentity ¶
func (m *Mat4) SetIdentity()
SetIdentity sets this matrix as the identity matrix.
func (*Mat4) 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 (*Mat4) SetOrthographic ¶
SetOrthographic sets this matrix to an orthographic projection matrix.
func (*Mat4) 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 (*Mat4) SetPos ¶
SetPos sets this transformation matrix position fields from the specified vector v.
func (*Mat4) SetRotationAxis ¶
SetRotationAxis sets this matrix to a rotation matrix of the specified angle around the specified axis.
func (*Mat4) SetRotationFromEuler ¶
SetRotationFromEuler set this a matrix as a rotation matrix from the specified euler angles.
func (*Mat4) SetRotationFromQuat ¶
SetRotationFromQuat sets this matrix as a rotation matrix from the specified quaternion.
func (*Mat4) SetRotationX ¶
SetRotationX sets this matrix to a rotation matrix of angle theta around the X axis.
func (*Mat4) SetRotationY ¶
SetRotationY sets this matrix to a rotation matrix of angle theta around the Y axis.
func (*Mat4) SetRotationZ ¶
SetRotationZ sets this matrix to a rotation matrix of angle theta around the Z axis.
func (*Mat4) SetScale ¶
SetScale sets this matrix to a scale transformation matrix using the specified x, y and z values.
func (*Mat4) 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 (*Mat4) SetTransform ¶
SetTransform sets this matrix to a transformation matrix for the specified position, rotation specified by the quaternion and scale.
func (*Mat4) SetTranslation ¶
SetTranslation sets this matrix to a translation matrix from the specified x, y and z values.
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) DistToPoint ¶
DistToPoint returns the distance of this plane from point.
func (*Plane) DistToSphere ¶
DistToSphere 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 ¶ added in v0.9.9
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 ¶ added in v0.9.9
ToAxisAngle returns the Vec4 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) ApplyMat4 ¶
MulMat4 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) DistSqToPoint ¶
DistSqToPoint 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) DistSqToSegment ¶
DistSqToSegment returns the smallest squared distance from this ray to the line segment from v0 to v1. If optPointOnRay Vec3 is not nil, it is set with the coordinates of the point on the ray. if optPointOnSegment Vec3 is not nil, it is set with the coordinates of the point on the segment.
func (*Ray) DistToPlane ¶
DistToPlane 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) DistToPoint ¶
DistToPoint 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 false is returne.
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) IsIntersectionBox ¶
IsIntersectionBox returns if this ray intersects the specified box.
func (*Ray) IsIntersectionSphere ¶
IsIntersectionSphere returns if this ray intersects with the specified sphere.
type 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) DistToPoint ¶
DistToPoint 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) 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 Spline ¶
type Spline struct {
// contains filtered or unexported fields
}
func (*Spline) InitFromArray ¶
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 Vec2 ¶
Vec2 is a 2D vector/point with X and Y components.
func NewVec2FmFixed ¶ added in v0.9.11
func NewVec2FmPoint ¶ added in v0.9.11
func NewVec2Scalar ¶
NewVec2Scalar returns a new Vec2 with all components set to scalar.
func (Vec2) AddScalar ¶
AddScalar adds scalar s to each component of this vector and returns new vector.
func (Vec2) AlmostEqual ¶
AlmostEqual returns whether the vector is almost equal to another vector within the specified tolerance.
func (Vec2) Ceil ¶
Ceil returns vector with mat32.Ceil() applied to each of this vector's components.
func (*Vec2) Clamp ¶
Clamp sets this vector 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 (*Vec2) ClampScalar ¶
ClampScalar sets this vector components to be no less than minVal and not greater than maxVal.
func (Vec2) DistToSquared ¶
DistToSquared returns the distance squared of this point to other.
func (Vec2) Div ¶
Div divides each component of this vector by the corresponding one from other vector and returns resulting vector.
func (Vec2) DivScalar ¶
DivScalar divides each component of this vector by the scalar s and returns resulting vector. If scalar is zero, returns zero.
func (Vec2) Floor ¶
Floor returns vector with mat32.Floor() applied to each of this vector's components.
func (*Vec2) FromArray ¶
FromArray sets this vector's components from the specified array and offset.
func (Vec2) InTriangle ¶
InTriangle returns whether the vector is inside the specified triangle.
func (Vec2) LengthSq ¶
LengthSq returns the length squared of this vector. LengthSq can be used to compare vectors' lengths without the need to perform a square root.
func (Vec2) Lerp ¶
Lerp returns vector with each components as the linear interpolated value of alpha between itself and the corresponding other component.
func (Vec2) Mul ¶
Mul multiplies each component of this vector by the corresponding one from other and returns resulting vector.
func (Vec2) MulScalar ¶
MulScalar multiplies each component of this vector by the scalar s and returns resulting vector.
func (*Vec2) Normalize ¶
func (v *Vec2) Normalize()
Normalize normalizes this vector so its length will be 1.
func (Vec2) Round ¶
Round returns vector with mat32.Round() applied to each of this vector's components.
func (*Vec2) SetAddScalar ¶
SetAddScalar sets this to addition with scalar.
func (*Vec2) SetByName ¶
SetByName sets this vector component value by its case insensitive name: "x" or "y".
func (*Vec2) SetCeil ¶
func (v *Vec2) SetCeil()
SetCeil applies mat32.Ceil() to each of this vector's components.
func (*Vec2) SetDivScalar ¶
SetDivScalar sets this to division by scalar.
func (*Vec2) SetFloor ¶
func (v *Vec2) SetFloor()
SetFloor applies mat32.Floor() to each of this vector's components.
func (*Vec2) SetFromVec2i ¶
SetFromVec2i sets from a Vec2i (int32) vector.
func (*Vec2) SetLerp ¶
Lerp sets each of this vector's components to the linear interpolated value of alpha between ifself and the corresponding other component.
func (*Vec2) SetMax ¶
SetMax sets this vector components to the maximum value of itself and other vector.
func (*Vec2) SetMaxDim ¶ added in v0.9.11
set the value along a given dimension to max of current val and new val
func (*Vec2) SetMaxScalar ¶ added in v0.9.11
SetMaxScalar sets to max of current value and scalar val
func (*Vec2) SetMin ¶
SetMin sets this vector components to the minimum values of itself and other vector.
func (*Vec2) SetMinDim ¶ added in v0.9.11
set the value along a given dimension to min of current val and new val
func (*Vec2) SetMinPosDim ¶ added in v0.9.11
set the value along a given dimension to min of current val and new val
func (*Vec2) SetMinPosScalar ¶ added in v0.9.11
SetMinPosScalar sets to minpos of current value and scalar val
func (*Vec2) SetMinScalar ¶ added in v0.9.11
SetMinScalar sets to min of current value and scalar val
func (*Vec2) SetMul ¶
SetMul sets this to multiplication with other vector (i.e., *= or times-equals).
func (*Vec2) SetMulScalar ¶
SetMulScalar sets this to multiplication by scalar.
func (*Vec2) SetNegate ¶
func (v *Vec2) SetNegate()
SetNegate negates each of this vector's components.
func (*Vec2) SetNormal ¶
func (v *Vec2) SetNormal()
SetNormal normalizes this vector so its length will be 1.
func (*Vec2) SetSubScalar ¶
SetSubScalar sets this to subtraction of scalar.
func (*Vec2) SetZero ¶
func (v *Vec2) SetZero()
SetZero sets this vector X and Y components to be zero.
func (Vec2) SubScalar ¶
SubScalar subtracts scalar s from each component of this vector and returns new vector.
func (Vec2) ToPointCeil ¶ added in v0.9.11
func (Vec2) ToPointFloor ¶ added in v0.9.11
func (Vec2) ToPointRound ¶ added in v0.9.11
func (Vec2) WindowToNDC ¶ added in v0.9.9
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 Vec2i ¶
Vec2i is a 2D vector/point with X and Y integer32 components.
func NewVec2iScalar ¶
NewVec2iScalar returns a new Vec2i with all components set to scalar.
func (Vec2i) AddScalar ¶
AddScalar adds scalar s to each component of this vector and returns new vector.
func (*Vec2i) Clamp ¶
Clamp sets this vector 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 (*Vec2i) ClampScalar ¶
ClampScalar sets this vector components to be no less than minVal and not greater than maxVal.
func (Vec2i) Div ¶
Div divides each component of this vector by the corresponding one from other vector and returns resulting vector.
func (Vec2i) DivScalar ¶
DivScalar divides each component of this vector by the scalar s and returns resulting vector. If scalar is zero, returns zero.
func (*Vec2i) FromArray ¶
FromArray sets this vector's components from the specified array and offset.
func (Vec2i) Mul ¶
Mul multiplies each component of this vector by the corresponding one from other and returns resulting vector.
func (Vec2i) MulScalar ¶
MulScalar multiplies each component of this vector by the scalar s and returns resulting vector.
func (*Vec2i) SetAddScalar ¶
SetAddScalar sets this to addition with scalar.
func (*Vec2i) SetByName ¶
SetByName sets this vector component value by its case insensitive name: "x" or "y".
func (*Vec2i) SetDivScalar ¶
SetDivScalar sets this to division by scalar.
func (*Vec2i) SetFromVec2 ¶ added in v0.9.9
SetFromVec2 sets from a Vec2 (float32) vector.
func (*Vec2i) SetMax ¶
SetMax sets this vector components to the maximum value of itself and other vector.
func (*Vec2i) SetMin ¶
SetMin sets this vector components to the minimum values of itself and other vector.
func (*Vec2i) SetMul ¶
SetMul sets this to multiplication with other vector (i.e., *= or times-equals).
func (*Vec2i) SetMulScalar ¶
SetMulScalar sets this to multiplication by scalar.
func (*Vec2i) SetNegate ¶
func (v *Vec2i) SetNegate()
SetNegate negates each of this vector's components.
func (*Vec2i) SetSub ¶
SetSub sets this to subtraction with other vector (i.e., -= or minus-equals).
func (*Vec2i) SetSubScalar ¶
SetSubScalar sets this to subtraction of scalar.
func (*Vec2i) SetZero ¶
func (v *Vec2i) SetZero()
SetZero sets this vector X and Y components to be zero.
type Vec3 ¶
Vec3 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 Vec3 with components as the Euler angles from the specified pure rotation matrix.
func NewVec3FromVec4 ¶
NewVec3FromVec4 returns a new Vec3 from a Vec4
func NewVec3Scalar ¶
NewVec3Scalar returns a new Vec3 with all components set to scalar.
func (Vec3) AddScalar ¶
AddScalar adds scalar s to each component of this vector and returns new vector.
func (*Vec3) AlmostEqual ¶
AlmostEqual returns whether the vector is almost equal to another vector within the specified tolerance.
func (Vec3) Ceil ¶
Ceil returns vector with mat32.Ceil() applied to each of this vector's components.
func (*Vec3) Clamp ¶
Clamp sets this vector 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 (*Vec3) ClampScalar ¶
ClampScalar sets this vector components to be no less than minVal and not greater than maxVal.
func (Vec3) CosTo ¶
CosTo returns the cosine (normalized dot product) between this vector and other.
func (Vec3) DistToSquared ¶
DistToSquared returns the distance squared of this point to other.
func (Vec3) Div ¶
Div divides each component of this vector by the corresponding one from other vector and returns resulting vector.
func (Vec3) DivScalar ¶
DivScalar divides each component of this vector by the scalar s and returns resulting vector. If scalar is zero, returns zero.
func (Vec3) Floor ¶
Floor returns vector with mat32.Floor() applied to each of this vector's components.
func (*Vec3) FromArray ¶
FromArray sets this vector's components from the specified array and offset.
func (*Vec3) GenGoSet ¶ added in v0.9.9
GenGoSet returns code to set values in object at given path (var.member etc)
func (Vec3) LengthSq ¶
LengthSq returns the length squared of this vector. LengthSq can be used to compare vectors' lengths without the need to perform a square root.
func (Vec3) Lerp ¶
Lerp returns vector with each components as the linear interpolated value of alpha between itself and the corresponding other component.
func (Vec3) MVProjToNDC ¶ added in v0.9.9
MVProjToNDC project given vector through given MVP model-view-projection Mat4 and do perspective divide to return normalized display coordinates (NDC). w is value for 4th coordinate -- use 1 for positions, 0 for normals.
func (Vec3) Mul ¶
Mul multiplies each component of this vector by the corresponding one from other and returns resulting vector.
func (Vec3) MulMat4AsVec4 ¶
MulMat4AsVec4 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 MulMat4 on the 3-dim vector. Use 0 for normals and 1 for positions as the 4th dim to set.
func (Vec3) MulProjection ¶
MulProjection returns vector multiplied by the projection matrix m
func (Vec3) 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 (Vec3) MulScalar ¶
MulScalar multiplies each component of this vector by the scalar s and returns resulting vector.
func (Vec3) NDCToWindow ¶ added in v0.9.9
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 (*Vec3) Normalize ¶
func (v *Vec3) Normalize()
Normalize normalizes this vector so its length will be 1.
func (*Vec3) ProjectOnPlane ¶
ProjectOnPlane returns vector projected on the plane specified by normal vector.
func (*Vec3) ProjectOnVector ¶
ProjectOnVector returns vector projected on other vector.
func (*Vec3) RandomTangents ¶
RandomTangents computes and returns two arbitrary tangents to the vector.
func (*Vec3) Reflect ¶
Reflect returns vector reflected relative to the normal vector (assumed to be already normalized).
func (Vec3) RotateAxisAngle ¶
RotateAxisAngle returns vector rotated around axis by angle.
func (Vec3) Round ¶
Round returns vector with mat32.Round() applied to each of this vector's components.
func (*Vec3) SetAddScalar ¶
SetAddScalar sets this to addition with scalar.
func (*Vec3) SetByName ¶
SetByName sets this vector component value by its case insensitive name: "x", "y", or "z".
func (*Vec3) SetCeil ¶
func (v *Vec3) SetCeil()
SetCeil applies mat32.Ceil() to each of this vector's components.
func (*Vec3) SetDivScalar ¶
SetDivScalar sets this to division by scalar.
func (*Vec3) SetEulerAnglesFromMatrix ¶
SetEulerAnglesFromMatrix sets this vector components to the Euler angles from the specified pure rotation matrix.
func (*Vec3) SetEulerAnglesFromQuat ¶
SetEulerAnglesFromQuat sets this vector components to the Euler angles from the specified quaternion.
func (*Vec3) SetFloor ¶
func (v *Vec3) SetFloor()
SetFloor applies mat32.Floor() to each of this vector's components.
func (*Vec3) SetFromMatrixCol ¶
SetFromMatrixCol set this vector with the column at index of the m matrix.
func (*Vec3) SetFromMatrixPos ¶
SetFromMatrixPos set this vector from the translation coordinates in the specified transformation matrix.
func (*Vec3) SetFromVec3i ¶
SetFromVec3i sets from a Vec3i (int32) vector.
func (*Vec3) SetFromVec4 ¶
SetFromVec4 sets this vector from a Vec4
func (*Vec3) SetLength ¶
SetLength sets this vector to have the specified length. If the current length is zero, does nothing.
func (*Vec3) SetLerp ¶
SetLerp sets each of this vector's components to the linear interpolated value of alpha between itself and the corresponding other component.
func (*Vec3) SetMax ¶
SetMax sets this vector components to the maximum value of itself and other vector.
func (*Vec3) SetMin ¶
SetMin sets this vector components to the minimum values of itself and other vector.
func (*Vec3) SetMul ¶
SetMul sets this to multiplication with other vector (i.e., *= or times-equals).
func (*Vec3) SetMulMat3 ¶
SetMulMat3 sets vector multiplied by specified 3x3 matrix.
func (*Vec3) SetMulMat4 ¶
SetMulMat4 sets vector multiplied by specified 4x4 matrix.
func (*Vec3) SetMulQuat ¶
SetMulQuat multiplies vector by specified quaternion and then by the quaternion inverse. It basically applies the rotation encoded in the quaternion to this vector.
func (*Vec3) SetMulScalar ¶
SetMulScalar sets this to multiplication by scalar.
func (*Vec3) SetNegate ¶
func (v *Vec3) SetNegate()
SetNegate negates each of this vector's components.
func (*Vec3) SetNormal ¶
func (v *Vec3) SetNormal()
SetNormal normalizes this vector so its length will be 1.
func (*Vec3) SetRotateAxisAngle ¶
SetRotateAxisAngle sets vector rotated around axis by angle.
func (*Vec3) SetSubScalar ¶
SetSubScalar sets this to subtraction of scalar.
func (*Vec3) SetZero ¶
func (v *Vec3) SetZero()
SetZero sets this vector X, Y and Z components to be zero.
type Vec3i ¶
Vec3i is a 3D vector/point with X, Y and Z int32 components.
func NewVec3iScalar ¶
NewVec3iScalar returns a new Vec3 with all components set to scalar.
func (Vec3i) AddScalar ¶
AddScalar adds scalar s to each component of this vector and returns new vector.
func (*Vec3i) Clamp ¶
Clamp sets this vector 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 (*Vec3i) ClampScalar ¶
ClampScalar sets this vector components to be no less than minVal and not greater than maxVal.
func (Vec3i) Div ¶
Div divides each component of this vector by the corresponding one from other vector and returns resulting vector.
func (Vec3i) DivScalar ¶
DivScalar divides each component of this vector by the scalar s and returns resulting vector. If scalar is zero, returns zero.
func (*Vec3i) FromArray ¶
FromArray sets this vector's components from the specified array and offset
func (Vec3i) Mul ¶
Mul multiplies each component of this vector by the corresponding one from other and returns resulting vector.
func (Vec3i) MulScalar ¶
MulScalar multiplies each component of this vector by the scalar s and returns resulting vector.
func (*Vec3i) SetAddScalar ¶
SetAddScalar sets this to addition with scalar.
func (*Vec3i) SetByName ¶
SetByName sets this vector component value by its case insensitive name: "x", "y", or "z".
func (*Vec3i) SetDivScalar ¶
SetDivScalar sets this to division by scalar.
func (*Vec3i) SetFromVec3 ¶
SetFromVec3 sets from a Vec3 (float32) vector.
func (*Vec3i) SetMax ¶
SetMax sets this vector components to the maximum value of itself and other vector.
func (*Vec3i) SetMin ¶
SetMin sets this vector components to the minimum values of itself and other vector.
func (*Vec3i) SetMul ¶
SetMul sets this to multiplication with other vector (i.e., *= or times-equals).
func (*Vec3i) SetMulScalar ¶
SetMulScalar sets this to multiplication by scalar.
func (*Vec3i) SetNegate ¶
func (v *Vec3i) SetNegate()
SetNegate negates each of this vector's components.
func (*Vec3i) SetSub ¶
SetSub sets this to subtraction with other vector (i.e., -= or minus-equals).
func (*Vec3i) SetSubScalar ¶
SetSubScalar sets this to subtraction of scalar.
func (*Vec3i) SetZero ¶
func (v *Vec3i) SetZero()
SetZero sets this vector X, Y and Z components to be zero.
type Vec4 ¶
Vec4 is a vector/point in homogeneous coordinates with X, Y, Z and W components.
func NewVec4FromVec3 ¶
NewVec4FromVec3 returns a new Vec4 from a Vec3 and W
func NewVec4Scalar ¶
NewVec4Scalar returns a new Vec4 with all components set to scalar.
func (Vec4) AddScalar ¶
AddScalar adds scalar s to each component of this vector and returns new vector.
func (*Vec4) AlmostEqual ¶
AlmostEqual returns whether the vector is almost equal to another vector within the specified tolerance.
func (Vec4) Ceil ¶
Ceil returns vector with mat32.Ceil() applied to each of this vector's components.
func (*Vec4) Clamp ¶
Clamp sets this vector 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 (*Vec4) ClampScalar ¶
ClampScalar sets this vector components to be no less than minVal and not greater than maxVal.
func (Vec4) Div ¶
Div divides each component of this vector by the corresponding one from other vector and returns resulting vector.
func (Vec4) DivScalar ¶
DivScalar divides each component of this vector by the scalar s and returns resulting vector. If scalar is zero, returns zero.
func (Vec4) Floor ¶
Floor returns vector with mat32.Floor() applied to each of this vector's components.
func (*Vec4) FromArray ¶
FromArray sets this vector's components from the specified array and offset
func (Vec4) LengthSq ¶
LengthSq returns the length squared of this vector. LengthSq can be used to compare vectors' lengths without the need to perform a square root.
func (Vec4) Lerp ¶
Lerp returns vector with each components as the linear interpolated value of alpha between itself and the corresponding other component.
func (Vec4) Mul ¶
Mul multiplies each component of this vector by the corresponding one from other and returns resulting vector.
func (Vec4) MulScalar ¶
MulScalar multiplies each component of this vector by the scalar s and returns resulting vector.
func (*Vec4) Normalize ¶
func (v *Vec4) Normalize()
Normalize normalizes this vector so its length will be 1.
func (Vec4) PerspDiv ¶ added in v0.9.9
PerspDiv returns the 3-vector of normalized display coordinates (NDC) from given 4-vector By dividing by the 4th W component
func (Vec4) Round ¶
Round returns vector with mat32.Round() applied to each of this vector's components.
func (*Vec4) SetAddScalar ¶
SetAddScalar sets this to addition with scalar.
func (*Vec4) 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 (*Vec4) SetAxisFromRotationMatrix ¶
SetAxisFromRotationMatrix sets this vector to be the axis (x, y, z) and angle (w) of a rotation specified the matrix m. Assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled).
func (*Vec4) SetByName ¶
SetByName sets this vector component value by its case insensitive name: "x", "y", "z" or "w".
func (*Vec4) SetCeil ¶
func (v *Vec4) SetCeil()
SetCeil applies mat32.Ceil() to each of this vector's components.
func (*Vec4) SetDivScalar ¶
SetDivScalar sets this to division by scalar.
func (*Vec4) SetFloor ¶
func (v *Vec4) SetFloor()
SetFloor applies mat32.Floor() to each of this vector's components.
func (*Vec4) SetFromVec3 ¶
SetFromVec3 sets this vector from a Vec3 and W
func (*Vec4) SetLength ¶
SetLength sets this vector to have the specified length. If the current length is zero, does nothing.
func (*Vec4) SetLerp ¶
SetLerp sets each of this vector's components to the linear interpolated value of alpha between ifself and the corresponding other component.
func (*Vec4) SetMax ¶
SetMax sets this vector components to the maximum value of itself and other vector.
func (*Vec4) SetMin ¶
SetMin sets this vector components to the minimum values of itself and other vector.
func (*Vec4) SetMul ¶
SetMul sets this to multiplication with other vector (i.e., *= or times-equals).
func (*Vec4) SetMulScalar ¶
SetMulScalar sets this to multiplication by scalar.
func (*Vec4) SetNegate ¶
func (v *Vec4) SetNegate()
SetNegate negates each of this vector's components.
func (*Vec4) SetNormal ¶
func (v *Vec4) SetNormal()
SetNormal normalizes this vector so its length will be 1.
func (*Vec4) SetSubScalar ¶
SetSubScalar sets this to subtraction of scalar.
func (*Vec4) SetZero ¶
func (v *Vec4) SetZero()
SetZero sets this vector X, Y and Z components to be zero and W to be one.