zmath.math3d
Usefull functions to work in 3d math
-
Declaration
immutable boolis4dMat(M);Checks if a type is a valid Matrix for 3d math over 4d
-
Declaration
pure nothrow @nogc MperspectiveMat(M = Mat4f, T = float, U = float, V = float, W = float)(Tfov, Uaspect, VzMin, WzMax) if (is4dMat!M && isNumeric!T && isNumeric!U && isNumeric!V && isNumeric!W);Creates a projection matrix (similar to gluPerspective)
Parameters
TfovField of View in radians (PI_2 -> 90ยบ)
UaspectAspect ratio (x/y)
VzMinNear clipping plane
WzMaxFar clipping plane Returns a perspective projection matrix
-
Declaration
pure nothrow @nogc MorthoMat(M = Mat4f, T = float, U = float, V = float, W = float, X = float, Y = float)(TxMin, UxMax, VyMin, WyMax, XzMin= 0, YzMax= 1) if (is4dMat!M && isNumeric!T && isNumeric!U && isNumeric!V && isNumeric!W && isNumeric!X && isNumeric!Y);Creates a orthographic projection matrix
Parameters
TxMinLeft clipping plane
UxMaxRight clipping plane
VyMinBottom clipping plane
WyMaxTop clipping plane
XzMinNear clipping plane
YzMaxFar clipping plane Returns a orthographic projection matrix
-
Declaration
pure nothrow @nogc MorthoMat(M = Mat4f, T = float, U = float, V = float)(Twidth= 1, Uheight= 1, Vdeep= 1) if (is4dMat!M && isNumeric!T && isNumeric!U && isNumeric!V);Creates a orthographic projection matrix
Parameters
TwidthWidth of visible zone
UheightHeight of visible zone
VdeepDeep of visible zone Returns a orthographic projection matrix
-
Declaration
pure nothrow @nogc MtranslateMat(M = Mat4f, V = Vec3f)(Vv) if (isVector!V && (V.dim <= 3) && is4dMat!M);Creates a translation matrix from a 2d/3d Vector
Parameters
Vv2d/3d Vector Returns a translation matrix
-
Declaration
pure nothrow @nogc MtranslateMat(M = Mat4f, T = float)(Tx, Ty, Tz) if (is4dMat!M && is(T : real));Creates a translation matrix from xyz coords
Parameters
TxX coord
TyY coord
TzZ coord Returns a translation matrix
-
Declaration
pure nothrow @nogc MscaleMat(M = Mat4f, T = float)(Ts) if (is4dMat!M && is(T : real));Creates a uniform 3d scale matrix
Parameters
Tsscale factor Returns a scale matrix
-
Declaration
pure nothrow @nogc MscaleMat(M = Mat4f, T = float)(Tx, Ty, Tz) if (is4dMat!M && is(T : real));Creates a not uniform 3d scale matrix
Parameters
TxX axis scale
TyY axis scale
TzZ axis scale Returns a scale matrix
-
Declaration
pure nothrow @nogc MscaleMat(M = Mat4f, V = Vec3f)(Vv) if (isVector!V && (V.dim <= 3) && is4dMat!M);Creates a not uniform 3d scale matrix
Parameters
VvVector with scale factor. If is a 2d Vector, z axis scale factor is 1 Returns a scale matrix
-
Declaration
pure nothrow @nogc MrotMat(M = Mat4f, V = Vec3f, T = float)(Vv, Tangle) if (isVector!V && (V.dim <= 3) && is4dMat!M && __traits(isFloating, T));Creates a rotation matrix from a axis and
anglein radiansParameters
VvRotation axis
Tangleanglein radians Returns a 3d rotation matrix -
Declaration
pure nothrow @nogc MrotMat(M = Mat4f, T = float, U = float)(Tx, Ty, Tz, Uangle) if (is4dMat!M && is(T : real) && is(U : real));Creates a rotation matrix from a axis and
anglein radiansParameters
TxX coord of rotation axis
TyY coord of rotation axis
TzZ coord of rotation axis
Uangleanglein radians Returns a 3d rotation matrix -
Declaration
MrotMat(M = Mat4f, Q = Qua_f)(Qq) if (is4dMat!M && isQuaternion!Q);Creates a rotation matrix from a Quaternion
Parameters
QqQuaternion that represents a rotation Returns a 3d rotation matrix
-
Declaration
pure nothrow @nogc MlookAt(M = Mat4f, V = Vec3f, T = float)(Veye, Vtarget, Vup) if (is4dMat!M && isNumeric!T && isVector!V && (V.dim <= 3));Look At projection Based on gfm code