mgl32 - pkg.dev

文章推薦指數: 80 %
投票人數:10人

Package mgl[32|64] (an abbreviation of mathgl since the packages were split between 32 and 64-bit versions) is a ... github.com/go-gl/mathgl. WhyGo GetStarted Packages Blog Details Validgo.modfile TheGomodulesystemwasintroducedinGo1.11andistheofficialdependencymanagement solutionforGo. Redistributablelicense Redistributablelicensesplaceminimalrestrictionsonhowsoftwarecanbeused, modified,andredistributed. Taggedversion Moduleswithtaggedversionsgiveimportersmorepredictablebuilds. Stableversion Whenaprojectreachesmajorversionv1itisconsideredstable. Learnmore Repository github.com/go-gl/mathgl Jumpto... Documentation Overview Index Constants Variables Functions Abs(a) CartesianToCylindical(coord) CartesianToSpherical(coord) Clamp(a,low,high) ClampFunc(low,high) CopyMatMN(dst,src) CylindircalToSpherical(rho,phi,z) DegToRad(angle) DisableMemoryPooling() Extract3DScale(m) ExtractMaxScale(m) FloatEqual(a,b) FloatEqualFunc(epsilon) FloatEqualThreshold(a,b,epsilon) GLToScreenCoords(x,y,screenWidth,screenHeight) IsClamped(a,low,high) RadToDeg(angle) ReticulateSplines(ranges,cPoints,withLlamas) Round(v,precision) ScreenToGLCoords(x,y,screenWidth,screenHeight) SetMax(a,b) SetMin(a,b) SphericalToCylindrical(r,theta,phi) Types typeInferMatrixError (me)Error() typeMat2 Diag2(v) Ident2() Mat2FromCols(col0,col1) Mat2FromRows(row0,row1) Rotate2D(angle) (m)Abs() (m1)Add(m2) (m1)ApproxEqual(m2) (m1)ApproxEqualThreshold(m2,threshold) (m1)ApproxFuncEqual(m2,eq) (m)At(row,col) (m)Col(col) (m)Cols() (m)Det() (m)Diag() (m)Index(row,col) (m)Inv() (m)Mat3() (m)Mat4() (m1)Mul(c) (m1)Mul2(m2) (m1)Mul2x1(m2) (m1)Mul2x3(m2) (m1)Mul2x4(m2) (m)Row(row) (m)Rows() (m)Set(row,col,value) (m)SetCol(col,v) (m)SetRow(row,v) (m)String() (m1)Sub(m2) (m)Trace() (m1)Transpose() typeMat2x3 Mat2x3FromCols(col0,col1,col2) Mat2x3FromRows(row0,row1) (m)Abs() (m1)Add(m2) (m1)ApproxEqual(m2) (m1)ApproxEqualThreshold(m2,threshold) (m1)ApproxFuncEqual(m2,eq) (m)At(row,col) (m)Col(col) (m)Cols() (m)Index(row,col) (m1)Mul(c) (m1)Mul3(m2) (m1)Mul3x1(m2) (m1)Mul3x2(m2) (m1)Mul3x4(m2) (m)Row(row) (m)Rows() (m)Set(row,col,value) (m)SetCol(col,v) (m)SetRow(row,v) (m)String() (m1)Sub(m2) (m1)Transpose() typeMat2x4 Mat2x4FromCols(col0,col1,col2,col3) Mat2x4FromRows(row0,row1) (m)Abs() (m1)Add(m2) (m1)ApproxEqual(m2) (m1)ApproxEqualThreshold(m2,threshold) (m1)ApproxFuncEqual(m2,eq) (m)At(row,col) (m)Col(col) (m)Cols() (m)Index(row,col) (m1)Mul(c) (m1)Mul4(m2) (m1)Mul4x1(m2) (m1)Mul4x2(m2) (m1)Mul4x3(m2) (m)Row(row) (m)Rows() (m)Set(row,col,value) (m)SetCol(col,v) (m)SetRow(row,v) (m)String() (m1)Sub(m2) (m1)Transpose() typeMat3 Diag3(v) HomogRotate2D(angle) Ident3() Mat3FromCols(col0,col1,col2) Mat3FromRows(row0,row1,row2) Mat4Normal(m) Rotate3DX(angle) Rotate3DY(angle) Rotate3DZ(angle) Scale2D(scaleX,scaleY) ShearX2D(shear) ShearY2D(shear) Translate2D(Tx,Ty) (m)Abs() (m1)Add(m2) (m1)ApproxEqual(m2) (m1)ApproxEqualThreshold(m2,threshold) (m1)ApproxFuncEqual(m2,eq) (m)At(row,col) (m)Col(col) (m)Cols() (m)Det() (m)Diag() (m)Index(row,col) (m)Inv() (m)Mat2() (m)Mat4() (m1)Mul(c) (m1)Mul3(m2) (m1)Mul3x1(m2) (m1)Mul3x2(m2) (m1)Mul3x4(m2) (m)Row(row) (m)Rows() (m)Set(row,col,value) (m)SetCol(col,v) (m)SetRow(row,v) (m)String() (m1)Sub(m2) (m)Trace() (m1)Transpose() typeMat3x2 Mat3x2FromCols(col0,col1) Mat3x2FromRows(row0,row1,row2) (m)Abs() (m1)Add(m2) (m1)ApproxEqual(m2) (m1)ApproxEqualThreshold(m2,threshold) (m1)ApproxFuncEqual(m2,eq) (m)At(row,col) (m)Col(col) (m)Cols() (m)Index(row,col) (m1)Mul(c) (m1)Mul2(m2) (m1)Mul2x1(m2) (m1)Mul2x3(m2) (m1)Mul2x4(m2) (m)Row(row) (m)Rows() (m)Set(row,col,value) (m)SetCol(col,v) (m)SetRow(row,v) (m)String() (m1)Sub(m2) (m1)Transpose() typeMat3x4 Mat3x4FromCols(col0,col1,col2,col3) Mat3x4FromRows(row0,row1,row2) (m)Abs() (m1)Add(m2) (m1)ApproxEqual(m2) (m1)ApproxEqualThreshold(m2,threshold) (m1)ApproxFuncEqual(m2,eq) (m)At(row,col) (m)Col(col) (m)Cols() (m)Index(row,col) (m1)Mul(c) (m1)Mul4(m2) (m1)Mul4x1(m2) (m1)Mul4x2(m2) (m1)Mul4x3(m2) (m)Row(row) (m)Rows() (m)Set(row,col,value) (m)SetCol(col,v) (m)SetRow(row,v) (m)String() (m1)Sub(m2) (m1)Transpose() typeMat4 Diag4(v) Frustum(left,right,bottom,top,near,far) HomogRotate3D(angle,axis) HomogRotate3DX(angle) HomogRotate3DY(angle) HomogRotate3DZ(angle) Ident4() LookAt(eyeX,eyeY,eyeZ,centerX,centerY,centerZ,upX,upY,upZ) LookAtV(eye,center,up) Mat4FromCols(col0,col1,col2,col3) Mat4FromRows(row0,row1,row2,row3) Ortho(left,right,bottom,top,near,far) Ortho2D(left,right,bottom,top) Perspective(fovy,aspect,near,far) Scale3D(scaleX,scaleY,scaleZ) ShearX3D(shearY,shearZ) ShearY3D(shearX,shearZ) ShearZ3D(shearX,shearY) Translate3D(Tx,Ty,Tz) (m)Abs() (m1)Add(m2) (m1)ApproxEqual(m2) (m1)ApproxEqualThreshold(m2,threshold) (m1)ApproxFuncEqual(m2,eq) (m)At(row,col) (m)Col(col) (m)Cols() (m)Det() (m)Diag() (m)Index(row,col) (m)Inv() (m)Mat2() (m)Mat3() (m1)Mul(c) (m1)Mul4(m2) (m1)Mul4x1(m2) (m1)Mul4x2(m2) (m1)Mul4x3(m2) (m)Row(row) (m)Rows() (m)Set(row,col,value) (m)SetCol(col,v) (m)SetRow(row,v) (m)String() (m1)Sub(m2) (m)Trace() (m1)Transpose() typeMat4x2 Mat4x2FromCols(col0,col1) Mat4x2FromRows(row0,row1,row2,row3) (m)Abs() (m1)Add(m2) (m1)ApproxEqual(m2) (m1)ApproxEqualThreshold(m2,threshold) (m1)ApproxFuncEqual(m2,eq) (m)At(row,col) (m)Col(col) (m)Cols() (m)Index(row,col) (m1)Mul(c) (m1)Mul2(m2) (m1)Mul2x1(m2) (m1)Mul2x3(m2) (m1)Mul2x4(m2) (m)Row(row) (m)Rows() (m)Set(row,col,value) (m)SetCol(col,v) (m)SetRow(row,v) (m)String() (m1)Sub(m2) (m1)Transpose() typeMat4x3 Mat4x3FromCols(col0,col1,col2) Mat4x3FromRows(row0,row1,row2,row3) (m)Abs() (m1)Add(m2) (m1)ApproxEqual(m2) (m1)ApproxEqualThreshold(m2,threshold) (m1)ApproxFuncEqual(m2,eq) (m)At(row,col) (m)Col(col) (m)Cols() (m)Index(row,col) (m1)Mul(c) (m1)Mul3(m2) (m1)Mul3x1(m2) (m1)Mul3x2(m2) (m1)Mul3x4(m2) (m)Row(row) (m)Rows() (m)Set(row,col,value) (m)SetCol(col,v) (m)SetRow(row,v) (m)String() (m1)Sub(m2) (m1)Transpose() typeMatMxN DiagN(dst,diag) IdentN(dst,n) NewMatrix(m,n) NewMatrixFromData(src,m,n) (mat)Add(dst,addend) (mat)ApproxEqual(m2) (mat)ApproxEqualFunc(m2,comp) (mat)ApproxEqualThreshold(m2,epsilon) (mat)At(row,col) (mat)InferMatrix(m) (mat)Mul(dst,c) (mat)MulMxN(dst,mul) (mat)MulNx1(dst,v) (mat)NumCols() (mat)NumRowCols() (mat)NumRows() (mat)Raw() (mat)Reshape(m,n) (mat)Set(row,col,val) (mat)Sub(dst,subtrahend) (mat)Trace() (mat)Transpose(dst) (mat)Zero(m,n) typeNilMatrixError (me)Error() typeQuat AnglesToQuat(angle1,angle2,angle3,order) Mat4ToQuat(m) QuatBetweenVectors(start,dest) QuatIdent() QuatLerp(q1,q2,amount) QuatLookAtV(eye,center,up) QuatNlerp(q1,q2,amount) QuatRotate(angle,axis) QuatSlerp(q1,q2,amount) (q1)Add(q2) (q1)ApproxEqual(q2) (q1)ApproxEqualFunc(q2,f) (q1)ApproxEqualThreshold(q2,epsilon) (q1)Conjugate() (q1)Dot(q2) (q1)Inverse() (q1)Len() (q1)Mat4() (q1)Mul(q2) (q1)Norm() (q1)Normalize() (q1)OrientationEqual(q2) (q1)OrientationEqualThreshold(q2,epsilon) (q1)Rotate(v) (q1)Scale(c) (q1)Sub(q2) (q)X() (q)Y() (q)Z() typeRectangularMatrixError (mse)Error() typeRotationOrder typeVec2 BezierCurve2D(t,cPoints) BezierSplineInterpolate2D(t,ranges,cPoints) Circle(radiusX,radiusY,numSlices) CubicBezierCurve2D(t,cPoint1,cPoint2,cPoint3,cPoint4) MakeBezierCurve2D(numPoints,cPoints) QuadraticBezierCurve2D(t,cPoint1,cPoint2,cPoint3) Rect(width,height) (v1)Add(v2) (v1)ApproxEqual(v2) (v1)ApproxEqualThreshold(v2,threshold) (v1)ApproxFuncEqual(v2,eq) (v1)Dot(v2) (v)Elem() (v1)Len() (v1)LenSqr() (v1)Mul(c) (v1)Normalize() (v1)OuterProd2(v2) (v1)OuterProd3(v2) (v1)OuterProd4(v2) (v1)Sub(v2) (v)Vec3(z) (v)Vec4(z,w) (v)X() (v)Y() typeVec3 BezierCurve3D(t,cPoints) BezierSplineInterpolate3D(t,ranges,cPoints) BezierSurface(u,v,cPoints) CubicBezierCurve3D(t,cPoint1,cPoint2,cPoint3,cPoint4) CylindricalToCartesian(rho,phi,z) MakeBezierCurve3D(numPoints,cPoints) Project(obj,modelview,projection,initialX,initialY,width,height) QuadraticBezierCurve3D(t,cPoint1,cPoint2,cPoint3) SphericalToCartesian(r,theta,phi) TransformCoordinate(v,m) TransformNormal(v,m) UnProject(win,modelview,projection,initialX,initialY,width,height) (v1)Add(v2) (v1)ApproxEqual(v2) (v1)ApproxEqualThreshold(v2,threshold) (v1)ApproxFuncEqual(v2,eq) (v1)Cross(v2) (v1)Dot(v2) (v)Elem() (v1)Len() (v1)LenSqr() (v1)Mul(c) (v1)Normalize() (v1)OuterProd2(v2) (v1)OuterProd3(v2) (v1)OuterProd4(v2) (v1)Sub(v2) (v)Vec2() (v)Vec4(w) (v)X() (v)Y() (v)Z() typeVec4 (v1)Add(v2) (v1)ApproxEqual(v2) (v1)ApproxEqualThreshold(v2,threshold) (v1)ApproxFuncEqual(v2,eq) (v1)Dot(v2) (v)Elem() (v1)Len() (v1)LenSqr() (v1)Mul(c) (v1)Normalize() (v1)OuterProd2(v2) (v1)OuterProd3(v2) (v1)OuterProd4(v2) (v)Quat() (v1)Sub(v2) (v)Vec2() (v)Vec3() (v)W() (v)X() (v)Y() (v)Z() typeVecN NewVecN(n) NewVecNFromData(initial) (vn)Add(dst,subtrahend) (vn)ApproxEqual(vn2) (vn)ApproxEqualFunc(vn2,comp) (vn)ApproxEqualThreshold(vn2,epsilon) (vn)Cap() (vn)Cross(dst,other) (vn)Dot(other) (vn)Get(i) (vn)Len() (vn)LenSqr() (vn)Mul(dst,c) (vn)Normalize(dst) (vn)OuterProd(dst,v2) (vn)Raw() (vn)Resize(n) (vn)Set(i,val) (vn)SetBackingSlice(newSlice) (vn)Size() (vn)Sub(dst,addend) (vn)Vec2() (vn)Vec3() (vn)Vec4() (vn)Zero(n) SourceFiles Directories Documentation Documentation ¶ Overview¶ Packagemgl[32|64](anabbreviationofmathglsincethepackagesweresplitbetween32and64-bitversions) isapureGomathpackagespecializedfor3Dmath,withinspirationfromGLM.Itprovidesstatically-sizedvectorsandmatriceswith compile-timegeneratedcalculationsformostbasicmathoperations.Italsoprovidesseveralbasicgraphicsutilitiessuchasbeziercurvesandsurfaces, generationofbasicprimitiveslikecircles,easycreationofcommonmatricessuchasperspectiveorrotation,andcommonoperationslikeconverting to/fromscreen/OpenGLcoordinatesorProjecting/UnprojectingfromanMVPmatrix.Quaternionsarealsosupported. Thebasicvectorsandmatricesarewrittenwithcodegeneration,solookingdirectlyatthesourcewillprobablybeabitconfusing.IrecommendlookingattheGodoc instead,asallbasicfunctionsaredocumented. ThispackageiswritteninColumnMajorOrdertomakeiteasierwithOpenGL.Thismeansforuniformblocksyoucanusethedefaultordering,andwhenyoucall pass-infunctionsyoucanleavethe"transpose"argumentasfalse. Thepackagenowcontainsvariablesizedvectorsandmatrices.Usingtheseisdiscouraged.Theyexistforcornercaseswhereyouneed"small"matricesthatarestill biggerthan4x4.AnexamplemaybeaJacobeanusedforinversekinematics.Thingslikecomputervisionorgenerallinearalgebraarebestlefttopackages moredirectlysuitedforthattask--OpenCV,BLAS,LAPACK,numpy,gonum(ifyouwanttostayinGo),andsoon. Index¶ Variables funcAbs(afloat32)float32 funcCartesianToCylindical(coordVec3)(rho,phi,zfloat32) funcCartesianToSpherical(coordVec3)(r,theta,phifloat32) funcClamp(a,low,highfloat32)float32 funcClampFunc(low,highfloat32)func(float32)float32 funcCopyMatMN(dst,src*MatMxN) funcCylindircalToSpherical(rho,phi,zfloat32)(r,theta,phi2float32) funcDegToRad(anglefloat32)float32 funcDisableMemoryPooling() funcExtract3DScale(mMat4)(x,y,zfloat32) funcExtractMaxScale(mMat4)float32 funcFloatEqual(a,bfloat32)bool funcFloatEqualFunc(epsilonfloat32)func(float32,float32)bool funcFloatEqualThreshold(a,b,epsilonfloat32)bool funcGLToScreenCoords(x,yfloat32,screenWidth,screenHeightint)(xOut,yOutint) funcIsClamped(a,low,highfloat32)bool funcRadToDeg(anglefloat32)float32 funcReticulateSplines(ranges[][][2]float32,cPoints[][][]Vec2,withLlamasbool) funcRound(vfloat32,precisionint)float32 funcScreenToGLCoords(x,yint,screenWidth,screenHeightint)(xOut,yOutfloat32) funcSetMax(a,b*float32) funcSetMin(a,b*float32) funcSphericalToCylindrical(r,theta,phifloat32)(rho,phi2,zfloat32) typeInferMatrixError func(meInferMatrixError)Error()string typeMat2 funcDiag2(vVec2)Mat2 funcIdent2()Mat2 funcMat2FromCols(col0,col1Vec2)Mat2 funcMat2FromRows(row0,row1Vec2)Mat2 funcRotate2D(anglefloat32)Mat2 func(mMat2)Abs()Mat2 func(m1Mat2)Add(m2Mat2)Mat2 func(m1Mat2)ApproxEqual(m2Mat2)bool func(m1Mat2)ApproxEqualThreshold(m2Mat2,thresholdfloat32)bool func(m1Mat2)ApproxFuncEqual(m2Mat2,eqfunc(float32,float32)bool)bool func(mMat2)At(row,colint)float32 func(mMat2)Col(colint)Vec2 func(mMat2)Cols()(col0,col1Vec2) func(mMat2)Det()float32 func(mMat2)Diag()Vec2 func(mMat2)Index(row,colint)int func(mMat2)Inv()Mat2 func(mMat2)Mat3()Mat3 func(mMat2)Mat4()Mat4 func(m1Mat2)Mul(cfloat32)Mat2 func(m1Mat2)Mul2(m2Mat2)Mat2 func(m1Mat2)Mul2x1(m2Vec2)Vec2 func(m1Mat2)Mul2x3(m2Mat2x3)Mat2x3 func(m1Mat2)Mul2x4(m2Mat2x4)Mat2x4 func(mMat2)Row(rowint)Vec2 func(mMat2)Rows()(row0,row1Vec2) func(m*Mat2)Set(row,colint,valuefloat32) func(m*Mat2)SetCol(colint,vVec2) func(m*Mat2)SetRow(rowint,vVec2) func(mMat2)String()string func(m1Mat2)Sub(m2Mat2)Mat2 func(mMat2)Trace()float32 func(m1Mat2)Transpose()Mat2 typeMat2x3 funcMat2x3FromCols(col0,col1,col2Vec2)Mat2x3 funcMat2x3FromRows(row0,row1Vec3)Mat2x3 func(mMat2x3)Abs()Mat2x3 func(m1Mat2x3)Add(m2Mat2x3)Mat2x3 func(m1Mat2x3)ApproxEqual(m2Mat2x3)bool func(m1Mat2x3)ApproxEqualThreshold(m2Mat2x3,thresholdfloat32)bool func(m1Mat2x3)ApproxFuncEqual(m2Mat2x3,eqfunc(float32,float32)bool)bool func(mMat2x3)At(row,colint)float32 func(mMat2x3)Col(colint)Vec2 func(mMat2x3)Cols()(col0,col1,col2Vec2) func(mMat2x3)Index(row,colint)int func(m1Mat2x3)Mul(cfloat32)Mat2x3 func(m1Mat2x3)Mul3(m2Mat3)Mat2x3 func(m1Mat2x3)Mul3x1(m2Vec3)Vec2 func(m1Mat2x3)Mul3x2(m2Mat3x2)Mat2 func(m1Mat2x3)Mul3x4(m2Mat3x4)Mat2x4 func(mMat2x3)Row(rowint)Vec3 func(mMat2x3)Rows()(row0,row1Vec3) func(m*Mat2x3)Set(row,colint,valuefloat32) func(m*Mat2x3)SetCol(colint,vVec2) func(m*Mat2x3)SetRow(rowint,vVec3) func(mMat2x3)String()string func(m1Mat2x3)Sub(m2Mat2x3)Mat2x3 func(m1Mat2x3)Transpose()Mat3x2 typeMat2x4 funcMat2x4FromCols(col0,col1,col2,col3Vec2)Mat2x4 funcMat2x4FromRows(row0,row1Vec4)Mat2x4 func(mMat2x4)Abs()Mat2x4 func(m1Mat2x4)Add(m2Mat2x4)Mat2x4 func(m1Mat2x4)ApproxEqual(m2Mat2x4)bool func(m1Mat2x4)ApproxEqualThreshold(m2Mat2x4,thresholdfloat32)bool func(m1Mat2x4)ApproxFuncEqual(m2Mat2x4,eqfunc(float32,float32)bool)bool func(mMat2x4)At(row,colint)float32 func(mMat2x4)Col(colint)Vec2 func(mMat2x4)Cols()(col0,col1,col2,col3Vec2) func(mMat2x4)Index(row,colint)int func(m1Mat2x4)Mul(cfloat32)Mat2x4 func(m1Mat2x4)Mul4(m2Mat4)Mat2x4 func(m1Mat2x4)Mul4x1(m2Vec4)Vec2 func(m1Mat2x4)Mul4x2(m2Mat4x2)Mat2 func(m1Mat2x4)Mul4x3(m2Mat4x3)Mat2x3 func(mMat2x4)Row(rowint)Vec4 func(mMat2x4)Rows()(row0,row1Vec4) func(m*Mat2x4)Set(row,colint,valuefloat32) func(m*Mat2x4)SetCol(colint,vVec2) func(m*Mat2x4)SetRow(rowint,vVec4) func(mMat2x4)String()string func(m1Mat2x4)Sub(m2Mat2x4)Mat2x4 func(m1Mat2x4)Transpose()Mat4x2 typeMat3 funcDiag3(vVec3)Mat3 funcHomogRotate2D(anglefloat32)Mat3 funcIdent3()Mat3 funcMat3FromCols(col0,col1,col2Vec3)Mat3 funcMat3FromRows(row0,row1,row2Vec3)Mat3 funcMat4Normal(mMat4)Mat3 funcRotate3DX(anglefloat32)Mat3 funcRotate3DY(anglefloat32)Mat3 funcRotate3DZ(anglefloat32)Mat3 funcScale2D(scaleX,scaleYfloat32)Mat3 funcShearX2D(shearfloat32)Mat3 funcShearY2D(shearfloat32)Mat3 funcTranslate2D(Tx,Tyfloat32)Mat3 func(mMat3)Abs()Mat3 func(m1Mat3)Add(m2Mat3)Mat3 func(m1Mat3)ApproxEqual(m2Mat3)bool func(m1Mat3)ApproxEqualThreshold(m2Mat3,thresholdfloat32)bool func(m1Mat3)ApproxFuncEqual(m2Mat3,eqfunc(float32,float32)bool)bool func(mMat3)At(row,colint)float32 func(mMat3)Col(colint)Vec3 func(mMat3)Cols()(col0,col1,col2Vec3) func(mMat3)Det()float32 func(mMat3)Diag()Vec3 func(mMat3)Index(row,colint)int func(mMat3)Inv()Mat3 func(mMat3)Mat2()Mat2 func(mMat3)Mat4()Mat4 func(m1Mat3)Mul(cfloat32)Mat3 func(m1Mat3)Mul3(m2Mat3)Mat3 func(m1Mat3)Mul3x1(m2Vec3)Vec3 func(m1Mat3)Mul3x2(m2Mat3x2)Mat3x2 func(m1Mat3)Mul3x4(m2Mat3x4)Mat3x4 func(mMat3)Row(rowint)Vec3 func(mMat3)Rows()(row0,row1,row2Vec3) func(m*Mat3)Set(row,colint,valuefloat32) func(m*Mat3)SetCol(colint,vVec3) func(m*Mat3)SetRow(rowint,vVec3) func(mMat3)String()string func(m1Mat3)Sub(m2Mat3)Mat3 func(mMat3)Trace()float32 func(m1Mat3)Transpose()Mat3 typeMat3x2 funcMat3x2FromCols(col0,col1Vec3)Mat3x2 funcMat3x2FromRows(row0,row1,row2Vec2)Mat3x2 func(mMat3x2)Abs()Mat3x2 func(m1Mat3x2)Add(m2Mat3x2)Mat3x2 func(m1Mat3x2)ApproxEqual(m2Mat3x2)bool func(m1Mat3x2)ApproxEqualThreshold(m2Mat3x2,thresholdfloat32)bool func(m1Mat3x2)ApproxFuncEqual(m2Mat3x2,eqfunc(float32,float32)bool)bool func(mMat3x2)At(row,colint)float32 func(mMat3x2)Col(colint)Vec3 func(mMat3x2)Cols()(col0,col1Vec3) func(mMat3x2)Index(row,colint)int func(m1Mat3x2)Mul(cfloat32)Mat3x2 func(m1Mat3x2)Mul2(m2Mat2)Mat3x2 func(m1Mat3x2)Mul2x1(m2Vec2)Vec3 func(m1Mat3x2)Mul2x3(m2Mat2x3)Mat3 func(m1Mat3x2)Mul2x4(m2Mat2x4)Mat3x4 func(mMat3x2)Row(rowint)Vec2 func(mMat3x2)Rows()(row0,row1,row2Vec2) func(m*Mat3x2)Set(row,colint,valuefloat32) func(m*Mat3x2)SetCol(colint,vVec3) func(m*Mat3x2)SetRow(rowint,vVec2) func(mMat3x2)String()string func(m1Mat3x2)Sub(m2Mat3x2)Mat3x2 func(m1Mat3x2)Transpose()Mat2x3 typeMat3x4 funcMat3x4FromCols(col0,col1,col2,col3Vec3)Mat3x4 funcMat3x4FromRows(row0,row1,row2Vec4)Mat3x4 func(mMat3x4)Abs()Mat3x4 func(m1Mat3x4)Add(m2Mat3x4)Mat3x4 func(m1Mat3x4)ApproxEqual(m2Mat3x4)bool func(m1Mat3x4)ApproxEqualThreshold(m2Mat3x4,thresholdfloat32)bool func(m1Mat3x4)ApproxFuncEqual(m2Mat3x4,eqfunc(float32,float32)bool)bool func(mMat3x4)At(row,colint)float32 func(mMat3x4)Col(colint)Vec3 func(mMat3x4)Cols()(col0,col1,col2,col3Vec3) func(mMat3x4)Index(row,colint)int func(m1Mat3x4)Mul(cfloat32)Mat3x4 func(m1Mat3x4)Mul4(m2Mat4)Mat3x4 func(m1Mat3x4)Mul4x1(m2Vec4)Vec3 func(m1Mat3x4)Mul4x2(m2Mat4x2)Mat3x2 func(m1Mat3x4)Mul4x3(m2Mat4x3)Mat3 func(mMat3x4)Row(rowint)Vec4 func(mMat3x4)Rows()(row0,row1,row2Vec4) func(m*Mat3x4)Set(row,colint,valuefloat32) func(m*Mat3x4)SetCol(colint,vVec3) func(m*Mat3x4)SetRow(rowint,vVec4) func(mMat3x4)String()string func(m1Mat3x4)Sub(m2Mat3x4)Mat3x4 func(m1Mat3x4)Transpose()Mat4x3 typeMat4 funcDiag4(vVec4)Mat4 funcFrustum(left,right,bottom,top,near,farfloat32)Mat4 funcHomogRotate3D(anglefloat32,axisVec3)Mat4 funcHomogRotate3DX(anglefloat32)Mat4 funcHomogRotate3DY(anglefloat32)Mat4 funcHomogRotate3DZ(anglefloat32)Mat4 funcIdent4()Mat4 funcLookAt(eyeX,eyeY,eyeZ,centerX,centerY,centerZ,upX,upY,upZfloat32)Mat4 funcLookAtV(eye,center,upVec3)Mat4 funcMat4FromCols(col0,col1,col2,col3Vec4)Mat4 funcMat4FromRows(row0,row1,row2,row3Vec4)Mat4 funcOrtho(left,right,bottom,top,near,farfloat32)Mat4 funcOrtho2D(left,right,bottom,topfloat32)Mat4 funcPerspective(fovy,aspect,near,farfloat32)Mat4 funcScale3D(scaleX,scaleY,scaleZfloat32)Mat4 funcShearX3D(shearY,shearZfloat32)Mat4 funcShearY3D(shearX,shearZfloat32)Mat4 funcShearZ3D(shearX,shearYfloat32)Mat4 funcTranslate3D(Tx,Ty,Tzfloat32)Mat4 func(mMat4)Abs()Mat4 func(m1Mat4)Add(m2Mat4)Mat4 func(m1Mat4)ApproxEqual(m2Mat4)bool func(m1Mat4)ApproxEqualThreshold(m2Mat4,thresholdfloat32)bool func(m1Mat4)ApproxFuncEqual(m2Mat4,eqfunc(float32,float32)bool)bool func(mMat4)At(row,colint)float32 func(mMat4)Col(colint)Vec4 func(mMat4)Cols()(col0,col1,col2,col3Vec4) func(mMat4)Det()float32 func(mMat4)Diag()Vec4 func(mMat4)Index(row,colint)int func(mMat4)Inv()Mat4 func(mMat4)Mat2()Mat2 func(mMat4)Mat3()Mat3 func(m1Mat4)Mul(cfloat32)Mat4 func(m1Mat4)Mul4(m2Mat4)Mat4 func(m1Mat4)Mul4x1(m2Vec4)Vec4 func(m1Mat4)Mul4x2(m2Mat4x2)Mat4x2 func(m1Mat4)Mul4x3(m2Mat4x3)Mat4x3 func(mMat4)Row(rowint)Vec4 func(mMat4)Rows()(row0,row1,row2,row3Vec4) func(m*Mat4)Set(row,colint,valuefloat32) func(m*Mat4)SetCol(colint,vVec4) func(m*Mat4)SetRow(rowint,vVec4) func(mMat4)String()string func(m1Mat4)Sub(m2Mat4)Mat4 func(mMat4)Trace()float32 func(m1Mat4)Transpose()Mat4 typeMat4x2 funcMat4x2FromCols(col0,col1Vec4)Mat4x2 funcMat4x2FromRows(row0,row1,row2,row3Vec2)Mat4x2 func(mMat4x2)Abs()Mat4x2 func(m1Mat4x2)Add(m2Mat4x2)Mat4x2 func(m1Mat4x2)ApproxEqual(m2Mat4x2)bool func(m1Mat4x2)ApproxEqualThreshold(m2Mat4x2,thresholdfloat32)bool func(m1Mat4x2)ApproxFuncEqual(m2Mat4x2,eqfunc(float32,float32)bool)bool func(mMat4x2)At(row,colint)float32 func(mMat4x2)Col(colint)Vec4 func(mMat4x2)Cols()(col0,col1Vec4) func(mMat4x2)Index(row,colint)int func(m1Mat4x2)Mul(cfloat32)Mat4x2 func(m1Mat4x2)Mul2(m2Mat2)Mat4x2 func(m1Mat4x2)Mul2x1(m2Vec2)Vec4 func(m1Mat4x2)Mul2x3(m2Mat2x3)Mat4x3 func(m1Mat4x2)Mul2x4(m2Mat2x4)Mat4 func(mMat4x2)Row(rowint)Vec2 func(mMat4x2)Rows()(row0,row1,row2,row3Vec2) func(m*Mat4x2)Set(row,colint,valuefloat32) func(m*Mat4x2)SetCol(colint,vVec4) func(m*Mat4x2)SetRow(rowint,vVec2) func(mMat4x2)String()string func(m1Mat4x2)Sub(m2Mat4x2)Mat4x2 func(m1Mat4x2)Transpose()Mat2x4 typeMat4x3 funcMat4x3FromCols(col0,col1,col2Vec4)Mat4x3 funcMat4x3FromRows(row0,row1,row2,row3Vec3)Mat4x3 func(mMat4x3)Abs()Mat4x3 func(m1Mat4x3)Add(m2Mat4x3)Mat4x3 func(m1Mat4x3)ApproxEqual(m2Mat4x3)bool func(m1Mat4x3)ApproxEqualThreshold(m2Mat4x3,thresholdfloat32)bool func(m1Mat4x3)ApproxFuncEqual(m2Mat4x3,eqfunc(float32,float32)bool)bool func(mMat4x3)At(row,colint)float32 func(mMat4x3)Col(colint)Vec4 func(mMat4x3)Cols()(col0,col1,col2Vec4) func(mMat4x3)Index(row,colint)int func(m1Mat4x3)Mul(cfloat32)Mat4x3 func(m1Mat4x3)Mul3(m2Mat3)Mat4x3 func(m1Mat4x3)Mul3x1(m2Vec3)Vec4 func(m1Mat4x3)Mul3x2(m2Mat3x2)Mat4x2 func(m1Mat4x3)Mul3x4(m2Mat3x4)Mat4 func(mMat4x3)Row(rowint)Vec3 func(mMat4x3)Rows()(row0,row1,row2,row3Vec3) func(m*Mat4x3)Set(row,colint,valuefloat32) func(m*Mat4x3)SetCol(colint,vVec4) func(m*Mat4x3)SetRow(rowint,vVec3) func(mMat4x3)String()string func(m1Mat4x3)Sub(m2Mat4x3)Mat4x3 func(m1Mat4x3)Transpose()Mat3x4 typeMatMxN funcDiagN(dst*MatMxN,diag*VecN)*MatMxN funcIdentN(dst*MatMxN,nint)*MatMxN funcNewMatrix(m,nint)(mat*MatMxN) funcNewMatrixFromData(src[]float32,m,nint)*MatMxN func(mat*MatMxN)Add(dst*MatMxN,addend*MatMxN)*MatMxN func(mat*MatMxN)ApproxEqual(m2*MatMxN)bool func(mat*MatMxN)ApproxEqualFunc(m2*MatMxN,compfunc(float32,float32)bool)bool func(mat*MatMxN)ApproxEqualThreshold(m2*MatMxN,epsilonfloat32)bool func(mat*MatMxN)At(row,colint)float32 func(mat*MatMxN)InferMatrix(minterface{})(*MatMxN,error) func(mat*MatMxN)Mul(dst*MatMxN,cfloat32)*MatMxN func(mat*MatMxN)MulMxN(dst*MatMxN,mul*MatMxN)*MatMxN func(mat*MatMxN)MulNx1(dst,v*VecN)*VecN func(mat*MatMxN)NumCols()int func(mat*MatMxN)NumRowCols()(rows,colsint) func(mat*MatMxN)NumRows()int func(mat*MatMxN)Raw()[]float32 func(mat*MatMxN)Reshape(m,nint)*MatMxN func(mat*MatMxN)Set(row,colint,valfloat32) func(mat*MatMxN)Sub(dst*MatMxN,subtrahend*MatMxN)*MatMxN func(mat*MatMxN)Trace()float32 func(mat*MatMxN)Transpose(dst*MatMxN)(t*MatMxN) func(mat*MatMxN)Zero(m,nint) typeNilMatrixError func(meNilMatrixError)Error()string typeQuat funcAnglesToQuat(angle1,angle2,angle3float32,orderRotationOrder)Quat funcMat4ToQuat(mMat4)Quat funcQuatBetweenVectors(start,destVec3)Quat funcQuatIdent()Quat funcQuatLerp(q1,q2Quat,amountfloat32)Quat funcQuatLookAtV(eye,center,upVec3)Quat funcQuatNlerp(q1,q2Quat,amountfloat32)Quat funcQuatRotate(anglefloat32,axisVec3)Quat funcQuatSlerp(q1,q2Quat,amountfloat32)Quat func(q1Quat)Add(q2Quat)Quat func(q1Quat)ApproxEqual(q2Quat)bool func(q1Quat)ApproxEqualFunc(q2Quat,ffunc(float32,float32)bool)bool func(q1Quat)ApproxEqualThreshold(q2Quat,epsilonfloat32)bool func(q1Quat)Conjugate()Quat func(q1Quat)Dot(q2Quat)float32 func(q1Quat)Inverse()Quat func(q1Quat)Len()float32 func(q1Quat)Mat4()Mat4 func(q1Quat)Mul(q2Quat)Quat func(q1Quat)Norm()float32 func(q1Quat)Normalize()Quat func(q1Quat)OrientationEqual(q2Quat)bool func(q1Quat)OrientationEqualThreshold(q2Quat,epsilonfloat32)bool func(q1Quat)Rotate(vVec3)Vec3 func(q1Quat)Scale(cfloat32)Quat func(q1Quat)Sub(q2Quat)Quat func(qQuat)X()float32 func(qQuat)Y()float32 func(qQuat)Z()float32 typeRectangularMatrixError func(mseRectangularMatrixError)Error()string typeRotationOrder typeVec2 funcBezierCurve2D(tfloat32,cPoints[]Vec2)Vec2 funcBezierSplineInterpolate2D(tfloat32,ranges[][2]float32,cPoints[][]Vec2)Vec2 funcCircle(radiusX,radiusYfloat32,numSlicesint)[]Vec2 funcCubicBezierCurve2D(tfloat32,cPoint1,cPoint2,cPoint3,cPoint4Vec2)Vec2 funcMakeBezierCurve2D(numPointsint,cPoints[]Vec2)(line[]Vec2) funcQuadraticBezierCurve2D(tfloat32,cPoint1,cPoint2,cPoint3Vec2)Vec2 funcRect(width,heightfloat32)[]Vec2 func(v1Vec2)Add(v2Vec2)Vec2 func(v1Vec2)ApproxEqual(v2Vec2)bool func(v1Vec2)ApproxEqualThreshold(v2Vec2,thresholdfloat32)bool func(v1Vec2)ApproxFuncEqual(v2Vec2,eqfunc(float32,float32)bool)bool func(v1Vec2)Dot(v2Vec2)float32 func(vVec2)Elem()(x,yfloat32) func(v1Vec2)Len()float32 func(v1Vec2)LenSqr()float32 func(v1Vec2)Mul(cfloat32)Vec2 func(v1Vec2)Normalize()Vec2 func(v1Vec2)OuterProd2(v2Vec2)Mat2 func(v1Vec2)OuterProd3(v2Vec3)Mat2x3 func(v1Vec2)OuterProd4(v2Vec4)Mat2x4 func(v1Vec2)Sub(v2Vec2)Vec2 func(vVec2)Vec3(zfloat32)Vec3 func(vVec2)Vec4(z,wfloat32)Vec4 func(vVec2)X()float32 func(vVec2)Y()float32 typeVec3 funcBezierCurve3D(tfloat32,cPoints[]Vec3)Vec3 funcBezierSplineInterpolate3D(tfloat32,ranges[][2]float32,cPoints[][]Vec3)Vec3 funcBezierSurface(u,vfloat32,cPoints[][]Vec3)Vec3 funcCubicBezierCurve3D(tfloat32,cPoint1,cPoint2,cPoint3,cPoint4Vec3)Vec3 funcCylindricalToCartesian(rho,phi,zfloat32)Vec3 funcMakeBezierCurve3D(numPointsint,cPoints[]Vec3)(line[]Vec3) funcProject(objVec3,modelview,projectionMat4,initialX,initialY,width,heightint)(winVec3) funcQuadraticBezierCurve3D(tfloat32,cPoint1,cPoint2,cPoint3Vec3)Vec3 funcSphericalToCartesian(r,theta,phifloat32)Vec3 funcTransformCoordinate(vVec3,mMat4)Vec3 funcTransformNormal(vVec3,mMat4)Vec3 funcUnProject(winVec3,modelview,projectionMat4,initialX,initialY,width,heightint)(objVec3,errerror) func(v1Vec3)Add(v2Vec3)Vec3 func(v1Vec3)ApproxEqual(v2Vec3)bool func(v1Vec3)ApproxEqualThreshold(v2Vec3,thresholdfloat32)bool func(v1Vec3)ApproxFuncEqual(v2Vec3,eqfunc(float32,float32)bool)bool func(v1Vec3)Cross(v2Vec3)Vec3 func(v1Vec3)Dot(v2Vec3)float32 func(vVec3)Elem()(x,y,zfloat32) func(v1Vec3)Len()float32 func(v1Vec3)LenSqr()float32 func(v1Vec3)Mul(cfloat32)Vec3 func(v1Vec3)Normalize()Vec3 func(v1Vec3)OuterProd2(v2Vec2)Mat3x2 func(v1Vec3)OuterProd3(v2Vec3)Mat3 func(v1Vec3)OuterProd4(v2Vec4)Mat3x4 func(v1Vec3)Sub(v2Vec3)Vec3 func(vVec3)Vec2()Vec2 func(vVec3)Vec4(wfloat32)Vec4 func(vVec3)X()float32 func(vVec3)Y()float32 func(vVec3)Z()float32 typeVec4 func(v1Vec4)Add(v2Vec4)Vec4 func(v1Vec4)ApproxEqual(v2Vec4)bool func(v1Vec4)ApproxEqualThreshold(v2Vec4,thresholdfloat32)bool func(v1Vec4)ApproxFuncEqual(v2Vec4,eqfunc(float32,float32)bool)bool func(v1Vec4)Dot(v2Vec4)float32 func(vVec4)Elem()(x,y,z,wfloat32) func(v1Vec4)Len()float32 func(v1Vec4)LenSqr()float32 func(v1Vec4)Mul(cfloat32)Vec4 func(v1Vec4)Normalize()Vec4 func(v1Vec4)OuterProd2(v2Vec2)Mat4x2 func(v1Vec4)OuterProd3(v2Vec3)Mat4x3 func(v1Vec4)OuterProd4(v2Vec4)Mat4 func(vVec4)Quat()Quat func(v1Vec4)Sub(v2Vec4)Vec4 func(vVec4)Vec2()Vec2 func(vVec4)Vec3()Vec3 func(vVec4)W()float32 func(vVec4)X()float32 func(vVec4)Y()float32 func(vVec4)Z()float32 typeVecN funcNewVecN(nint)*VecN funcNewVecNFromData(initial[]float32)*VecN func(vn*VecN)Add(dst*VecN,subtrahend*VecN)*VecN func(vn*VecN)ApproxEqual(vn2*VecN)bool func(vn*VecN)ApproxEqualFunc(vn2*VecN,compfunc(float32,float32)bool)bool func(vn*VecN)ApproxEqualThreshold(vn2*VecN,epsilonfloat32)bool func(vn*VecN)Cap()int func(vn*VecN)Cross(dst*VecN,other*VecN)*VecN func(vn*VecN)Dot(other*VecN)float32 func(vnVecN)Get(iint)float32 func(vn*VecN)Len()float32 func(vn*VecN)LenSqr()float32 func(vn*VecN)Mul(dst*VecN,cfloat32)*VecN func(vn*VecN)Normalize(dst*VecN)*VecN func(vn*VecN)OuterProd(dst*MatMxN,v2*VecN)*MatMxN func(vnVecN)Raw()[]float32 func(vn*VecN)Resize(nint)*VecN func(vn*VecN)Set(iint,valfloat32) func(vn*VecN)SetBackingSlice(newSlice[]float32) func(vn*VecN)Size()int func(vn*VecN)Sub(dst*VecN,addend*VecN)*VecN func(vn*VecN)Vec2()Vec2 func(vn*VecN)Vec3()Vec3 func(vn*VecN)Vec4()Vec4 func(vn*VecN)Zero(nint) Constants¶ Thissectionisempty. Variables¶ ViewSource var( MinNormal=float32(1.1754943508222875e-38)//1/2**(127-1) MinValue=float32(math.SmallestNonzeroFloat32) MaxValue=float32(math.MaxFloat32) InfPos=float32(math.Inf(1)) InfNeg=float32(math.Inf(-1)) NaN=float32(math.NaN()) ) Varioususefulconstants. ViewSource varEpsilonfloat32=1e-10 Epsilonissometinyvaluethatdetermineshowpreciselyequalwewantourfloatstobe Thisisexportedandleftasavariableincaseyouwanttochangethedefaultthresholdforthe purposesofcertainmethods(e.g.Unprojectusesthedefaultepsilonwhendetermining ifthedeterminantis"closeenough"tozerotomeanthere'snoinverse). Thisis,obviously,notmutexprotectedsobe**absolutelysure**thatnofunctionsusingEpsilon arebeingexecutedwhenyouchangethis. Functions¶ funcAbs¶ funcAbs(afloat32)float32 Absisadirectcopyofthemathpackage'sAbs.Thisishereforthemgl32 package,topreventrampanttypeconversionsduringequalitytests. funcCartesianToCylindical¶ funcCartesianToCylindical(coordVec3)(rho,phi,zfloat32) CartesianToCylindicalconverts3-dimensionalcartesiancoordinates(x,y,z)to cylindricalcoordinateswithradialdistancer,azimuthphi,andheightz. Allanglesareinradians. funcCartesianToSpherical¶ funcCartesianToSpherical(coordVec3)(r,theta,phifloat32) CartesianToSphericalconverts3-dimensionalcartesiancoordinates(x,y,z)tospherical coordinateswithradiusr,inclinationtheta,andazimuthphi. Allanglesareinradians. funcClamp¶ funcClamp(a,low,highfloat32)float32 Clamptakesinavalueandtwothresholds.Ifthevalueissmallerthanthelow threshold,itreturnsthelowthreshold.Ifit'sbiggerthanthehighthreshold itreturnsthehighthreshold.Otherwiseitreturnsthevalue. Usefultopreventsomefunctionsfromfreakingoutbecauseavaluewas teeeeechnicallyoutofrange. funcClampFunc¶ funcClampFunc(low,highfloat32)func(float32)float32 ClampFuncgeneratesaclosurethatreturnsitsparameter clampedtotherange[low,high]. funcCopyMatMN¶ funcCopyMatMN(dst,src*MatMxN) CopyMatMNcopiessrcintodst.ThisReshapesdst tothesamesizeassrc. Ifdstorsrcisnil,thisisano-op funcCylindircalToSpherical¶ funcCylindircalToSpherical(rho,phi,zfloat32)(r,theta,phi2float32) CylindircalToSphericalconvertscylindricalcoordinateswithradialdistance r,azimuthphi,andheightztosphericalcoordinateswithradiusr, inclinationtheta,andazimuthphi. Anglesareinradians funcDegToRad¶ funcDegToRad(anglefloat32)float32 DegToRadconvertsdegreestoradians funcDisableMemoryPooling¶ funcDisableMemoryPooling() funcExtract3DScale¶ funcExtract3DScale(mMat4)(x,y,zfloat32) Extract3DScaleextractsthe3dscalingfromahomogeneousmatrix funcExtractMaxScale¶ funcExtractMaxScale(mMat4)float32 ExtractMaxScaleextractsthemaximumscalingfromahomogeneousmatrix funcFloatEqual¶ funcFloatEqual(a,bfloat32)bool FloatEqualisasafeutilityfunctiontocomparefloats. It'sTakenfromhttp://floating-point-gui.de/errors/comparison/ ItisslightlyalteredtonotcallAbswhennotneeded. funcFloatEqualFunc¶ funcFloatEqualFunc(epsilonfloat32)func(float32,float32)bool FloatEqualFuncisautilityclosurethatwillgenerateafunctionthat alwaysapproximatelycomparesfloatslikeFloatEqualThresholdwithadifferent threshold. funcFloatEqualThreshold¶ funcFloatEqualThreshold(a,b,epsilonfloat32)bool FloatEqualThresholdisautilityfunctiontocomparefloats. It'sTakenfromhttp://floating-point-gui.de/errors/comparison/ ItisslightlyalteredtonotcallAbswhennotneeded. ThisdiffersfromFloatEqualinthatitletsyoupassinyourcomparisonthreshold,sothatyoucanadjustthecomparisonvaluetoyourspecificneeds funcGLToScreenCoords¶ funcGLToScreenCoords(x,yfloat32,screenWidth,screenHeightint)(xOut,yOutint) GLToScreenCoordstransformsfromGL'sproportionalsystemtopixelcoordinates. Assumesthepixelcoordinatesystemhasitsorigininthetopleftcorner.(GL'sisinthebottomleft) GL'scoordinatesystemmaps[screenWidth-1,0]to[1.0,1.0]and[0,screenHeight-1]to[-1.0,-1.0].Ifxandyareoutoftherange,they'llstill bemappedcorrectly,justoffthescreen.(e.g.ify=-3.0,you'llget2*(screenHeight-1)foryOut) ThisissimilartoProject,exceptfor2Dcasesandmuchsimpler funcIsClamped¶ funcIsClamped(a,low,highfloat32)bool IsClampedchecksifaisclampedbetweenlowandhighasif Clamp(a,low,high)hadbeencalled. Inmostcasesit'sprobablybettertojustcallClamp withoutcheckingthissinceit'srelativelycheap. TheIsClampedfunctionsusestrictequality(meaning:nottheFloatEqual function)thereshouldn'tbeanymajorissueswiththissinceclampisoften usedtofixminorerrors funcRadToDeg¶ funcRadToDeg(anglefloat32)float32 RadToDegconvertsradianstodegrees funcReticulateSplines¶ funcReticulateSplines(ranges[][][2]float32,cPoints[][][]Vec2,withLlamasbool) ReticulateSplinesreticulatesALLtheSplines. Fortheoverlyserious:thefunctionisjustforfun.ItdoesnothingexceptprintsaMaxisreference.Technicallyyoucould"reticulatesplines" byjoiningabunchofsplinestogether,butthatruinsthejoke. funcRound¶ funcRound(vfloat32,precisionint)float32 Roundshortensafloat32valuetoaspecifiedprecision(numberofdigitsafterthedecimalpoint) with"roundhalfup"tie-brakingrule.Half-wayvalues(23.5)arealwaysroundedup(24). funcScreenToGLCoords¶ funcScreenToGLCoords(x,yint,screenWidth,screenHeightint)(xOut,yOutfloat32) ScreenToGLCoordstransformsfrompixelcoordinatestoGLcoordinates. Thisassumesthatyourpixelcoordinatesystemconsidersitsorigintobeinthetopleftcorner(GL'sisinthebottomleft). Thecoordinatesxandymaybeoutoftherange[0,screenWidth-1]and[0,screeneHeight-1]. GL'scoordinatesystemmaps[screenWidth-1,0]to[1.0,1.0]and[0,screenHeight-1]to[-1.0,-1.0].Ifxandyareoutoftherange,they'llstill bemappedcorrectly,justoffthescreen.(e.g.ify=2*(screenHeight-1)you'llget-3.0foryOut) ThisissimilartoUnproject,exceptfor2Dcasesandmuchsimpler(especiallysinceaninversemayalwaysbefound) funcSetMax¶ funcSetMax(a,b*float32) SetMaxsetsatobifab. funcSphericalToCylindrical¶ funcSphericalToCylindrical(r,theta,phifloat32)(rho,phi2,zfloat32) SphericalToCylindricalconvertssphericalcoordinateswithradiusr, inclinationtheta,andazimuthphitocylindricalcoordinateswithradial distancer,azimuthphi,andheightz. Anglesareinradians Types¶ typeInferMatrixError¶ typeInferMatrixErrorstruct{} InferMatrixErrormaybereturnedbyInferMatrix. Makesureyou'reusingaconstantmatrixsuchasMat3fromwithinthesame package(meaning:mgl32.MatMxNcan'thandleamgl64.Mat2x3). func(InferMatrixError)Error¶ func(meInferMatrixError)Error()string typeMat2¶ typeMat2[4]float32 funcDiag2¶ funcDiag2(vVec2)Mat2 Diag2createsadiagonalmatrixfromtheentriesoftheinputvector. Thatis,foreachpointerforrow==col,vector[row]istheentry.Otherwiseit's0. Anotherwaytothinkaboutitisthattheidentityisthisfunctionwheretheeveryvectorelementis1. funcIdent2¶ funcIdent2()Mat2 Ident2returnsthe2x2identitymatrix. Theidentitymatrixisasquarematrixwiththevalue1onits diagonals.Thecharacteristicpropertyoftheidentitymatrixisthat anymatrixmultipliedbyitisitself.(MI=M;IN=N) funcMat2FromCols¶ funcMat2FromCols(col0,col1Vec2)Mat2 Mat2FromColsbuildsanewmatrixfromcolumnvectors. funcMat2FromRows¶ funcMat2FromRows(row0,row1Vec2)Mat2 funcRotate2D¶ funcRotate2D(anglefloat32)Mat2 Rotate2DreturnsarotationMatrixaboutaanglein2-Dspace.Specificallyabouttheorigin. Itisa2x2matrix,ifyouneeda3x3forHomogeneousmath(e.g.compositionwithaTranslationmatrix) seeHomogRotate2D func(Mat2)Abs¶ func(mMat2)Abs()Mat2 Absreturnstheelement-wiseabsolutevalueofthismatrix func(Mat2)Add¶ func(m1Mat2)Add(m2Mat2)Mat2 Addperformsanelement-wiseadditionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andaddingthecorrespondingvalueofm2. func(Mat2)ApproxEqual¶ func(m1Mat2)ApproxEqual(m2Mat2)bool ApproxEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices, asifFloatEqualhadbeenused. func(Mat2)ApproxEqualThreshold¶ func(m1Mat2)ApproxEqualThreshold(m2Mat2,thresholdfloat32)bool ApproxEqualThresholdperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenepsilonthreshold,asifFloatEqualThresholdhadbeenused. func(Mat2)ApproxFuncEqual¶ func(m1Mat2)ApproxFuncEqual(m2Mat2,eqfunc(float32,float32)bool)bool ApproxFuncEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenequalityfunctions,intendedtobeusedwithFloatEqualFunc;althoughandcomparison functionmaybeusedinpractice. func(Mat2)At¶ func(mMat2)At(row,colint)float32 Atreturnsthematrixelementatthegivenrowandcolumn. Thisisequivalenttomat[col*numRow+row]wherenumRowisconstant (E.G.foraMat3x2it'sequalto3) Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor At(5,0)willworkjustlikeAt(1,1).Oritmaypanicifit'soutofbounds. func(Mat2)Col¶ func(mMat2)Col(colint)Vec2 Colreturnsavectorrepresentingthecorrespondingcolumn(startingatcol0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecNforaMxNmatrix. func(Mat2)Cols¶ func(mMat2)Cols()(col0,col1Vec2) Colsdecomposesamatrixintoitscorrespondingcolumnvectors. Thisisequivalenttocallingmat.Colforeachcolumn. func(Mat2)Det¶ func(mMat2)Det()float32 Detreturnsthedeterminantofamatrix.Itisameasureofasquarematrix's singularityandinvertability,amongotherthings.Inthislibrary,the determinantishardcodedbasedonpre-computedcofactorexpansion,anduses noloops.Ofcourse,theadditionandmultiplicationmuststillbedone. func(Mat2)Diag¶ func(mMat2)Diag()Vec2 Diagisabasicoperationonasquarematrixthatsimply returnsmaindiagonal(meaningallelementssuchthatrow==col). func(Mat2)Index¶ func(mMat2)Index(row,colint)int Indexreturnstheindexofthegivenrowandcolumn,tobeusedwithdirect access.E.G.Index(0,0)=0. Thisisagarbage-ingarbage-outmethod.Forinstance,onaMat4askingfortheindexof (5,0)willworkthesameasaskingfor(1,1).Oritmaygiveyouavaluethatwillcause apanicifyoutrytoaccessthearraywithitifit'strulyoutofbounds. func(Mat2)Inv¶ func(mMat2)Inv()Mat2 Invcomputestheinverseofasquarematrix.Aninverseisasquarematrixsuchthatwhenmultipliedbythe original,yieldstheidentity. M_inv*M=M*M_inv=I Inthislibrary,themathisprecomputed,andusesnoloops,thoughthemultiplications,additions,determinantcalculation,andscaling arestilldone.Thiscanstillbe(relatively)expensivefora4x4. Thisfunctionchecksthedeterminanttoseeifthematrixisinvertible. Ifthedeterminantis0.0,thisfunctionreturnsthezeromatrix.However,duetofloatingpointerrors,itis entirelyplausibletogetafalsepositiveornegative. Inthefuture,analternatefunctionmaybewrittenwhichtakesinapre-computeddeterminant. func(Mat2)Mat3¶ func(mMat2)Mat3()Mat3 func(Mat2)Mat4¶ func(mMat2)Mat4()Mat4 func(Mat2)Mul¶ func(m1Mat2)Mul(cfloat32)Mat2 Mulperformsascalarmultiplcationofthematrix.Thisisequivalenttoiterating overeveryelementofthematrixandmultiplyitbyc. func(Mat2)Mul2¶ func(m1Mat2)Mul2(m2Mat2)Mat2 Mul2performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat2)Mul2x1¶ func(m1Mat2)Mul2x1(m2Vec2)Vec2 Mul2x1performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat2)Mul2x3¶ func(m1Mat2)Mul2x3(m2Mat2x3)Mat2x3 Mul2x3performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat2)Mul2x4¶ func(m1Mat2)Mul2x4(m2Mat2x4)Mat2x4 Mul2x4performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat2)Row¶ func(mMat2)Row(rowint)Vec2 Rowreturnsavectorrepresentingthecorrespondingrow(startingatrow0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecMforaMxNmatrix. func(Mat2)Rows¶ func(mMat2)Rows()(row0,row1Vec2) Rowsdecomposesamatrixintoitscorrespondingrowvectors. Thisisequivalenttocallingmat.Rowforeachrow. func(*Mat2)Set¶ func(m*Mat2)Set(row,colint,valuefloat32) Setsetsthecorrespondingmatrixelementatthegivenrowandcolumn. Thishasapointerreceiverbecauseitmutatesthematrix. Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor Set(5,0,val)willworkjustlikeSet(1,1,val).Oritmaypanicifit'soutofbounds. func(*Mat2)SetCol¶ func(m*Mat2)SetCol(colint,vVec2) SetColsetsaColumnwithintheMatrix,soitmutatesthecallingmatrix. func(*Mat2)SetRow¶ func(m*Mat2)SetRow(rowint,vVec2) SetRowsetsaRowwithintheMatrix,soitmutatesthecallingmatrix. func(Mat2)String¶ func(mMat2)String()string Prettyprintsthematrix func(Mat2)Sub¶ func(m1Mat2)Sub(m2Mat2)Mat2 Subperformsanelement-wisesubtractionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andsubtractingthecorrespondingvalueofm2. func(Mat2)Trace¶ func(mMat2)Trace()float32 Traceisabasicoperationonasquarematrixthatsimply sumsupallelementsonthemaindiagonal(meaningallelementssuchthatrow==col). func(Mat2)Transpose¶ func(m1Mat2)Transpose()Mat2 Transposeproducesthetransposeofthismatrix.ForanyMxNmatrix thetransposeisanNxMmatrixwiththerowsswappedwiththecolumns.Forinstance thetransposeoftheMat3x2isaMat2x3likeso: [[ab]][[ace]] [[cd]]=[[bdf]] [[ef]] typeMat2x3¶ typeMat2x3[6]float32 funcMat2x3FromCols¶ funcMat2x3FromCols(col0,col1,col2Vec2)Mat2x3 Mat2x3FromColsbuildsanewmatrixfromcolumnvectors. funcMat2x3FromRows¶ funcMat2x3FromRows(row0,row1Vec3)Mat2x3 func(Mat2x3)Abs¶ func(mMat2x3)Abs()Mat2x3 Absreturnstheelement-wiseabsolutevalueofthismatrix func(Mat2x3)Add¶ func(m1Mat2x3)Add(m2Mat2x3)Mat2x3 Addperformsanelement-wiseadditionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andaddingthecorrespondingvalueofm2. func(Mat2x3)ApproxEqual¶ func(m1Mat2x3)ApproxEqual(m2Mat2x3)bool ApproxEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices, asifFloatEqualhadbeenused. func(Mat2x3)ApproxEqualThreshold¶ func(m1Mat2x3)ApproxEqualThreshold(m2Mat2x3,thresholdfloat32)bool ApproxEqualThresholdperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenepsilonthreshold,asifFloatEqualThresholdhadbeenused. func(Mat2x3)ApproxFuncEqual¶ func(m1Mat2x3)ApproxFuncEqual(m2Mat2x3,eqfunc(float32,float32)bool)bool ApproxFuncEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenequalityfunctions,intendedtobeusedwithFloatEqualFunc;althoughandcomparison functionmaybeusedinpractice. func(Mat2x3)At¶ func(mMat2x3)At(row,colint)float32 Atreturnsthematrixelementatthegivenrowandcolumn. Thisisequivalenttomat[col*numRow+row]wherenumRowisconstant (E.G.foraMat3x2it'sequalto3) Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor At(5,0)willworkjustlikeAt(1,1).Oritmaypanicifit'soutofbounds. func(Mat2x3)Col¶ func(mMat2x3)Col(colint)Vec2 Colreturnsavectorrepresentingthecorrespondingcolumn(startingatcol0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecNforaMxNmatrix. func(Mat2x3)Cols¶ func(mMat2x3)Cols()(col0,col1,col2Vec2) Colsdecomposesamatrixintoitscorrespondingcolumnvectors. Thisisequivalenttocallingmat.Colforeachcolumn. func(Mat2x3)Index¶ func(mMat2x3)Index(row,colint)int Indexreturnstheindexofthegivenrowandcolumn,tobeusedwithdirect access.E.G.Index(0,0)=0. Thisisagarbage-ingarbage-outmethod.Forinstance,onaMat4askingfortheindexof (5,0)willworkthesameasaskingfor(1,1).Oritmaygiveyouavaluethatwillcause apanicifyoutrytoaccessthearraywithitifit'strulyoutofbounds. func(Mat2x3)Mul¶ func(m1Mat2x3)Mul(cfloat32)Mat2x3 Mulperformsascalarmultiplcationofthematrix.Thisisequivalenttoiterating overeveryelementofthematrixandmultiplyitbyc. func(Mat2x3)Mul3¶ func(m1Mat2x3)Mul3(m2Mat3)Mat2x3 Mul3performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat2x3)Mul3x1¶ func(m1Mat2x3)Mul3x1(m2Vec3)Vec2 Mul3x1performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat2x3)Mul3x2¶ func(m1Mat2x3)Mul3x2(m2Mat3x2)Mat2 Mul3x2performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat2x3)Mul3x4¶ func(m1Mat2x3)Mul3x4(m2Mat3x4)Mat2x4 Mul3x4performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat2x3)Row¶ func(mMat2x3)Row(rowint)Vec3 Rowreturnsavectorrepresentingthecorrespondingrow(startingatrow0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecMforaMxNmatrix. func(Mat2x3)Rows¶ func(mMat2x3)Rows()(row0,row1Vec3) Rowsdecomposesamatrixintoitscorrespondingrowvectors. Thisisequivalenttocallingmat.Rowforeachrow. func(*Mat2x3)Set¶ func(m*Mat2x3)Set(row,colint,valuefloat32) Setsetsthecorrespondingmatrixelementatthegivenrowandcolumn. Thishasapointerreceiverbecauseitmutatesthematrix. Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor Set(5,0,val)willworkjustlikeSet(1,1,val).Oritmaypanicifit'soutofbounds. func(*Mat2x3)SetCol¶ func(m*Mat2x3)SetCol(colint,vVec2) SetColsetsaColumnwithintheMatrix,soitmutatesthecallingmatrix. func(*Mat2x3)SetRow¶ func(m*Mat2x3)SetRow(rowint,vVec3) SetRowsetsaRowwithintheMatrix,soitmutatesthecallingmatrix. func(Mat2x3)String¶ func(mMat2x3)String()string Prettyprintsthematrix func(Mat2x3)Sub¶ func(m1Mat2x3)Sub(m2Mat2x3)Mat2x3 Subperformsanelement-wisesubtractionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andsubtractingthecorrespondingvalueofm2. func(Mat2x3)Transpose¶ func(m1Mat2x3)Transpose()Mat3x2 Transposeproducesthetransposeofthismatrix.ForanyMxNmatrix thetransposeisanNxMmatrixwiththerowsswappedwiththecolumns.Forinstance thetransposeoftheMat3x2isaMat2x3likeso: [[ab]][[ace]] [[cd]]=[[bdf]] [[ef]] typeMat2x4¶ typeMat2x4[8]float32 funcMat2x4FromCols¶ funcMat2x4FromCols(col0,col1,col2,col3Vec2)Mat2x4 Mat2x4FromColsbuildsanewmatrixfromcolumnvectors. funcMat2x4FromRows¶ funcMat2x4FromRows(row0,row1Vec4)Mat2x4 func(Mat2x4)Abs¶ func(mMat2x4)Abs()Mat2x4 Absreturnstheelement-wiseabsolutevalueofthismatrix func(Mat2x4)Add¶ func(m1Mat2x4)Add(m2Mat2x4)Mat2x4 Addperformsanelement-wiseadditionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andaddingthecorrespondingvalueofm2. func(Mat2x4)ApproxEqual¶ func(m1Mat2x4)ApproxEqual(m2Mat2x4)bool ApproxEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices, asifFloatEqualhadbeenused. func(Mat2x4)ApproxEqualThreshold¶ func(m1Mat2x4)ApproxEqualThreshold(m2Mat2x4,thresholdfloat32)bool ApproxEqualThresholdperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenepsilonthreshold,asifFloatEqualThresholdhadbeenused. func(Mat2x4)ApproxFuncEqual¶ func(m1Mat2x4)ApproxFuncEqual(m2Mat2x4,eqfunc(float32,float32)bool)bool ApproxFuncEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenequalityfunctions,intendedtobeusedwithFloatEqualFunc;althoughandcomparison functionmaybeusedinpractice. func(Mat2x4)At¶ func(mMat2x4)At(row,colint)float32 Atreturnsthematrixelementatthegivenrowandcolumn. Thisisequivalenttomat[col*numRow+row]wherenumRowisconstant (E.G.foraMat3x2it'sequalto3) Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor At(5,0)willworkjustlikeAt(1,1).Oritmaypanicifit'soutofbounds. func(Mat2x4)Col¶ func(mMat2x4)Col(colint)Vec2 Colreturnsavectorrepresentingthecorrespondingcolumn(startingatcol0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecNforaMxNmatrix. func(Mat2x4)Cols¶ func(mMat2x4)Cols()(col0,col1,col2,col3Vec2) Colsdecomposesamatrixintoitscorrespondingcolumnvectors. Thisisequivalenttocallingmat.Colforeachcolumn. func(Mat2x4)Index¶ func(mMat2x4)Index(row,colint)int Indexreturnstheindexofthegivenrowandcolumn,tobeusedwithdirect access.E.G.Index(0,0)=0. Thisisagarbage-ingarbage-outmethod.Forinstance,onaMat4askingfortheindexof (5,0)willworkthesameasaskingfor(1,1).Oritmaygiveyouavaluethatwillcause apanicifyoutrytoaccessthearraywithitifit'strulyoutofbounds. func(Mat2x4)Mul¶ func(m1Mat2x4)Mul(cfloat32)Mat2x4 Mulperformsascalarmultiplcationofthematrix.Thisisequivalenttoiterating overeveryelementofthematrixandmultiplyitbyc. func(Mat2x4)Mul4¶ func(m1Mat2x4)Mul4(m2Mat4)Mat2x4 Mul4performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat2x4)Mul4x1¶ func(m1Mat2x4)Mul4x1(m2Vec4)Vec2 Mul4x1performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat2x4)Mul4x2¶ func(m1Mat2x4)Mul4x2(m2Mat4x2)Mat2 Mul4x2performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat2x4)Mul4x3¶ func(m1Mat2x4)Mul4x3(m2Mat4x3)Mat2x3 Mul4x3performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat2x4)Row¶ func(mMat2x4)Row(rowint)Vec4 Rowreturnsavectorrepresentingthecorrespondingrow(startingatrow0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecMforaMxNmatrix. func(Mat2x4)Rows¶ func(mMat2x4)Rows()(row0,row1Vec4) Rowsdecomposesamatrixintoitscorrespondingrowvectors. Thisisequivalenttocallingmat.Rowforeachrow. func(*Mat2x4)Set¶ func(m*Mat2x4)Set(row,colint,valuefloat32) Setsetsthecorrespondingmatrixelementatthegivenrowandcolumn. Thishasapointerreceiverbecauseitmutatesthematrix. Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor Set(5,0,val)willworkjustlikeSet(1,1,val).Oritmaypanicifit'soutofbounds. func(*Mat2x4)SetCol¶ func(m*Mat2x4)SetCol(colint,vVec2) SetColsetsaColumnwithintheMatrix,soitmutatesthecallingmatrix. func(*Mat2x4)SetRow¶ func(m*Mat2x4)SetRow(rowint,vVec4) SetRowsetsaRowwithintheMatrix,soitmutatesthecallingmatrix. func(Mat2x4)String¶ func(mMat2x4)String()string Prettyprintsthematrix func(Mat2x4)Sub¶ func(m1Mat2x4)Sub(m2Mat2x4)Mat2x4 Subperformsanelement-wisesubtractionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andsubtractingthecorrespondingvalueofm2. func(Mat2x4)Transpose¶ func(m1Mat2x4)Transpose()Mat4x2 Transposeproducesthetransposeofthismatrix.ForanyMxNmatrix thetransposeisanNxMmatrixwiththerowsswappedwiththecolumns.Forinstance thetransposeoftheMat3x2isaMat2x3likeso: [[ab]][[ace]] [[cd]]=[[bdf]] [[ef]] typeMat3¶ typeMat3f32.Mat3 funcDiag3¶ funcDiag3(vVec3)Mat3 Diag3createsadiagonalmatrixfromtheentriesoftheinputvector. Thatis,foreachpointerforrow==col,vector[row]istheentry.Otherwiseit's0. Anotherwaytothinkaboutitisthattheidentityisthisfunctionwheretheeveryvectorelementis1. funcHomogRotate2D¶ funcHomogRotate2D(anglefloat32)Mat3 HomogRotate2DisthesameasRotate2D,excepthomogeneous(3x3withtheextrarow/colbeingallzeroeswithaoneinthebottomright) funcIdent3¶ funcIdent3()Mat3 Ident3returnsthe3x3identitymatrix. Theidentitymatrixisasquarematrixwiththevalue1onits diagonals.Thecharacteristicpropertyoftheidentitymatrixisthat anymatrixmultipliedbyitisitself.(MI=M;IN=N) funcMat3FromCols¶ funcMat3FromCols(col0,col1,col2Vec3)Mat3 Mat3FromColsbuildsanewmatrixfromcolumnvectors. funcMat3FromRows¶ funcMat3FromRows(row0,row1,row2Vec3)Mat3 funcMat4Normal¶ funcMat4Normal(mMat4)Mat3 Mat4NormalcalculatestheNormaloftheMatrix(akatheinversetranspose) funcRotate3DX¶ funcRotate3DX(anglefloat32)Mat3 Rotate3DXreturnsa3x3(non-homogeneous)MatrixthatrotatesbyangleabouttheX-axis Whereciscos(angle)andsissin(angle) [100] [0c-s] [0sc] funcRotate3DY¶ funcRotate3DY(anglefloat32)Mat3 Rotate3DYreturnsa3x3(non-homogeneous)MatrixthatrotatesbyangleabouttheY-axis Whereciscos(angle)andsissin(angle) [c0s] [010] [s0c] funcRotate3DZ¶ funcRotate3DZ(anglefloat32)Mat3 Rotate3DZreturnsa3x3(non-homogeneous)MatrixthatrotatesbyangleabouttheZ-axis Whereciscos(angle)andsissin(angle) [c-s0] [sc0] [001] funcScale2D¶ funcScale2D(scaleX,scaleYfloat32)Mat3 Scale2Dcreatesahomogeneous2Dscalingmatrix [[scaleX,0,0]] [[0,scaleY,0]] [[0,0,1]] funcShearX2D¶ funcShearX2D(shearfloat32)Mat3 ShearX2Dcreatesahomogeneous2DshearmatrixalongtheX-axis funcShearY2D¶ funcShearY2D(shearfloat32)Mat3 ShearY2Dcreatesahomogeneous2DshearmatrixalongtheY-axis funcTranslate2D¶ funcTranslate2D(Tx,Tyfloat32)Mat3 Translate2Dreturnsahomogeneous(3x3for2D-space)TranslationmatrixthatmovesapointbyTxunitsinthex-directionandTyunitsinthey-direction [[1,0,Tx]] [[0,1,Ty]] [[0,0,1]] func(Mat3)Abs¶ func(mMat3)Abs()Mat3 Absreturnstheelement-wiseabsolutevalueofthismatrix func(Mat3)Add¶ func(m1Mat3)Add(m2Mat3)Mat3 Addperformsanelement-wiseadditionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andaddingthecorrespondingvalueofm2. func(Mat3)ApproxEqual¶ func(m1Mat3)ApproxEqual(m2Mat3)bool ApproxEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices, asifFloatEqualhadbeenused. func(Mat3)ApproxEqualThreshold¶ func(m1Mat3)ApproxEqualThreshold(m2Mat3,thresholdfloat32)bool ApproxEqualThresholdperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenepsilonthreshold,asifFloatEqualThresholdhadbeenused. func(Mat3)ApproxFuncEqual¶ func(m1Mat3)ApproxFuncEqual(m2Mat3,eqfunc(float32,float32)bool)bool ApproxFuncEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenequalityfunctions,intendedtobeusedwithFloatEqualFunc;althoughandcomparison functionmaybeusedinpractice. func(Mat3)At¶ func(mMat3)At(row,colint)float32 Atreturnsthematrixelementatthegivenrowandcolumn. Thisisequivalenttomat[col*numRow+row]wherenumRowisconstant (E.G.foraMat3x2it'sequalto3) Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor At(5,0)willworkjustlikeAt(1,1).Oritmaypanicifit'soutofbounds. func(Mat3)Col¶ func(mMat3)Col(colint)Vec3 Colreturnsavectorrepresentingthecorrespondingcolumn(startingatcol0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecNforaMxNmatrix. func(Mat3)Cols¶ func(mMat3)Cols()(col0,col1,col2Vec3) Colsdecomposesamatrixintoitscorrespondingcolumnvectors. Thisisequivalenttocallingmat.Colforeachcolumn. func(Mat3)Det¶ func(mMat3)Det()float32 Detreturnsthedeterminantofamatrix.Itisameasureofasquarematrix's singularityandinvertability,amongotherthings.Inthislibrary,the determinantishardcodedbasedonpre-computedcofactorexpansion,anduses noloops.Ofcourse,theadditionandmultiplicationmuststillbedone. func(Mat3)Diag¶ func(mMat3)Diag()Vec3 Diagisabasicoperationonasquarematrixthatsimply returnsmaindiagonal(meaningallelementssuchthatrow==col). func(Mat3)Index¶ func(mMat3)Index(row,colint)int Indexreturnstheindexofthegivenrowandcolumn,tobeusedwithdirect access.E.G.Index(0,0)=0. Thisisagarbage-ingarbage-outmethod.Forinstance,onaMat4askingfortheindexof (5,0)willworkthesameasaskingfor(1,1).Oritmaygiveyouavaluethatwillcause apanicifyoutrytoaccessthearraywithitifit'strulyoutofbounds. func(Mat3)Inv¶ func(mMat3)Inv()Mat3 Invcomputestheinverseofasquarematrix.Aninverseisasquarematrixsuchthatwhenmultipliedbythe original,yieldstheidentity. M_inv*M=M*M_inv=I Inthislibrary,themathisprecomputed,andusesnoloops,thoughthemultiplications,additions,determinantcalculation,andscaling arestilldone.Thiscanstillbe(relatively)expensivefora4x4. Thisfunctionchecksthedeterminanttoseeifthematrixisinvertible. Ifthedeterminantis0.0,thisfunctionreturnsthezeromatrix.However,duetofloatingpointerrors,itis entirelyplausibletogetafalsepositiveornegative. Inthefuture,analternatefunctionmaybewrittenwhichtakesinapre-computeddeterminant. func(Mat3)Mat2¶ func(mMat3)Mat2()Mat2 func(Mat3)Mat4¶ func(mMat3)Mat4()Mat4 func(Mat3)Mul¶ func(m1Mat3)Mul(cfloat32)Mat3 Mulperformsascalarmultiplcationofthematrix.Thisisequivalenttoiterating overeveryelementofthematrixandmultiplyitbyc. func(Mat3)Mul3¶ func(m1Mat3)Mul3(m2Mat3)Mat3 Mul3performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat3)Mul3x1¶ func(m1Mat3)Mul3x1(m2Vec3)Vec3 Mul3x1performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat3)Mul3x2¶ func(m1Mat3)Mul3x2(m2Mat3x2)Mat3x2 Mul3x2performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat3)Mul3x4¶ func(m1Mat3)Mul3x4(m2Mat3x4)Mat3x4 Mul3x4performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat3)Row¶ func(mMat3)Row(rowint)Vec3 Rowreturnsavectorrepresentingthecorrespondingrow(startingatrow0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecMforaMxNmatrix. func(Mat3)Rows¶ func(mMat3)Rows()(row0,row1,row2Vec3) Rowsdecomposesamatrixintoitscorrespondingrowvectors. Thisisequivalenttocallingmat.Rowforeachrow. func(*Mat3)Set¶ func(m*Mat3)Set(row,colint,valuefloat32) Setsetsthecorrespondingmatrixelementatthegivenrowandcolumn. Thishasapointerreceiverbecauseitmutatesthematrix. Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor Set(5,0,val)willworkjustlikeSet(1,1,val).Oritmaypanicifit'soutofbounds. func(*Mat3)SetCol¶ func(m*Mat3)SetCol(colint,vVec3) SetColsetsaColumnwithintheMatrix,soitmutatesthecallingmatrix. func(*Mat3)SetRow¶ func(m*Mat3)SetRow(rowint,vVec3) SetRowsetsaRowwithintheMatrix,soitmutatesthecallingmatrix. func(Mat3)String¶ func(mMat3)String()string Prettyprintsthematrix func(Mat3)Sub¶ func(m1Mat3)Sub(m2Mat3)Mat3 Subperformsanelement-wisesubtractionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andsubtractingthecorrespondingvalueofm2. func(Mat3)Trace¶ func(mMat3)Trace()float32 Traceisabasicoperationonasquarematrixthatsimply sumsupallelementsonthemaindiagonal(meaningallelementssuchthatrow==col). func(Mat3)Transpose¶ func(m1Mat3)Transpose()Mat3 Transposeproducesthetransposeofthismatrix.ForanyMxNmatrix thetransposeisanNxMmatrixwiththerowsswappedwiththecolumns.Forinstance thetransposeoftheMat3x2isaMat2x3likeso: [[ab]][[ace]] [[cd]]=[[bdf]] [[ef]] typeMat3x2¶ typeMat3x2[6]float32 funcMat3x2FromCols¶ funcMat3x2FromCols(col0,col1Vec3)Mat3x2 Mat3x2FromColsbuildsanewmatrixfromcolumnvectors. funcMat3x2FromRows¶ funcMat3x2FromRows(row0,row1,row2Vec2)Mat3x2 func(Mat3x2)Abs¶ func(mMat3x2)Abs()Mat3x2 Absreturnstheelement-wiseabsolutevalueofthismatrix func(Mat3x2)Add¶ func(m1Mat3x2)Add(m2Mat3x2)Mat3x2 Addperformsanelement-wiseadditionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andaddingthecorrespondingvalueofm2. func(Mat3x2)ApproxEqual¶ func(m1Mat3x2)ApproxEqual(m2Mat3x2)bool ApproxEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices, asifFloatEqualhadbeenused. func(Mat3x2)ApproxEqualThreshold¶ func(m1Mat3x2)ApproxEqualThreshold(m2Mat3x2,thresholdfloat32)bool ApproxEqualThresholdperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenepsilonthreshold,asifFloatEqualThresholdhadbeenused. func(Mat3x2)ApproxFuncEqual¶ func(m1Mat3x2)ApproxFuncEqual(m2Mat3x2,eqfunc(float32,float32)bool)bool ApproxFuncEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenequalityfunctions,intendedtobeusedwithFloatEqualFunc;althoughandcomparison functionmaybeusedinpractice. func(Mat3x2)At¶ func(mMat3x2)At(row,colint)float32 Atreturnsthematrixelementatthegivenrowandcolumn. Thisisequivalenttomat[col*numRow+row]wherenumRowisconstant (E.G.foraMat3x2it'sequalto3) Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor At(5,0)willworkjustlikeAt(1,1).Oritmaypanicifit'soutofbounds. func(Mat3x2)Col¶ func(mMat3x2)Col(colint)Vec3 Colreturnsavectorrepresentingthecorrespondingcolumn(startingatcol0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecNforaMxNmatrix. func(Mat3x2)Cols¶ func(mMat3x2)Cols()(col0,col1Vec3) Colsdecomposesamatrixintoitscorrespondingcolumnvectors. Thisisequivalenttocallingmat.Colforeachcolumn. func(Mat3x2)Index¶ func(mMat3x2)Index(row,colint)int Indexreturnstheindexofthegivenrowandcolumn,tobeusedwithdirect access.E.G.Index(0,0)=0. Thisisagarbage-ingarbage-outmethod.Forinstance,onaMat4askingfortheindexof (5,0)willworkthesameasaskingfor(1,1).Oritmaygiveyouavaluethatwillcause apanicifyoutrytoaccessthearraywithitifit'strulyoutofbounds. func(Mat3x2)Mul¶ func(m1Mat3x2)Mul(cfloat32)Mat3x2 Mulperformsascalarmultiplcationofthematrix.Thisisequivalenttoiterating overeveryelementofthematrixandmultiplyitbyc. func(Mat3x2)Mul2¶ func(m1Mat3x2)Mul2(m2Mat2)Mat3x2 Mul2performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat3x2)Mul2x1¶ func(m1Mat3x2)Mul2x1(m2Vec2)Vec3 Mul2x1performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat3x2)Mul2x3¶ func(m1Mat3x2)Mul2x3(m2Mat2x3)Mat3 Mul2x3performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat3x2)Mul2x4¶ func(m1Mat3x2)Mul2x4(m2Mat2x4)Mat3x4 Mul2x4performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat3x2)Row¶ func(mMat3x2)Row(rowint)Vec2 Rowreturnsavectorrepresentingthecorrespondingrow(startingatrow0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecMforaMxNmatrix. func(Mat3x2)Rows¶ func(mMat3x2)Rows()(row0,row1,row2Vec2) Rowsdecomposesamatrixintoitscorrespondingrowvectors. Thisisequivalenttocallingmat.Rowforeachrow. func(*Mat3x2)Set¶ func(m*Mat3x2)Set(row,colint,valuefloat32) Setsetsthecorrespondingmatrixelementatthegivenrowandcolumn. Thishasapointerreceiverbecauseitmutatesthematrix. Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor Set(5,0,val)willworkjustlikeSet(1,1,val).Oritmaypanicifit'soutofbounds. func(*Mat3x2)SetCol¶ func(m*Mat3x2)SetCol(colint,vVec3) SetColsetsaColumnwithintheMatrix,soitmutatesthecallingmatrix. func(*Mat3x2)SetRow¶ func(m*Mat3x2)SetRow(rowint,vVec2) SetRowsetsaRowwithintheMatrix,soitmutatesthecallingmatrix. func(Mat3x2)String¶ func(mMat3x2)String()string Prettyprintsthematrix func(Mat3x2)Sub¶ func(m1Mat3x2)Sub(m2Mat3x2)Mat3x2 Subperformsanelement-wisesubtractionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andsubtractingthecorrespondingvalueofm2. func(Mat3x2)Transpose¶ func(m1Mat3x2)Transpose()Mat2x3 Transposeproducesthetransposeofthismatrix.ForanyMxNmatrix thetransposeisanNxMmatrixwiththerowsswappedwiththecolumns.Forinstance thetransposeoftheMat3x2isaMat2x3likeso: [[ab]][[ace]] [[cd]]=[[bdf]] [[ef]] typeMat3x4¶ typeMat3x4[12]float32 funcMat3x4FromCols¶ funcMat3x4FromCols(col0,col1,col2,col3Vec3)Mat3x4 Mat3x4FromColsbuildsanewmatrixfromcolumnvectors. funcMat3x4FromRows¶ funcMat3x4FromRows(row0,row1,row2Vec4)Mat3x4 func(Mat3x4)Abs¶ func(mMat3x4)Abs()Mat3x4 Absreturnstheelement-wiseabsolutevalueofthismatrix func(Mat3x4)Add¶ func(m1Mat3x4)Add(m2Mat3x4)Mat3x4 Addperformsanelement-wiseadditionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andaddingthecorrespondingvalueofm2. func(Mat3x4)ApproxEqual¶ func(m1Mat3x4)ApproxEqual(m2Mat3x4)bool ApproxEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices, asifFloatEqualhadbeenused. func(Mat3x4)ApproxEqualThreshold¶ func(m1Mat3x4)ApproxEqualThreshold(m2Mat3x4,thresholdfloat32)bool ApproxEqualThresholdperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenepsilonthreshold,asifFloatEqualThresholdhadbeenused. func(Mat3x4)ApproxFuncEqual¶ func(m1Mat3x4)ApproxFuncEqual(m2Mat3x4,eqfunc(float32,float32)bool)bool ApproxFuncEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenequalityfunctions,intendedtobeusedwithFloatEqualFunc;althoughandcomparison functionmaybeusedinpractice. func(Mat3x4)At¶ func(mMat3x4)At(row,colint)float32 Atreturnsthematrixelementatthegivenrowandcolumn. Thisisequivalenttomat[col*numRow+row]wherenumRowisconstant (E.G.foraMat3x2it'sequalto3) Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor At(5,0)willworkjustlikeAt(1,1).Oritmaypanicifit'soutofbounds. func(Mat3x4)Col¶ func(mMat3x4)Col(colint)Vec3 Colreturnsavectorrepresentingthecorrespondingcolumn(startingatcol0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecNforaMxNmatrix. func(Mat3x4)Cols¶ func(mMat3x4)Cols()(col0,col1,col2,col3Vec3) Colsdecomposesamatrixintoitscorrespondingcolumnvectors. Thisisequivalenttocallingmat.Colforeachcolumn. func(Mat3x4)Index¶ func(mMat3x4)Index(row,colint)int Indexreturnstheindexofthegivenrowandcolumn,tobeusedwithdirect access.E.G.Index(0,0)=0. Thisisagarbage-ingarbage-outmethod.Forinstance,onaMat4askingfortheindexof (5,0)willworkthesameasaskingfor(1,1).Oritmaygiveyouavaluethatwillcause apanicifyoutrytoaccessthearraywithitifit'strulyoutofbounds. func(Mat3x4)Mul¶ func(m1Mat3x4)Mul(cfloat32)Mat3x4 Mulperformsascalarmultiplcationofthematrix.Thisisequivalenttoiterating overeveryelementofthematrixandmultiplyitbyc. func(Mat3x4)Mul4¶ func(m1Mat3x4)Mul4(m2Mat4)Mat3x4 Mul4performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat3x4)Mul4x1¶ func(m1Mat3x4)Mul4x1(m2Vec4)Vec3 Mul4x1performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat3x4)Mul4x2¶ func(m1Mat3x4)Mul4x2(m2Mat4x2)Mat3x2 Mul4x2performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat3x4)Mul4x3¶ func(m1Mat3x4)Mul4x3(m2Mat4x3)Mat3 Mul4x3performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat3x4)Row¶ func(mMat3x4)Row(rowint)Vec4 Rowreturnsavectorrepresentingthecorrespondingrow(startingatrow0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecMforaMxNmatrix. func(Mat3x4)Rows¶ func(mMat3x4)Rows()(row0,row1,row2Vec4) Rowsdecomposesamatrixintoitscorrespondingrowvectors. Thisisequivalenttocallingmat.Rowforeachrow. func(*Mat3x4)Set¶ func(m*Mat3x4)Set(row,colint,valuefloat32) Setsetsthecorrespondingmatrixelementatthegivenrowandcolumn. Thishasapointerreceiverbecauseitmutatesthematrix. Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor Set(5,0,val)willworkjustlikeSet(1,1,val).Oritmaypanicifit'soutofbounds. func(*Mat3x4)SetCol¶ func(m*Mat3x4)SetCol(colint,vVec3) SetColsetsaColumnwithintheMatrix,soitmutatesthecallingmatrix. func(*Mat3x4)SetRow¶ func(m*Mat3x4)SetRow(rowint,vVec4) SetRowsetsaRowwithintheMatrix,soitmutatesthecallingmatrix. func(Mat3x4)String¶ func(mMat3x4)String()string Prettyprintsthematrix func(Mat3x4)Sub¶ func(m1Mat3x4)Sub(m2Mat3x4)Mat3x4 Subperformsanelement-wisesubtractionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andsubtractingthecorrespondingvalueofm2. func(Mat3x4)Transpose¶ func(m1Mat3x4)Transpose()Mat4x3 Transposeproducesthetransposeofthismatrix.ForanyMxNmatrix thetransposeisanNxMmatrixwiththerowsswappedwiththecolumns.Forinstance thetransposeoftheMat3x2isaMat2x3likeso: [[ab]][[ace]] [[cd]]=[[bdf]] [[ef]] typeMat4¶ typeMat4f32.Mat4 funcDiag4¶ funcDiag4(vVec4)Mat4 Diag4createsadiagonalmatrixfromtheentriesoftheinputvector. Thatis,foreachpointerforrow==col,vector[row]istheentry.Otherwiseit's0. Anotherwaytothinkaboutitisthattheidentityisthisfunctionwheretheeveryvectorelementis1. funcFrustum¶ funcFrustum(left,right,bottom,top,near,farfloat32)Mat4 FrustumgeneratesaFrustumMatrix. funcHomogRotate3D¶ funcHomogRotate3D(anglefloat32,axisVec3)Mat4 HomogRotate3Dcreatesa3DrotationMatrixthatrotatesby(radian)angleaboutsomearbitraryaxisgivenbyanormalizedVector. Itproducesahomogeneousmatrix(4x4) Whereciscos(angle)andsissin(angle),andx,y,andzarethefirst,second,andthirdelementsoftheaxisvector(respectively): [[x^2(1-c)+c,xy(1-c)-zs,xz(1-c)+ys,0]] [[xy(1-c)+zs,y^2(1-c)+c,yz(1-c)-xs,0]] [[xz(1-c)-ys,yz(1-c)+xs,z^2(1-c)+c,0]] [[0,0,0,1]] funcHomogRotate3DX¶ funcHomogRotate3DX(anglefloat32)Mat4 HomogRotate3DXisthesameasRotate3DX,excepthomogeneous(4x4withtheextrarow/colbeingallzeroeswithaoneinthebottomright) funcHomogRotate3DY¶ funcHomogRotate3DY(anglefloat32)Mat4 HomogRotate3DYisthesameasRotate3DY,excepthomogeneous(4x4withtheextrarow/colbeingallzeroeswithaoneinthebottomright) funcHomogRotate3DZ¶ funcHomogRotate3DZ(anglefloat32)Mat4 HomogRotate3DZisthesameasRotate3DZ,excepthomogeneous(4x4withtheextrarow/colbeingallzeroeswithaoneinthebottomright) funcIdent4¶ funcIdent4()Mat4 Ident4returnsthe4x4identitymatrix. Theidentitymatrixisasquarematrixwiththevalue1onits diagonals.Thecharacteristicpropertyoftheidentitymatrixisthat anymatrixmultipliedbyitisitself.(MI=M;IN=N) funcLookAt¶ funcLookAt(eyeX,eyeY,eyeZ,centerX,centerY,centerZ,upX,upY,upZfloat32)Mat4 LookAtgeneratesatransformmatrixfromworldspacetothegiveneyespace. funcLookAtV¶ funcLookAtV(eye,center,upVec3)Mat4 LookAtVgeneratesatransformmatrixfromworldspaceintothespecificeye space. funcMat4FromCols¶ funcMat4FromCols(col0,col1,col2,col3Vec4)Mat4 Mat4FromColsbuildsanewmatrixfromcolumnvectors. funcMat4FromRows¶ funcMat4FromRows(row0,row1,row2,row3Vec4)Mat4 funcOrtho¶ funcOrtho(left,right,bottom,top,near,farfloat32)Mat4 OrthogeneratesanOrthoMatrix. funcOrtho2D¶ funcOrtho2D(left,right,bottom,topfloat32)Mat4 Ortho2DisequivalenttoOrthowiththenearandfarplanesbeing-1and1, respectively. funcPerspective¶ funcPerspective(fovy,aspect,near,farfloat32)Mat4 PerspectivegeneratesaPerspectiveMatrix. funcScale3D¶ funcScale3D(scaleX,scaleY,scaleZfloat32)Mat4 Scale3Dcreatesahomogeneous3Dscalingmatrix [[scaleX,0,0,0]] [[0,scaleY,0,0]] [[0,0,scaleZ,0]] [[0,0,0,1]] funcShearX3D¶ funcShearX3D(shearY,shearZfloat32)Mat4 ShearX3Dcreatesahomogeneous3DshearmatrixalongtheX-axis funcShearY3D¶ funcShearY3D(shearX,shearZfloat32)Mat4 ShearY3Dcreatesahomogeneous3DshearmatrixalongtheY-axis funcShearZ3D¶ funcShearZ3D(shearX,shearYfloat32)Mat4 ShearZ3Dcreatesahomogeneous3DshearmatrixalongtheZ-axis funcTranslate3D¶ funcTranslate3D(Tx,Ty,Tzfloat32)Mat4 Translate3Dreturnsahomogeneous(4x4for3D-space)TranslationmatrixthatmovesapointbyTxunitsinthex-direction,Tyunitsinthey-direction, andTzunitsinthez-direction [[1,0,0,Tx]] [[0,1,0,Ty]] [[0,0,1,Tz]] [[0,0,0,1]] func(Mat4)Abs¶ func(mMat4)Abs()Mat4 Absreturnstheelement-wiseabsolutevalueofthismatrix func(Mat4)Add¶ func(m1Mat4)Add(m2Mat4)Mat4 Addperformsanelement-wiseadditionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andaddingthecorrespondingvalueofm2. func(Mat4)ApproxEqual¶ func(m1Mat4)ApproxEqual(m2Mat4)bool ApproxEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices, asifFloatEqualhadbeenused. func(Mat4)ApproxEqualThreshold¶ func(m1Mat4)ApproxEqualThreshold(m2Mat4,thresholdfloat32)bool ApproxEqualThresholdperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenepsilonthreshold,asifFloatEqualThresholdhadbeenused. func(Mat4)ApproxFuncEqual¶ func(m1Mat4)ApproxFuncEqual(m2Mat4,eqfunc(float32,float32)bool)bool ApproxFuncEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenequalityfunctions,intendedtobeusedwithFloatEqualFunc;althoughandcomparison functionmaybeusedinpractice. func(Mat4)At¶ func(mMat4)At(row,colint)float32 Atreturnsthematrixelementatthegivenrowandcolumn. Thisisequivalenttomat[col*numRow+row]wherenumRowisconstant (E.G.foraMat3x2it'sequalto3) Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor At(5,0)willworkjustlikeAt(1,1).Oritmaypanicifit'soutofbounds. func(Mat4)Col¶ func(mMat4)Col(colint)Vec4 Colreturnsavectorrepresentingthecorrespondingcolumn(startingatcol0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecNforaMxNmatrix. func(Mat4)Cols¶ func(mMat4)Cols()(col0,col1,col2,col3Vec4) Colsdecomposesamatrixintoitscorrespondingcolumnvectors. Thisisequivalenttocallingmat.Colforeachcolumn. func(Mat4)Det¶ func(mMat4)Det()float32 Detreturnsthedeterminantofamatrix.Itisameasureofasquarematrix's singularityandinvertability,amongotherthings.Inthislibrary,the determinantishardcodedbasedonpre-computedcofactorexpansion,anduses noloops.Ofcourse,theadditionandmultiplicationmuststillbedone. func(Mat4)Diag¶ func(mMat4)Diag()Vec4 Diagisabasicoperationonasquarematrixthatsimply returnsmaindiagonal(meaningallelementssuchthatrow==col). func(Mat4)Index¶ func(mMat4)Index(row,colint)int Indexreturnstheindexofthegivenrowandcolumn,tobeusedwithdirect access.E.G.Index(0,0)=0. Thisisagarbage-ingarbage-outmethod.Forinstance,onaMat4askingfortheindexof (5,0)willworkthesameasaskingfor(1,1).Oritmaygiveyouavaluethatwillcause apanicifyoutrytoaccessthearraywithitifit'strulyoutofbounds. func(Mat4)Inv¶ func(mMat4)Inv()Mat4 Invcomputestheinverseofasquarematrix.Aninverseisasquarematrixsuchthatwhenmultipliedbythe original,yieldstheidentity. M_inv*M=M*M_inv=I Inthislibrary,themathisprecomputed,andusesnoloops,thoughthemultiplications,additions,determinantcalculation,andscaling arestilldone.Thiscanstillbe(relatively)expensivefora4x4. Thisfunctionchecksthedeterminanttoseeifthematrixisinvertible. Ifthedeterminantis0.0,thisfunctionreturnsthezeromatrix.However,duetofloatingpointerrors,itis entirelyplausibletogetafalsepositiveornegative. Inthefuture,analternatefunctionmaybewrittenwhichtakesinapre-computeddeterminant. func(Mat4)Mat2¶ func(mMat4)Mat2()Mat2 func(Mat4)Mat3¶ func(mMat4)Mat3()Mat3 func(Mat4)Mul¶ func(m1Mat4)Mul(cfloat32)Mat4 Mulperformsascalarmultiplcationofthematrix.Thisisequivalenttoiterating overeveryelementofthematrixandmultiplyitbyc. func(Mat4)Mul4¶ func(m1Mat4)Mul4(m2Mat4)Mat4 Mul4performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat4)Mul4x1¶ func(m1Mat4)Mul4x1(m2Vec4)Vec4 Mul4x1performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat4)Mul4x2¶ func(m1Mat4)Mul4x2(m2Mat4x2)Mat4x2 Mul4x2performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat4)Mul4x3¶ func(m1Mat4)Mul4x3(m2Mat4x3)Mat4x3 Mul4x3performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat4)Row¶ func(mMat4)Row(rowint)Vec4 Rowreturnsavectorrepresentingthecorrespondingrow(startingatrow0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecMforaMxNmatrix. func(Mat4)Rows¶ func(mMat4)Rows()(row0,row1,row2,row3Vec4) Rowsdecomposesamatrixintoitscorrespondingrowvectors. Thisisequivalenttocallingmat.Rowforeachrow. func(*Mat4)Set¶ func(m*Mat4)Set(row,colint,valuefloat32) Setsetsthecorrespondingmatrixelementatthegivenrowandcolumn. Thishasapointerreceiverbecauseitmutatesthematrix. Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor Set(5,0,val)willworkjustlikeSet(1,1,val).Oritmaypanicifit'soutofbounds. func(*Mat4)SetCol¶ func(m*Mat4)SetCol(colint,vVec4) SetColsetsaColumnwithintheMatrix,soitmutatesthecallingmatrix. func(*Mat4)SetRow¶ func(m*Mat4)SetRow(rowint,vVec4) SetRowsetsaRowwithintheMatrix,soitmutatesthecallingmatrix. func(Mat4)String¶ func(mMat4)String()string Prettyprintsthematrix func(Mat4)Sub¶ func(m1Mat4)Sub(m2Mat4)Mat4 Subperformsanelement-wisesubtractionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andsubtractingthecorrespondingvalueofm2. func(Mat4)Trace¶ func(mMat4)Trace()float32 Traceisabasicoperationonasquarematrixthatsimply sumsupallelementsonthemaindiagonal(meaningallelementssuchthatrow==col). func(Mat4)Transpose¶ func(m1Mat4)Transpose()Mat4 Transposeproducesthetransposeofthismatrix.ForanyMxNmatrix thetransposeisanNxMmatrixwiththerowsswappedwiththecolumns.Forinstance thetransposeoftheMat3x2isaMat2x3likeso: [[ab]][[ace]] [[cd]]=[[bdf]] [[ef]] typeMat4x2¶ typeMat4x2[8]float32 funcMat4x2FromCols¶ funcMat4x2FromCols(col0,col1Vec4)Mat4x2 Mat4x2FromColsbuildsanewmatrixfromcolumnvectors. funcMat4x2FromRows¶ funcMat4x2FromRows(row0,row1,row2,row3Vec2)Mat4x2 func(Mat4x2)Abs¶ func(mMat4x2)Abs()Mat4x2 Absreturnstheelement-wiseabsolutevalueofthismatrix func(Mat4x2)Add¶ func(m1Mat4x2)Add(m2Mat4x2)Mat4x2 Addperformsanelement-wiseadditionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andaddingthecorrespondingvalueofm2. func(Mat4x2)ApproxEqual¶ func(m1Mat4x2)ApproxEqual(m2Mat4x2)bool ApproxEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices, asifFloatEqualhadbeenused. func(Mat4x2)ApproxEqualThreshold¶ func(m1Mat4x2)ApproxEqualThreshold(m2Mat4x2,thresholdfloat32)bool ApproxEqualThresholdperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenepsilonthreshold,asifFloatEqualThresholdhadbeenused. func(Mat4x2)ApproxFuncEqual¶ func(m1Mat4x2)ApproxFuncEqual(m2Mat4x2,eqfunc(float32,float32)bool)bool ApproxFuncEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenequalityfunctions,intendedtobeusedwithFloatEqualFunc;althoughandcomparison functionmaybeusedinpractice. func(Mat4x2)At¶ func(mMat4x2)At(row,colint)float32 Atreturnsthematrixelementatthegivenrowandcolumn. Thisisequivalenttomat[col*numRow+row]wherenumRowisconstant (E.G.foraMat3x2it'sequalto3) Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor At(5,0)willworkjustlikeAt(1,1).Oritmaypanicifit'soutofbounds. func(Mat4x2)Col¶ func(mMat4x2)Col(colint)Vec4 Colreturnsavectorrepresentingthecorrespondingcolumn(startingatcol0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecNforaMxNmatrix. func(Mat4x2)Cols¶ func(mMat4x2)Cols()(col0,col1Vec4) Colsdecomposesamatrixintoitscorrespondingcolumnvectors. Thisisequivalenttocallingmat.Colforeachcolumn. func(Mat4x2)Index¶ func(mMat4x2)Index(row,colint)int Indexreturnstheindexofthegivenrowandcolumn,tobeusedwithdirect access.E.G.Index(0,0)=0. Thisisagarbage-ingarbage-outmethod.Forinstance,onaMat4askingfortheindexof (5,0)willworkthesameasaskingfor(1,1).Oritmaygiveyouavaluethatwillcause apanicifyoutrytoaccessthearraywithitifit'strulyoutofbounds. func(Mat4x2)Mul¶ func(m1Mat4x2)Mul(cfloat32)Mat4x2 Mulperformsascalarmultiplcationofthematrix.Thisisequivalenttoiterating overeveryelementofthematrixandmultiplyitbyc. func(Mat4x2)Mul2¶ func(m1Mat4x2)Mul2(m2Mat2)Mat4x2 Mul2performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat4x2)Mul2x1¶ func(m1Mat4x2)Mul2x1(m2Vec2)Vec4 Mul2x1performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat4x2)Mul2x3¶ func(m1Mat4x2)Mul2x3(m2Mat2x3)Mat4x3 Mul2x3performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat4x2)Mul2x4¶ func(m1Mat4x2)Mul2x4(m2Mat2x4)Mat4 Mul2x4performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat4x2)Row¶ func(mMat4x2)Row(rowint)Vec2 Rowreturnsavectorrepresentingthecorrespondingrow(startingatrow0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecMforaMxNmatrix. func(Mat4x2)Rows¶ func(mMat4x2)Rows()(row0,row1,row2,row3Vec2) Rowsdecomposesamatrixintoitscorrespondingrowvectors. Thisisequivalenttocallingmat.Rowforeachrow. func(*Mat4x2)Set¶ func(m*Mat4x2)Set(row,colint,valuefloat32) Setsetsthecorrespondingmatrixelementatthegivenrowandcolumn. Thishasapointerreceiverbecauseitmutatesthematrix. Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor Set(5,0,val)willworkjustlikeSet(1,1,val).Oritmaypanicifit'soutofbounds. func(*Mat4x2)SetCol¶ func(m*Mat4x2)SetCol(colint,vVec4) SetColsetsaColumnwithintheMatrix,soitmutatesthecallingmatrix. func(*Mat4x2)SetRow¶ func(m*Mat4x2)SetRow(rowint,vVec2) SetRowsetsaRowwithintheMatrix,soitmutatesthecallingmatrix. func(Mat4x2)String¶ func(mMat4x2)String()string Prettyprintsthematrix func(Mat4x2)Sub¶ func(m1Mat4x2)Sub(m2Mat4x2)Mat4x2 Subperformsanelement-wisesubtractionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andsubtractingthecorrespondingvalueofm2. func(Mat4x2)Transpose¶ func(m1Mat4x2)Transpose()Mat2x4 Transposeproducesthetransposeofthismatrix.ForanyMxNmatrix thetransposeisanNxMmatrixwiththerowsswappedwiththecolumns.Forinstance thetransposeoftheMat3x2isaMat2x3likeso: [[ab]][[ace]] [[cd]]=[[bdf]] [[ef]] typeMat4x3¶ typeMat4x3[12]float32 funcMat4x3FromCols¶ funcMat4x3FromCols(col0,col1,col2Vec4)Mat4x3 Mat4x3FromColsbuildsanewmatrixfromcolumnvectors. funcMat4x3FromRows¶ funcMat4x3FromRows(row0,row1,row2,row3Vec3)Mat4x3 func(Mat4x3)Abs¶ func(mMat4x3)Abs()Mat4x3 Absreturnstheelement-wiseabsolutevalueofthismatrix func(Mat4x3)Add¶ func(m1Mat4x3)Add(m2Mat4x3)Mat4x3 Addperformsanelement-wiseadditionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andaddingthecorrespondingvalueofm2. func(Mat4x3)ApproxEqual¶ func(m1Mat4x3)ApproxEqual(m2Mat4x3)bool ApproxEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices, asifFloatEqualhadbeenused. func(Mat4x3)ApproxEqualThreshold¶ func(m1Mat4x3)ApproxEqualThreshold(m2Mat4x3,thresholdfloat32)bool ApproxEqualThresholdperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenepsilonthreshold,asifFloatEqualThresholdhadbeenused. func(Mat4x3)ApproxFuncEqual¶ func(m1Mat4x3)ApproxFuncEqual(m2Mat4x3,eqfunc(float32,float32)bool)bool ApproxFuncEqualperformsanelement-wiseapproximateequalitytestbetweentwomatrices withagivenequalityfunctions,intendedtobeusedwithFloatEqualFunc;althoughandcomparison functionmaybeusedinpractice. func(Mat4x3)At¶ func(mMat4x3)At(row,colint)float32 Atreturnsthematrixelementatthegivenrowandcolumn. Thisisequivalenttomat[col*numRow+row]wherenumRowisconstant (E.G.foraMat3x2it'sequalto3) Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor At(5,0)willworkjustlikeAt(1,1).Oritmaypanicifit'soutofbounds. func(Mat4x3)Col¶ func(mMat4x3)Col(colint)Vec4 Colreturnsavectorrepresentingthecorrespondingcolumn(startingatcol0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecNforaMxNmatrix. func(Mat4x3)Cols¶ func(mMat4x3)Cols()(col0,col1,col2Vec4) Colsdecomposesamatrixintoitscorrespondingcolumnvectors. Thisisequivalenttocallingmat.Colforeachcolumn. func(Mat4x3)Index¶ func(mMat4x3)Index(row,colint)int Indexreturnstheindexofthegivenrowandcolumn,tobeusedwithdirect access.E.G.Index(0,0)=0. Thisisagarbage-ingarbage-outmethod.Forinstance,onaMat4askingfortheindexof (5,0)willworkthesameasaskingfor(1,1).Oritmaygiveyouavaluethatwillcause apanicifyoutrytoaccessthearraywithitifit'strulyoutofbounds. func(Mat4x3)Mul¶ func(m1Mat4x3)Mul(cfloat32)Mat4x3 Mulperformsascalarmultiplcationofthematrix.Thisisequivalenttoiterating overeveryelementofthematrixandmultiplyitbyc. func(Mat4x3)Mul3¶ func(m1Mat4x3)Mul3(m2Mat3)Mat4x3 Mul3performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat4x3)Mul3x1¶ func(m1Mat4x3)Mul3x1(m2Vec3)Vec4 Mul3x1performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat4x3)Mul3x2¶ func(m1Mat4x3)Mul3x2(m2Mat3x2)Mat4x2 Mul3x2performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat4x3)Mul3x4¶ func(m1Mat4x3)Mul3x4(m2Mat3x4)Mat4 Mul3x4performsa"matrixproduct"betweenthismatrix andanotherofthegivendimension.Foranytwomatricesofdimensionality MxNandNxO,theresultwillbeMxO.Forinstance,Mat4multipliedusing Mul4x2willresultinaMat4x2. func(Mat4x3)Row¶ func(mMat4x3)Row(rowint)Vec3 Rowreturnsavectorrepresentingthecorrespondingrow(startingatrow0). Thispackagemakesnodistinctionbetweenrowandcolumnvectors,soit willbeanormalVecMforaMxNmatrix. func(Mat4x3)Rows¶ func(mMat4x3)Rows()(row0,row1,row2,row3Vec3) Rowsdecomposesamatrixintoitscorrespondingrowvectors. Thisisequivalenttocallingmat.Rowforeachrow. func(*Mat4x3)Set¶ func(m*Mat4x3)Set(row,colint,valuefloat32) Setsetsthecorrespondingmatrixelementatthegivenrowandcolumn. Thishasapointerreceiverbecauseitmutatesthematrix. Thismethodisgarbage-ingarbage-out.Forinstance,onaMat4askingfor Set(5,0,val)willworkjustlikeSet(1,1,val).Oritmaypanicifit'soutofbounds. func(*Mat4x3)SetCol¶ func(m*Mat4x3)SetCol(colint,vVec4) SetColsetsaColumnwithintheMatrix,soitmutatesthecallingmatrix. func(*Mat4x3)SetRow¶ func(m*Mat4x3)SetRow(rowint,vVec3) SetRowsetsaRowwithintheMatrix,soitmutatesthecallingmatrix. func(Mat4x3)String¶ func(mMat4x3)String()string Prettyprintsthematrix func(Mat4x3)Sub¶ func(m1Mat4x3)Sub(m2Mat4x3)Mat4x3 Subperformsanelement-wisesubtractionoftwomatrices,thisis equivalenttoiteratingovereveryelementofm1andsubtractingthecorrespondingvalueofm2. func(Mat4x3)Transpose¶ func(m1Mat4x3)Transpose()Mat3x4 Transposeproducesthetransposeofthismatrix.ForanyMxNmatrix thetransposeisanNxMmatrixwiththerowsswappedwiththecolumns.Forinstance thetransposeoftheMat3x2isaMat2x3likeso: [[ab]][[ace]] [[cd]]=[[bdf]] [[ef]] typeMatMxN¶ typeMatMxNstruct{ //containsfilteredorunexportedfields } MatMxNisanarbitrarymxnmatrixbackedbyasliceoffloats. Thisisemphaticallynotrecommendedforhardcoren-dimensional linearalgebra.ForthatpurposeIrecommendgithub.com/gonum/matrixor well-testedClibrariessuchasBLASorLAPACK. Thisismeanttocomplementfuturealgorithmsthatmayrequirematriceslargerthan 4x4,butstillrelativelysmall(e.g.Jacobeansforinversekinematics). Itmakesuseofthesamememorysync.PoolsetthatVecNdoes,withthesamesizingrules. MatMNwillalwayscheckifthereceiverisnilonanymethod.MeaningMathMN(nil).Add(dst,m2) shouldalwayswork.ExceptfortheReshapefunction,thesemanticsofthisisto"propogate"nils forward,soifaninvalidoperationoccursinalongchainofmatrixoperations,theoverallresultwillbenil. funcDiagN¶ funcDiagN(dst*MatMxN,diag*VecN)*MatMxN DiagNcreatesanNxNdiagonalmatrixseededbythediagonalvectordiag. Meaning:forallentries,wherei==j,dst.At(i,j)=diag[i].Otherwise dst.At(i,j)=0 Thisreshapesdsttothecorrectsize,returning/grabbingfromthememory poolasnecessary. funcIdentN¶ funcIdentN(dst*MatMxN,nint)*MatMxN IdentNstorestheNxNidentitymatrixindst,reallocatingasnecessary. funcNewMatrix¶ funcNewMatrix(m,nint)(mat*MatMxN) NewMatrixcreatesamatrixbackedbyanewsliceofsizem*n funcNewMatrixFromData¶ funcNewMatrixFromData(src[]float32,m,nint)*MatMxN NewMatrixFromDatareturnsamatrixwithdataspecifiedbythedatainsrc Forinstance,tocreatea3x3MatMNfromaMat3 m1:=mgl32.Rotate3DX(3.14159) mat:=mgl32.NewBackedMatrix(m1[:],3,3) willcreateanMNmatrixmatchingthedataintheoriginalrotationmatrix. ThismatrixisNOTbackedbytheinitialslice;it'sacopyofthedata Ifm*n>cap(src),thisfunctionwillpanic. func(*MatMxN)Add¶ func(mat*MatMxN)Add(dst*MatMxN,addend*MatMxN)*MatMxN Addisthearithemtic+operatordefinedonaMatMxN. func(*MatMxN)ApproxEqual¶ func(mat*MatMxN)ApproxEqual(m2*MatMxN)bool ApproxEqualreturnswhetherthetwovectorsareapproximatelyequal(See FloatEqual). func(*MatMxN)ApproxEqualFunc¶ func(mat*MatMxN)ApproxEqualFunc(m2*MatMxN,compfunc(float32,float32)bool)bool ApproxEqualFuncreturnswhetherthetwovectorsareapproximatelyequal, givenafunctionwhichcomparestwoscalarelements. func(*MatMxN)ApproxEqualThreshold¶ func(mat*MatMxN)ApproxEqualThreshold(m2*MatMxN,epsilonfloat32)bool ApproxEqualThresholdreturnswhetherthetwovectorsareapproximatelyequal towithinthegiventhresholdgivenby"epsilon"(SeeApproxEqualThreshold). func(*MatMxN)At¶ func(mat*MatMxN)At(row,colint)float32 Atreturnstheelementatthegivenrowandcolumn. Thisisgarbagein/garbageoutanddoesnobounds checking.Ifthecomputationhappenstoleadtoaninvalid element,itwillbereturned;oritmaypanic. func(*MatMxN)InferMatrix¶ func(mat*MatMxN)InferMatrix(minterface{})(*MatMxN,error) InferMatrixinfersanMxNmatrixfromaconstantmatrixfromthispackage. Forinstance,aMat2x3inferredwiththisfunctionwillworkjustlike NewMatrixFromData(m[:],2,3)wheremistheMat2x3.Thisusesatypeswitch. IpersonallyrecommendusingNewMatrixFromData,becauseitavoidsa potentiallycostlytypeswitch.However,thisisalsomorerobustandless errorproneifyouchangethesizeofyourmatrixsomewhere. Ifthevaluepassedinisnotrecognized,itreturnsanInferMatrixError. func(*MatMxN)Mul¶ func(mat*MatMxN)Mul(dst*MatMxN,cfloat32)*MatMxN Mulperformsascalarmultiplicationbetweenmatandsomeconstantc, storingtheresultindst.Matanddstcanbeequal.Ifdstisnotthe correctsize,aReshapewilloccur. func(*MatMxN)MulMxN¶ func(mat*MatMxN)MulMxN(dst*MatMxN,mul*MatMxN)*MatMxN MulMxNperformsmatrixmultiplicationonMxNmatrixmatandNxOmatrixmul, storingtheresultindst.Thisreturnsdst,orniliftheoperationisnot abletobeperformed. Ifmat==dst,ormul==dstatemporarymatrixwillbeused. Thisusesthenaivealgorithm(thoughonsmallermatrices,thiscanactually befaster;aboutlen(mat)+len(mul)



請為這篇文章評分?