0.1.6 • Published 4 years ago

anny.math v0.1.6

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Math

This is a basic Math package. It contains routines to work with matrices, quaternions and vectors. All those entities are represented as Float32Arrays. | Property | Description | | ------ | ------ | | Mathf.matrix4x4 | access available matrix functions. | | Mathf.quaternion | access available quaternion functions. | | Mathf.vector | access available vector functions. | | Mathf.deg2Rad | use this to convert degrees to radians. | | Mathf.rad2Deg | use this to convert radians to degrees. |

MethodDescription
Mathf.asUintconvert number to uint32.
Mathf.asIntconvert number to int32.
Mathf.asFloatconvert number to float.

Matrices

Matrices are stored in the column-major order | Method | Description | | ------ | ------ | | Mathf.matrix4x4.identity | gets the identity matrix .| | Mathf.matrix4x4.inverse | calculates full matrix inversion. | | Mathf.matrix4x4.scaleWithVector3 | constructs scale matrix from a given float3 vector containing the 3 axis scales. | | Mathf.matrix4x4.scaleWithNumber | constructs scale matrix from a given uniform scale value. | | Mathf.matrix4x4.mul | calculates the float4x4 matrix result of a matrix multiplication between a float4x4 matrix and a float4x4 matrix. | | Mathf.matrix4x4.set | sets matrix with rows. | | Mathf.matrix4x4.setWithMatrix | set matrix with values from another matrix. | | Mathf.matrix4x4.translateWithVector3 | calculates a float4x4 translation matrix given a float3 translation vector. | | Mathf.matrix4x4.setWithQuaternion | calculates a float4x4 matrix constructed from a quaternion. | | Mathf.matrix4x4.setWithQuaternionAndTranslate | calculates a float4x4 matrix constructed from a quaternion and a given float3 translation vector. |

Quaternions

MethodDescription
Mathf.quaternion.eulerXYZcalculates a quaternion constructed by first performing a rotation around the x-axis, then the y-axis and finally the z-axis
Mathf.quaternion.eulerXZYcalculates a quaternion constructed by first performing a rotation around the x-axis, then the z-axis and finally the y-axis.
Mathf.quaternion.eulerYXZcalculates a quaternion constructed by first performing a rotation around the y-axis, then the x-axis and finally the z-axis.
Mathf.quaternion.eulerYZXcalculates a quaternion constructed by first performing a rotation around the y-axis, then the z-axis and finally the x-axis.
Mathf.quaternion.eulerZXYcalculates a quaternion constructed by first performing a rotation around the z-axis, then the x-axis and finally the y-axis.
Mathf.quaternion.eulerZYXcalculates a quaternion constructed by first performing a rotation around the z-axis, then the y-axis and finally the x-axis.
Mathf.quaternion.mulcalculates the result of transforming the quaternion b by the quaternion a.

Vectors

Vectors may be treated as Float32Arrays and also as instances of classes: Vector2, Vector3, Vector4 | Method | Description | | ------ | ------ | | Mathf.vector.add | returns a sum of two vectors element wise. | | Mathf.vector.sub | returns a subtraction of two vectors element wise. | | Mathf.vector.mul | returns a multiplication of two vectors element wise. | | Mathf.vector.scale | returns a multiplication of a vector by another vector element wise. | | Mathf.vector.div | returns a division of a vector and number element wise. | | Mathf.vector.inverse | returns vector inversion as 1 / v[i]. | | Mathf.vector.equals | returns true if vectors are equal. | | Mathf.vector.length | returns length(magnitude) of a vector. | | Mathf.vector.distance | returns distance between two points. | | Mathf.vector.dot | returns dot product of two vectors. | | Mathf.vector.cross | returns cross product of two vectors. |

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago