DayZ Enforce
Script API
Static Private Member Functions | Static Private Attributes | List of all members
EnMath3D Class Reference

#include <EnMath3D.h>

Static Private Member Functions

static float  DiffAngle (float yaw, float a)
  Return relative difference between angles. More...
 
static vector  GetRelAngles (vector angs)
  Returns relative angles between -180 and 180, not 0 to 360. More...
 
static proto float  VectorNormalize (inout vector vec)
  Normalizes vector. Returns length. More...
 
static proto float  VectorLength (vector vec)
  Returns length of vector (magnitude) More...
 
static float  VectorDistance (vector v1, vector v2)
  Returns the distance between tips of two 3D vectors. More...
 
static proto float  VectorLength2 (vector vec)
  Returns squared length (magnitudeSqr) More...
 
static proto vector  VectorToAngles (vector vec)
  Returns angles of vector. More...
 
static proto float  VectorToYaw (vector vec)
  Returns yaw of vector. More...
 
static proto vector  YawToVector (float yaw)
  Returns vector of yaw. More...
 
static proto vector  VectorToSphere (vector vec)
  Converts vector to spherical coordinates with radius = 1. More...
 
static proto vector  SphereToVector (vector ang)
  Converts spherical coordinates to unit length vector. More...
 
static proto void  RotationMatrixFromAngles (vector ang, out vector mat[3])
  Creates rotation matrix from angles. More...
 
static proto void  RotationMatrixFromDirUp (vector dir, vector up, out vector mat[4])
  Creates rotation matrix from direction and up vector. More...
 
static proto vector  VectorMatrixMultiply4 (vector mat[4], vector vec)
  Transforms position. More...
 
static proto vector  VectorMatrixMultiply3 (vector mat[3], vector vec)
  Transforms vector. More...
 
static proto vector  VectorMatrixInvMultiply4 (vector mat[4], vector vec)
  Invert-transforms position. More...
 
static proto vector  VectorMatrixInvMultiply3 (vector mat[3], vector vec)
  Invert-transforms vector. More...
 
static proto void  MatrixMultiply4 (vector mat0[4], vector mat1[4], out vector res[4])
  Transforms matrix. More...
 
static proto void  MatrixMultiply3 (vector mat0[3], vector mat1[3], out vector res[3])
  Transforms rotation matrix. More...
 
static proto void  MatrixInvMultiply4 (vector mat0[4], vector mat1[4], out vector res[4])
  Invert-transforms matrix. More...
 
static proto void  MatrixInvMultiply3 (vector mat0[3], vector mat1[3], out vector res[3])
  Invert-transforms rotation matrix. More...
 
static void  MatrixIdentity4 (out vector mat[4])
  Creates identity matrix. More...
 
static void  MatrixIdentity3 (out vector mat[3])
  Creates identity matrix. More...
 
static void  ScaleMatrix (float scale, out vector mat[3])
  Creates scale matrix. More...
 
static void  QuatIdentity (out float q[4])
  Creates identity quaternion. More...
 
static void  QuatCopy (float s[4], out float d[4])
  Copies quaternion. More...
 
static proto void  MatrixQuat (vector mat[3], out float d[4])
  Converts rotation matrix to quaternion. More...
 
static proto void  QuatLerp (out float qout[4], float q1[4], float q2[4], float frac)
  Linear interpolation between q1 and q2 with weight 'frac' (0...1) More...
 
static proto void  QuatMultiply (out float qout[4], float q1[4], float q2[4])
  Multiplies quaternions. More...
 
static int  CheckBoundBox (vector mins1, vector maxs1, vector mins2, vector maxs2)
  Returns 1, when bounding boxes intersects. More...
 
static vector  Perpend (vector vec)
  Returns perpendicular vector. Perpendicular vector is computed as cross product between input vector and up vector (0, 1, 0). More...
 
static vector  DirectionVector (vector p1, vector p2)
  Returns direction vector from point p1 to point p2. More...
 
