class Math3DSource
Part of Math3D library
Constructors 2
private void Math3D()private void ~Math3D()Methods 39
Tests whether ray is intersecting sphere.
raybasevectorStart of rayraycosvectorEnd of raycentervectorCenter of sphereradiusfloatRadius of sphere
Returns: float -1 when not intersecting, else the fraction of ray
Tests whether ray is intersecting axis aligned box.
startvectorStart of rayendvectorEnd of rayminsvectorMinimums of bound boxmaxsvectorMaximums of bound box
Returns: float -1 when not intersecting, else the fraction of ray
Tests whether sphere is intersecting axis aligned box.
originvectorOrigin of sphereradiusfloatRadius of sphereminsvectorMinimums of bound boxmaxsvectorMaximums of bound box
Returns: bool True when intersects
proto static bool IntersectSphereCone(vector origin, float radius, vector conepos, vector axis, float angle)Tests whether sphere is intersecting cone.
originvectorOrigin of sphereradiusfloatRadius of sphereconeposvectorPosition of top of coneaxisvectorOrientation of cone in direction from top to bottomanglefloatAngle of cone in radians
Returns: bool True when sphere is intersecting cone
proto static bool IntersectWholeSphereCone(vector origin, float radius, vector conepos, vector axis, float angle)Tests whether sphere is fully inside cone.
originvectorOrigin of sphereradiusfloatRadius of sphereconeposvectorPosition of top of coneaxisvectorOrientation of cone in direction from top to bottomanglefloatAngle of cone in radians
Returns: bool True when sphere is fully inside cone
proto static bool IntersectCylinderOBB(vector mins, vector maxs, vector obbMat[4], vector cylMat[4], float cylinderRadius, float cylinderHeight)Tests whether cylinder is intersecting oriented box.
minsvectorMinimums of bound boxmaxsvectorMaximums of bound boxobbMatvectorTransform of boxcylMatvectorTransform of cylindercylinderRadiusfloatRadius of cylindercylinderHeightfloatHeight of cylinder
Returns: bool True when cylinder is intersecting oriented box
proto static bool IntersectRayCylinder(vector rayStart, vector rayEnd, vector center, float radius, float height)Tests whether ray is intersecting cylinder.
rayStartvectorStart of rayrayEndvectorEnd of raycentervectorCenter of cylinderradiusfloatRadius of cylinderheightfloatHeight of cylinder
Returns: bool True when ray is intersecting cylinder
proto static int IntersectRayPlane(vector rayStart, vector rayEnd, vector planeNormal, float planeDist, out vector intersection)Tests whether ray is intersecting plane.
rayStartvectorStart of rayrayEndvectorEnd of rayplaneNormalvectorNormal of the planeplaneDistfloatLength of the planeintersectionvectorIntersection point of the plane, only valid when return is 3
Returns: int 1 when behind, 2 when in front and 3 when intersecting the plane
Creates rotation matrix from angles
angvectorwhich contains angles- out
mat vectorcreated rotation matrix
vector mat[3];
YawPitchRollMatrix( "70 15 45", mat );
Print( mat );
>> <0.330366,0.0885213,-0.939693>,<0.458809,0.854988,0.241845>,<0.824835,-0.511037,0.241845>Show 15 more
, DayZPlayerCamera1stPerson.OnUpdate(), DayZPlayerCamera1stPersonUnconscious.OnUpdate(), DayZPlayerCamera3rdPerson.OnUpdate(), DayZPlayerCamera3rdPersonProneBase.OnUpdate(), DayZPlayerCamera3rdPersonVehicle.OnUpdate(), DayZPlayerCameraIronsights.OnUpdate(), Hologram.AlignProjectionOnTerrain(), MiscGameplayFunctions.ThrowAllItemsInInventory(), PlayerBase.AddArrow(), PRAShapeBoxData.InitPRAShapeData(), ScriptCamera.FreeFly(), TrapSpawnBase.OnPlacementComplete(), Weapon_Base.ApproximateWeaponLiftTransform(), WeaponLiftDiag.DrawDiag(), and ZombieBase.AddArrow()Creates rotation matrix from direction and up vector
dirvectordirection vectorupvectorup vector- out
mat vector[4]created rotation matrix
vector mat[4];
vector dir = "1 0 1";
vector up = "0 1 0";
DirectionAndUpMatrix( dir, up, mat );
Print( mat );
>> <0.707107,0,-0.707107>,<0,1,0>,<0.707107,0,0.707107>,<0,0,0>Transforms matrix
mat0vector[4]first matrixmat1vector[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>Show 1 more
, Transport.IsAreaAtDoorFree()Transforms rotation matrix
mat0vector[3]first matrixmat1vector[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>Invert-transforms matrix
mat0vector[4]first matrixmat1vector[4]second matrix- out
res vector[4]inverse result of first and second matrix multiplication
vector mat0[4] = { "2 0 0", "0 3 0", "0 0 1", "0 0 0" }; // scale matrix
vector mat1[4] = { "1 0 0", "0 1 0", "0 0 1", "2 4 1" }; // translation matrix
vector res[4];
Math3D.MatrixInvMultiply4(mat0, mat1, res)
Print( res );
>> <2,0,0>,<0,3,1>,<0,3,1>,<4,12,4>Show 1 more
, ZombieBase.AddArrow()Invert-transforms rotation matrix
mat0vector[3]first matrixmat1vector[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.MatrixInvMultiply3(mat0, mat1, res)
Print( res );
>> <2.5,0.62,0>,<2.5,1.3,0>,<3.25,1.69,2.7>proto static void MatrixInverse4(vector mat[4])Inverses a matrix
- it
mat matrixwhich should be inversed
proto static void MatrixInverse3(vector mat[3])Inverses a matrix
- it
mat matrixwhich should be inversed
proto static void MatrixOrthogonalize4(vector mat[4])Orthogonalizes matrix
- it
mat matrixwhich should be orthogonalized
Show 1 more
, ZombieBase.AddArrow()proto static void MatrixOrthogonalize3(vector mat[3])Orthogonalizes matrix
- it
mat matrixwhich should be orthogonalized
static void MatrixIdentity4(out vector mat[4])Creates identity matrix
- out
mat createdidentity matrix
vector mat[4];
Math3D.MatrixIdentity4( mat );
Print( mat );
>> <1,0,0>,<0,1,0>,<0,0,1>,<0,0,0>Show 16 more
, CfgPlayerRestrictedAreaHandler.IsCylinderInAreaBox(), ContaminatedArea_Dynamic.SpawnItems(), DayZIntroScene.DayZIntroScene(), DayZPlayerUtils.HandleDropMagazine(), DropEquipAndDestroyRootLambda.CopyOldPropertiesToNew(), EntityAI.SpawnEntityOnGroundPos(), FireplaceToIndoorOvenLambda.FireplaceToIndoorOvenLambda(), FireplaceToIndoorsLambda.FireplaceToIndoorsLambda(), GameInventory.SetGroundPosByOwner(), MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(), PlayerBase.PredictiveDropEntity(), PlayerBase.SpawnEntityOnGroundPos(), PluginCharPlacement.CalculatePos(), PluginDeveloper.SpawnEntityOnGroundPos(), ReplaceItemWithNewLambdaBase.PrepareLocations(), and WeaponLiftDiagData.Clear()static void MatrixIdentity3(out vector mat[3])Creates identity matrix
- out
mat createdidentity matrix
vector mat[3];
Math3D.MatrixIdentity3( mat );
Print( mat );
>> <1,0,0>,<0,1,0>,<0,0,1>Creates scale matrix
scalescalecoeficient- out
mat createdscale matrix
vector mat[3];
Math3D.ScaleMatrix( 2.5, mat );
Print( mat );
>> <2.5,0,0>,<0,2.5,0>,<0,0,2.5>static void QuatIdentity(out float q[4])Creates identity quaternion
- out
q float[4]created identity quaternion
float q[4];
Math3D.QuatIdentity( q );
Print( q );
>> {0,0,0,1}Copies quaternion
sfloat[4]quaternion to copy- out
d float[4]created quaternion copy
float s[4] = { 2, 3, 4, 1 };
float d[4];
Math3D.QuatCopy( s, d );
Print( d );
>> {2,3,4,1}Converts rotation matrix to quaternion
matvector[3]rotation matrix- out
d float[4]created quaternion copy
vector mat[3];
vector rot = "70 15 45";
rot.RotationMatrixFromAngles( mat );
float d[4];
Math3D.MatrixToQuat( mat, d );
Print( d );
>> {0.241626,0.566299,-0.118838,0.778973}Converts quaternion to rotation matrix
Returns angles of rotation matrix
matvector[3]rotation matrix
Returns: vector roll, pitch, yaw angles
vector mat[3];
Math3D.RollPitchYawMatrix( "70 15 45", mat );
vector ang = Math3D.MatrixToAngles( mat );
Print( ang );
>> <70,15,-45>Linear interpolation between q1 and q2 with weight 'frac' (0...1)
- out
qout float[4]result quaternionq1float[4]first quaternionq2float[4]second quaternionfracfloatinterpolation weight
float q1[4] = { 1, 1, 1, 1 };
float q2[4] = { 2, 2, 2, 1 };
float qout[4];
Math3D.QuatLerp( qout, q1, q2, 0.5 );
Print( qout );
>> {1.5,1.5,1.5,1}Multiplies quaternions
- out
qout float[4]result quaternionq1float[4]first quaternionq2float[4]second quaternion
float q1[4] = { 1, 2, 3, 1 };
float q2[4] = { 2, 2, 2, 1 };
float qout[4];
Math3D.QuatMultiply( qout, q1, q2 );
Print( qout );
>> {2,4,6,1}Returns Angles vector from quaternion
Returns 1, when bounding boxes intersects
mins1vectorminimum point of first bounding boxmaxs1vectormaximum point of first bounding boxmins2vectorminimum point of second bounding boxmaxs2vectormaximum 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( Math3D.CheckBoundBox(mins1, maxs1, mins2, maxs2) );
>> 1static vector GetRandomDir()Returns randon normalized direction
Returns: vector
Print( Math3D.GetRandomDir() );
>>vector ret = 0x0000000007c1a1c0 {<0.422565,0,-0.906333>}proto static native vector Curve(ECurveType type, float param, notnull array<vector> points)Computes curve
Returns: vector
auto points = new array<vector>();
points.Insert( Vector( 0, 0, 0) );
points.Insert( Vector( 5, 0, 0) );
points.Insert( Vector( 8, 3, 0) );
points.Insert( Vector( 6, 1, 0) );
float t = 0.5;
vector result = Math3D.Curve(ECurveType.CatmullRom, t, points);Point on line beg .. end nearest to pos
Returns: vector
Angle that a target is from the direction of an origin
Returns: float Angle in radians
proto static void ConePoints(vector origin, float length, float halfAngle, float angleOffset, out vector leftPoint, out vector rightPoint)Calculates the points of a right 2D cone in 3D space
originvectorOrigin of conelengthfloatLength of the conehalfAnglefloatHalf of the angle of the cone in radiansangleOffsetfloatAngle offset of the cone in radians (handy for rotating it along with something in the world)- out
leftPoint vectorLeft point of the cone- out
rightPoint vectorRight point of the cone
proto static void BlendCartesian(vector samplePosition, notnull array<vector> inPositions, notnull array<float> outWeights)Output 2D blend space weights for `inPositions` when sampled at `samplePosition`
samplePosition- [X, Y, unused] coordinate to sample the 2d space
inPositions- [X, Y, unused] positions in the 2d space
outWeights- Output weights for individual nodes 1:1 to inPositions