Singleton class containing method for mathematical calculations.
Contains methods for: vectors, matrices, quaternions, planes and colors.
Learn it, use it, worship it.
Please notice that all vector related methods have basically 4 versions (2D,3D,4D and shot version of 3D). Please add your content to all corresponding pages.
VB.NET
'todo
C++
#include "CTVMathLibrary.h" CTVMathLibrary* TVMath = new CTVMathLibrary(); float Angle = TVMath->Direction2Ang(0.5f,0.5f);
TVMathLibrary is a singleton.
Common methods like vector addition and subtraction or matrix multiplication are also implemented as operators.
| Method | Description | |
|---|---|---|
| ACos | Calculates the ACos of a value | |
| ASin | Calculates the ASin of a value | |
| ATan | Calculates the ATan of a value | |
| ATan2 | Calculates the ATan2 given x and y values | |
| Deg2Rad | Converts given angle in Degrees to Radians. | |
| Direction2Ang | Converts direction to angle | |
| GetDistance2D | Calculates the distance between two 2D vectors | |
| GetDistance3D | Calculates the distance between two 3D vectors | |
| GetDistanceVec2D | Calculates the distance between two TV_2DVECTOR vectors | |
| GetDistanceVec3D | Calculates the distance between two TV_3DVECTOR vectors | |
| GetIndex | Short description of GetIndex | |
| GetMousePickVectors | Returns mouse pick vectors for current camera and x,y mouse position | |
| IntersectionXZPlane | Calculates intersection point of a ray and XZ plane | |
| MoveAroundPoint | Calculates position of point moving around specified origin given radius and angles | |
| Project2DPointTo3D | Projects a point from screen coordinates to 3D world | |
| Project3DPointTo2D | Projects a point from 3D world to 2D screen coordinates | |
| Rad2Deg | Converts given angle in Radians to Degrees | |
| SetIndex | Short description of SetIndex | |
| SortVectorList | Short description of SortVectorList | |
| SortVectorList | Short description of SortVectorList | |
| TVColorAdd | Performs color addition | |
| TVColorAdjustContrast | Adjusts color contrast | |
| TVColorAdjustSaturation | Adjusts color saturation | |
| TVColorLerp | Performs color interpolation | |
| TVColorModulate | Perfroms color modulation | |
| TVColorNegative | Calculates ngative color | |
| TVColorScale | Multiplies color by a scalar | |
| TVColorSubtract | Performs color subtraction | |
| TVConvertMatrixToQuaternion | Converts matrix to quaternion | |
| TVConvertQuaternionToMatrix | Convert quaternion to matrix | |
| TVEulerAnglesFromMatrix | Calculates Euler angles from matrix | |
| TVMatrixClipPlaneProjection | Clips projection matrix by plane | |
| TVMatrixDecompose | Decomposes matrix into scale, rotation and translation | |
| TVMatrixIdentity | Creates identity matrix | |
| TVMatrixInverse | Calculates inverse of a matrix | |
| TVMatrixInvertReflectCulling | Short description of TVMatrixInvertReflectCulling | |
| TVMatrixLerp | Interpolates between two matrices | |
| TVMatrixLookAt | Creates transformation matrix from look-at points | |
| TVMatrixMultiply | Performs matrix multiplication | |
| TVMatrixReflect | Calculates transformation matrix for reflection cameras | |
| TVMatrixRotationAxis | Creates rotation matrix given axis and angle | |
| TVMatrixRotationQuaternion | Converts quaternion to matrix | |
| TVMatrixRotationX | Crates rotation matrix for rotation along X axis | |
| TVMatrixRotationY | Crates rotation matrix for rotation along Y axis | |
| TVMatrixRotationYawPitchRoll | Crates rotation matrix from Yar, Pitch and Roll angles | |
| TVMatrixRotationZ | Crates rotation matrix for rotation along X axis | |
| TVMatrixScaling | Creates transformation matrix for scaling | |
| TVMatrixShadow | Creates transformation matrix for shadow placement | |
| TVMatrixTranslation | Creates translation matrix | |
| TVMatrixTranspose | Transposes a matrix | |
| TVPlaneDot | Distance to point (TV_4DVECTOR) | |
| TVPlaneDotCoord | Distance to point (TV_3DVECTOR) | |
| TVPlaneDotNormal | Short description of TVPlaneDotNormal | |
| TVPlaneFromPointNormal | Creates plane from point and normal vector | |
| TVPlaneFromPoints | Creates plane from three points | |
| TVPlaneIntersectLine | Calculates plane-line intersection | |
| TVPlaneNormalize | Normalizes plane coefficients | |
| TVPlaneScale | Scale plane coefficients | |
| TVPlaneTransform | Transform plane by matrix | |
| TVQuaternionBaryCentric | Creates quaternion in barycentric coordinates | |
| TVQuaternionConjugate | Creates conjugate quaternion | |
| TVQuaternionDot | Calculates quaternion dot product | |
| TVQuaternionExp | Calculates quaternion Exp | |
| TVQuaternionIdentity | Creates identity quaternion | |
| TVQuaternionInverse | Inverts quaternion | |
| TVQuaternionLength | Calucates length of quaternion | |
| TVQuaternionLengthSq | Calculates squared length of quaternion | |
| TVQuaternionLerp | Performs linear interpolation of two quaternions | |
| TVQuaternionLn | Calculates quaternion Ln | |
| TVQuaternionMultiply | Multiplies two quaternions | |
| TVQuaternionNormalize | Normalizes quaternion | |
| TVQuaternionRotationAxis | Creates quaternion from axis and angle | |
| TVQuaternionRotationMatrix | Creates quaternion from rotation matrix | |
| TVQuaternionRotationYawPitchRoll | Creates quaternion from Yaw, Pitch and Roll | |
| TVQuaternionSlerp | Performs spherical linear interpolation between two quaternions | |
| TVVec2Add | Adds two TV_2DVECTOR objects to each other | |
| TVVec2BaryCentric | Creates a vector in barycentric coordinates | |
| TVVec2CatmulRom | Performs Catmul-Rom interpolation | |
| TVVec2Distance | Calculates distance between two points | |
| TVVec2Dot | Calculates dot product of two vectors | |
| TVVec2Hermite | Performs hermite interpolation | |
| TVVec2Length | Calculates length of a vector | |
| TVVec2LengthSq | Calculates squared length of a vector | |
| TVVec2Lerp | Performs linear interpolation | |
| TVVec2Maximize | Finds maximum of two vectors | |
| TVVec2Minimize | Finds minimum of two vectors | |
| TVVec2Normalize | Normalizes a vector to unit length | |
| TVVec2Rotate | Rotates vetor using Yaw, Pitch and Roll angles | |
| TVVec2Scale | Scales vector | |
| TVVec2Subtract | Subtracts two vectors | |
| TVVec2Transform | Transforms vector by 3D matrix (returning 4D vector) | |
| TVVec2TransformCoord | Transforms vector by 3D matrix (returning 2D vector) | |
| TVVec2TransformNormal | Short description of TVVec2TransformNormal | |
| TVVec3Add | Calculates the sum of two given 3D vectors | |
| TVVec3BaryCentric | Creates a vector in barycentric coordinates | |
| TVVec3CatmulRom | Performs Catmul-Rom interpolation | |
| TVVec3Cross | Calculates the Cross product of two given 3D vectors | |
| TVVec3Distance | Calculates distance between two points | |
| TVVec3Dot | Calculates the Dot product of two given 3D vectors. | |
| TVVec3Hermite | Performs hermite interpolation | |
| TVVec3Length | Calculates length of a vector | |
| TVVec3LengthSq | Calculates squared length of a vector | |
| TVVec3Lerp | Performs linear interpolation | |
| TVVec3Maximize | Finds maximum of two vectors | |
| TVVec3Minimize | Finds minimum of two vectors | |
| TVVec3MultiplyAdd | Scales a vector and then performs addition | |
| TVVec3Normalize | Normalizes a vector to unit length | |
| TVVec3Rotate | Rotates vetor using Yaw, Pitch and Roll angles | |
| TVVec3Scale | Scales vector | |
| TVVec3Subtract | Subtracts two vectors | |
| TVVec3Transform | Transforms vector by 3D matrix (returning 4D vector) | |
| TVVec3TransformCoord | Transforms vector by 3D matrix (returning 3D vector) | |
| TVVec3TransformNormal | Short description of TVVec3TransformNormal | |
| TVVec4Add | Adds two TV_4DVECTOR objects to each other | |
| TVVec4BaryCentric | Creates a vector in barycentric coordinates | |
| TVVec4CatmulRom | Performs Catmul-Rom interpolation | |
| TVVec4Distance | Calculates distance between two points | |
| TVVec4Dot | Calculates dot product of two vectors | |
| TVVec4Hermite | Performs hermite interpolation | |
| TVVec4Length | Calculates length of a vector | |
| TVVec4LengthSq | Calculates squared length of a vector | |
| TVVec4Lerp | Performs linear interpolation | |
| TVVec4Maximize | Finds maximum of two vectors | |
| TVVec4Minimize | Finds minimum of two vectors | |
| TVVec4Normalize | Normalizes a vector to unit length | |
| TVVec4Rotate | Rotates vetor using Yaw, Pitch and Roll angles | |
| TVVec4Scale | Scales vector | |
| TVVec4Subtract | Subtracts two vectors | |
| TVVec4Transform | Transforms vector by 3D matrix | |
| VAdd | Adds two TV_3DVECTOR objects to each other | |
| VCompare | Compares two vector for equality (by value) | |
| VCompare2 | Compares two vector for equality (by value) with error margin | |
| VCrossProduct | Calculates cross product of two vectors | |
| VDotProduct | Calculates dot product of two vectors | |
| VLength | Calculates length of a vector | |
| VModulus | Calculates length of a vector | |
| VMultiply | Scales vector | |
| VNormalize | Normalizes a vector to unit length | |
| VScale | Scales vector | |
| VSubtract | Subtracts two vectors | |