static float  DotProduct (vector v1, vector v2)
  Returns Dot product of vector v1 and vector v2. More...
 

Static Private Attributes

static const vector  UpVec = "0 1 0"
 
static const vector  ZeroVec = "0 0 0"
 
static const float  M_PI = 3.14159265358979
 
static const float  M_PI2 = 6.28318530717958
 
static const float  M_PI_HALF = 1.570796326794
 
static const float  RAD2DEG = 57.2957795130823208768
 
static const float  DEG2RAD = 0.01745329251994329577
 

Member Function Documentation

static float EnMath3D::DiffAngle ( float  yaw,
float  a 
)
staticprivate

Return relative difference between angles.

Parameters
yaw float Angle1
a float Angle2
Returns
float Difference between angles (Angle1 - Angle2)
Print( EnMath3D.DiffAngle(-45, 45) );
>> -90
>> 10

References fabs(), and FixAngle().

static vector EnMath3D::GetRelAngles ( vector  angs )
staticprivate

Returns relative angles between -180 and 180, not 0 to 360.

Parameters
angs float Angle1
Returns
float Relative angles
vector angles = "-45 190 160";
>> <-45,-170,160>
static proto float EnMath3D::VectorNormalize ( inout vector  vec )
staticprivate

Normalizes vector. Returns length.

Parameters
[in,out] vec vector Vector to normalizing
Returns
float Length of origin vector
vector vec = "1 0 1";
float length = EnMath3D.VectorNormalize( vec );
Print( vec );
Print( length );
>> vec = <0.707107,0,0.707107>
>> length = 1.41421

Referenced by EN5C_FireplaceBase::IsFacingFireplace(), and PlayerBase::IsFacingTarget().

static proto float EnMath3D::VectorLength ( vector  vec )
staticprivate

Returns length of vector (magnitude)

Parameters
vec vector Vector to calculate length
Returns
float Length of vector
vector vec = "1 0 1";
float length = EnMath3D.VectorLength( vec );
Print( length );
>> length = 1.41421

Referenced by EN5C_FireplaceBase::IsFacingFireplace(), and VectorDistance().

static float EnMath3D::VectorDistance ( vector  v1,
vector  v2 
)
staticprivate
static proto float EnMath3D::VectorLength2 ( vector  vec )
staticprivate

Returns squared length (magnitudeSqr)

Parameters
vec vector Vector to calculate length
Returns
float Length of vector
vector vec = "1 1 0";
float length = EnMath3D.VectorLength2(vec);
Print( length );
>> length = 2
static proto vector EnMath3D::VectorToAngles ( vector  vec )
staticprivate

Returns angles of vector.

Parameters
vec vector Vector to convert angles
Returns
vector Angles of vector
Print( EnMath3D.VectorToAngles("0.7 0.7 0") );
>> <-0,90,0>
>> <-0,45,0>
static proto float EnMath3D::VectorToYaw ( vector  vec )
staticprivate

Returns yaw of vector.

Parameters
vec vector Vector to convert yaw
Returns
float Yaw of vector
Print( EnMath3D.VectorToYaw("0.7 0.7 0") );
>> 90
>> 45
static proto vector EnMath3D::YawToVector ( float  yaw )
staticprivate

Returns vector of yaw.

Parameters
yaw float Value of yaw
Returns
vector Yaw converted in vector
>> <0,1,0>
>> <0.707107,0.707107,0>
static proto vector EnMath3D::VectorToSphere ( vector  vec )
staticprivate

Converts vector to spherical coordinates with radius = 1.

Parameters
vec vector which will be converted to spherical coordinates
Returns
vector containing polar angle as x component and azimuthal angle as y component
>> <45,0,360>
>> <35.2644,0,324.736>
static proto vector EnMath3D::SphereToVector ( vector  ang )
staticprivate

Converts spherical coordinates to unit length vector.

Parameters
ang vector which contains spherical coordinates - x component is polar angle and y component is azimuthal angle
Returns
vector containing polar angle as x component and azimuthal angle as y component
>> <0.707107,0,0.707107>
>> <0.482963,0.836516,0.258819>
static proto void EnMath3D::RotationMatrixFromAngles ( vector  ang,
out vector  mat[3] 
)
staticprivate

Creates rotation matrix from angles.

Parameters
ang vector which contains angles
[out] mat vector created rotation matrix
vector mat[3];
Print( mat );
>> <0.330366,0.0885213,-0.939693>,<0.458809,0.854988,0.241845>,<0.824835,-0.511037,0.241845>
static proto void EnMath3D::RotationMatrixFromDirUp ( vector  dir,
vector  up,
out vector  mat[4] 
)
staticprivate

Creates rotation matrix from direction and up vector.

Parameters
dir vector direction vector
up vector up vector
[out] mat vector[4] created rotation matrix
vector mat[4];
vector dir = "1 0 1";
vector up = "0 1 0";
Print( mat );
>> <0.707107,0,-0.707107>,<0,1,0>,<0.707107,0,0.707107>,<0,0,0>
static proto vector EnMath3D::VectorMatrixMultiply4 ( vector  mat[4],
vector  vec 
)
staticprivate

Transforms position.

Parameters
mat vector[4] transformation matrix
vec vector position to transform
Returns
vector transformed position
vector mat[4] = { "1 0 0 0", "0 1 0 0", "0 0 1 1", "3 1 2 1" }; // translation matrix
vector pos = "1 1 1";
>> <4,2,3>
static proto vector EnMath3D::VectorMatrixMultiply3 ( vector  mat[3],
vector  vec 
)
staticprivate

Transforms vector.

Parameters
mat vector[3] transformation matrix
vec vector vector to transform
Returns
vector transformed vector
vector mat[3] = { "2 0 0", "0 3 0", "0 0 1" }; // scale matrix
vector vec = "1 1 1";
>> <2,3,1>
static proto vector EnMath3D::VectorMatrixInvMultiply4 ( vector  mat[4],
vector  vec 
)
staticprivate

Invert-transforms position.

Parameters
mat vector[4] transformation matrix
vec vector position to transform
Returns
vector transformed position
vector mat[4] = { "1 0 0 0", "0 1 0 0", "0 0 1 1", "3 1 2 1" }; // translation matrix
vector pos = "1 1 1";
Print( Math3D.VectorMatrixInvMultiply4(mat, pos) );
>> <-2,0,-1>
static proto vector EnMath3D::VectorMatrixInvMultiply3 ( vector  mat[3],
vector  vec 
)
staticprivate

Invert-transforms vector.

Parameters
mat vector[3] transformation matrix
vec vector vector to transform
Returns
vector transformed vector
vector mat[3] = { "1.5 2.5 0", "0.1 1.3 0", "0 0 1" }; // rotation matrix
vector vec = "1 1 1";
Print( Math3D.VectorMatrixInvMultiply3(mat, vec) );
>> <4,1.4,1>
static proto void EnMath3D::MatrixMultiply4 ( vector  mat0[4],
vector  mat1[4],
out vector  res[4] 
)
staticprivate

Transforms matrix.

Parameters
mat0 vector[4] first matrix
mat1 vector[4] second matrix
[out] res vector[4] result of first and second matrix multiplication
vector mat0[4] = { "2 0 0 0", "0 3 0 0", "0 1 0 0", "0 0 0 1" }; // scale matrix
vector mat1[4] = { "1 0 0 0", "0 1 0 0", "0 1 0 0", "2 4 1 3" }; // translation matrix
vector res[4];
Math3D.MatrixMultiply4(mat0, mat1, res)
Print( res );
>> <2,0,0>,<0,3,0>,<0,3,0>,<4,13,0>
static proto void EnMath3D::MatrixMultiply3 ( vector  mat0[3],
vector  mat1[3],
out vector  res[3] 
)
staticprivate

Transforms rotation matrix.

Parameters
mat0 vector[3] first matrix
mat1 vector[3] second matrix
[out] res vector[3] result of first and second matrix multiplication
vector mat0[3] = { "1.5 2.5 0", "0.1 1.3 0", "0 0 1" }; // rotation matrix
vector mat1[3] = { "1 0.4 0", "0 1 0", "0 1.3 2.7" }; // rotation matrix
vector res[3];
Math3D.MatrixMultiply3(mat0, mat1, res)
Print( res );
>> <1.54,3.02,0>,<0.1,1.3,0>,<0.13,1.69,2.7>
static proto void EnMath3D::MatrixInvMultiply4 ( vector  mat0[4],
vector  mat1[4],
out vector  res[4] 
)
staticprivate

Invert-transforms matrix.

Parameters
mat0 vector[4] first matrix
mat1 vector[4] second matrix
[out] res vector[4] inverse result of first and second matrix multiplication
vector mat0[4] = { "2 0 0 0", "0 3 0 0", "0 1 0 0", "0 0 0 1" }; // scale matrix
vector mat1[4] = { "1 0 0 0", "0 1 0 0", "0 1 0 0", "2 4 1 3" }; // translation matrix
vector res[4];
EnMath3D.MatrixInvMultiply4(mat0, mat1, res)
Print( res );
>> <2,0,0>,<0,3,1>,<0,3,1>,<4,12,4>
static proto void EnMath3D::MatrixInvMultiply3 ( vector  mat0[3],
vector  mat1[3],
out vector  res[3] 
)
staticprivate

Invert-transforms rotation matrix.

Parameters
mat0 vector[3] first matrix
mat1 vector[3] second matrix
[out] res vector[3] result of first and second matrix multiplication
vector mat0[3] = { "1.5 2.5 0", "0.1 1.3 0", "0 0 1" }; // rotation matrix
vector mat1[3] = { "1 0.4 0", "0 1 0", "0 1.3 2.7" }; // rotation matrix
vector res[3];
EnMath3D.MatrixInvMultiply3(mat0, mat1, res)
Print( res );
>> <2.5,0.62,0>,<2.5,1.3,0>,<3.25,1.69,2.7>
static void EnMath3D::MatrixIdentity4 ( out vector  mat[4] )
staticprivate

Creates identity matrix.

Parameters
[out] mat created identity matrix
vector mat[4];
Print( mat );
>> <1,0,0>,<0,1,0>,<0,0,1>,<0,0,0>

References ZeroVec.

static void EnMath3D::MatrixIdentity3 ( out vector  mat[3] )
staticprivate

Creates identity matrix.

Parameters
[out] mat created identity matrix
vector mat[3];
Print( mat );
>> <1,0,0>,<0,1,0>,<0,0,1>
static void EnMath3D::ScaleMatrix ( float  scale,
out vector  mat[3] 
)
staticprivate

Creates scale matrix.

Parameters
scale scale coeficient
[out] mat created scale matrix
vector mat[3];
EnMath3D.ScaleMatrix( 2.5, mat );
Print( mat );
>> <2.5,0,0>,<0,2.5,0>,<0,0,2.5>
static void EnMath3D::QuatIdentity ( out float  q[4] )
staticprivate

Creates identity quaternion.

Parameters
[out] q float[4] created identity quaternion
float q[4];
Print( q );
>> {0,0,0,1}
static void EnMath3D::QuatCopy ( float  s[4],
out float  d[4] 
)
staticprivate

Copies quaternion.

Parameters
s float[4] quaternion to copy
[out] d float[4] created quaternion copy
float s[4] = { 2, 3, 4, 1 };
float d[4];
Print( d );
>> {2,3,4,1}
static proto void EnMath3D::MatrixQuat ( vector  mat[3],
out float  d[4] 
)
staticprivate

Converts rotation matrix to quaternion.

Parameters
mat vector[3] rotation matrix
[out] d float[4] created quaternion copy
vector mat[3];
float d[4];
EnMath3D.MatrixQuat( mat, d );
Print( d );
>> {0.241626,0.566299,-0.118838,0.778973}
static proto void EnMath3D::QuatLerp ( out float  qout[4],
float  q1[4],
float  q2[4],
float  frac 
)
staticprivate

Linear interpolation between q1 and q2 with weight 'frac' (0...1)

Parameters
[out] qout float[4] result quaternion
q1 float[4] first quaternion
q2 float[4] second quaternion
frac float interpolation weight
float q1[4] = { 1, 1, 1, 1 };
float q2[4] = { 2, 2, 2, 1 };
float qout[4];
EnMath3D.QuatLerp( qout, q1, q2, 0.5 );
Print( qout );
>> {1.5,1.5,1.5,1}
static proto void EnMath3D::QuatMultiply ( out float  qout[4],
float  q1[4],
float  q2[4] 
)
staticprivate

Multiplies quaternions.

Parameters
[out] qout float[4] result quaternion
q1 float[4] first quaternion
q2 float[4] second quaternion
float q1[4] = { 1, 2, 3, 1 };
float q2[4] = { 2, 2, 2, 1 };
float qout[4];
EnMath3D.QuatMultiply( qout, q1, q2 );
Print( qout );
>> {2,4,6,1}
static int EnMath3D::CheckBoundBox ( vector  mins1,
vector  maxs1,
vector  mins2,
vector  maxs2 
)
staticprivate

Returns 1, when bounding boxes intersects.

Parameters
mins1 vector minimum point of first bounding box
maxs1 vector maximum point of first bounding box
mins2 vector minimum point of second bounding box
maxs2 vector maximum point of second bounding box
Returns
int 1 if boundig boxes intersects, otherwise 0
vector mins1 = "1 1 1";
vector maxs1 = "3 3 3";
vector mins2 = "2 2 2";
vector maxs2 = "4 4 4";
Print( EnMath3D.CheckBoundBox(mins1, maxs1, mins2, maxs2) );
>> 1
static vector EnMath3D::Perpend ( vector  vec )
staticprivate

Returns perpendicular vector. Perpendicular vector is computed as cross product between input vector and up vector (0, 1, 0).

Parameters
vec vector input vector
Returns
vector perpendicular vector
Print( EnMath3D.Perpend("1 0 0") );
>> <0,0,1>

References UpVec.

Referenced by Trap_RabbitSnare::AlignCatch().

static vector EnMath3D::DirectionVector ( vector  p1,
vector  p2 
)
staticprivate

Returns direction vector from point p1 to point p2.

Parameters
p1 vector point from
p2 vector point to
Returns
vector direction vector

Referenced by EN5C_FireplaceBase::IsFacingFireplace().

static float EnMath3D::DotProduct ( vector  v1,
vector  v2 
)
staticprivate

Returns Dot product of vector v1 and vector v2.

Parameters
v1 vector input vector
v2 vector input vector
Returns
vector direction vector

Referenced by EN5C_FireplaceBase::IsFacingFireplace().

Member Data Documentation

const vector EnMath3D::UpVec = "0 1 0"
staticprivate

Referenced by Perpend().

const vector EnMath3D::ZeroVec = "0 0 0"
staticprivate

Referenced by MatrixIdentity4().

const float EnMath3D::M_PI = 3.14159265358979
staticprivate
const float EnMath3D::M_PI2 = 6.28318530717958
staticprivate
const float EnMath3D::M_PI_HALF = 1.570796326794
staticprivate
const float EnMath3D::RAD2DEG = 57.2957795130823208768
staticprivate
const float EnMath3D::DEG2RAD = 0.01745329251994329577
staticprivate

The documentation for this class was generated from the following file:
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)