DayZ 1.24
Loading...
Searching...
No Matches
EnMath3D.c
Go to the documentation of this file.
1
18proto native vector Vector(float x, float y, float z);
19
26
27class Math3D
28{
29 private void Math3D() {}
30 private void ~Math3D() {}
31
32 //-----------------------------------------------------------------
33 proto static vector ClipLine(vector start, vector end, vector norm, float d);
34
43 proto static float IntersectRaySphere(vector raybase, vector raycos, vector center, float radius);
44
53 proto static float IntersectRayBox(vector start, vector end, vector mins, vector maxs);
54
63 proto static bool IntersectSphereBox(vector origin, float radius, vector mins, vector maxs);
64
74 proto static bool IntersectSphereCone(vector origin, float radius, vector conepos, vector axis, float angle);
75
85 proto static bool IntersectWholeSphereCone(vector origin, float radius, vector conepos, vector axis, float angle);
86
97 proto static bool IntersectCylinderOBB(vector mins, vector maxs, vector obbMat[4], vector cylMat[4], float cylinderRadius, float cylinderHeight);
98
108 proto static bool IntersectRayCylinder(vector rayStart, vector rayEnd, vector center, float radius, float height);
109
122 proto static void YawPitchRollMatrix(vector ang, out vector mat[3]);
123
139 proto static void DirectionAndUpMatrix(vector dir, vector up, out vector mat[4]);
140
156 proto static void MatrixMultiply4(vector mat0[4], vector mat1[4], out vector res[4]);
157
173 proto static void MatrixMultiply3(vector mat0[3], vector mat1[3], out vector res[3]);
174
190 proto static void MatrixInvMultiply4(vector mat0[4], vector mat1[4], out vector res[4]);
191
207 proto static void MatrixInvMultiply3(vector mat0[3], vector mat1[3], out vector res[3]);
208
213 proto static void MatrixOrthogonalize4(vector mat[4]);
214
219 proto static void MatrixOrthogonalize3(vector mat[3]);
220
233 static void MatrixIdentity4(out vector mat[4])
234 {
235 mat[0] = "1 0 0";
236 mat[1] = "0 1 0";
237 mat[2] = "0 0 1";
238 mat[3] = vector.Zero;
239 }
240
252 static void MatrixIdentity3(out vector mat[3])
253 {
254 mat[0] = "1 0 0";
255 mat[1] = "0 1 0";
256 mat[2] = "0 0 1";
257 }
258
271 static void ScaleMatrix(float scale, out vector mat[3])
272 {
273 vector v0, v1, v2;
274 v0[0] = scale;
275 v1[1] = scale;
276 v2[2] = scale;
277 mat[0] = v0;
278 mat[1] = v1;
279 mat[2] = v2;
280 }
281
293 static void QuatIdentity(out float q[4])
294 {
295 q[0] = 0;
296 q[1] = 0;
297 q[2] = 0;
298 q[3] = 1;
299 }
300
314 static void QuatCopy(float s[4], out float d[4])
315 {
316 d[0] = s[0];
317 d[1] = s[1];
318 d[2] = s[2];
319 d[3] = s[3];
320 }
321
337 proto static void MatrixToQuat(vector mat[3], out float d[4]);
338
339
341 proto static void QuatToMatrix(float q[4], out vector mat[3]);
342
356 proto static vector MatrixToAngles(vector mat[3]);
357
374 proto static void QuatLerp(out float qout[4], float q1[4], float q2[4], float frac);
375
391 proto static void QuatMultiply(out float qout[4], float q1[4], float q2[4]);
392
394 proto static vector QuatToAngles(float q[4]);
395
413 proto static int CheckBoundBox(vector mins1, vector maxs1, vector mins2, vector maxs2);
414
425 {
426 float x = Math.RandomFloatInclusive(-1, 1);
427 float y = Math.RandomFloatInclusive(-1, 1);
428 float z = Math.RandomFloatInclusive(-1, 1);
429
430 return Vector(x, y, z).Normalized();
431 }
432
433
448 proto static native vector Curve(ECurveType type, float param, notnull array<vector> points);
449
450
455 proto static vector NearestPoint(vector beg, vector end, vector pos);
456
461 proto static float AngleFromPosition(vector origin, vector originDir, vector target);
462
472 proto static void ConePoints(vector origin, float length, float halfAngle, float angleOffset, out vector leftPoint, out vector rightPoint);
473};
474//@}
Icon x
Icon y
Definition EnMath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto vector Normalized()
return normalized vector (keeps orginal vector untouched)
static const vector Zero
Definition EnConvert.c:110
ECurveType
Definition EnMath3D.c:21
static void QuatIdentity(out float q[4])
Creates identity quaternion.
Definition EnMath3D.c:293
static proto void QuatToMatrix(float q[4], out vector mat[3])
Converts quaternion to rotation matrix.
static proto vector MatrixToAngles(vector mat[3])
Returns angles of rotation matrix.
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)
static proto void MatrixOrthogonalize3(vector mat[3])
Orthogonalizes matrix.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static void QuatCopy(float s[4], out float d[4])
Copies quaternion.
Definition EnMath3D.c:314
static proto float AngleFromPosition(vector origin, vector originDir, vector target)
Angle that a target is from the direction of an origin.
static proto int CheckBoundBox(vector mins1, vector maxs1, vector mins2, vector maxs2)
Returns 1, when bounding boxes intersects.
void Math3D()
Definition EnMath3D.c:29
static proto void MatrixMultiply4(vector mat0[4], vector mat1[4], out vector res[4])
Transforms matrix.
void ~Math3D()
Definition EnMath3D.c:30
static proto vector ClipLine(vector start, vector end, vector norm, float d)
static proto void MatrixToQuat(vector mat[3], out float d[4])
Converts rotation matrix to quaternion.
static proto void YawPitchRollMatrix(vector ang, out vector mat[3])
Creates rotation matrix from angles.
static proto bool IntersectSphereCone(vector origin, float radius, vector conepos, vector axis, float angle)
Tests whether sphere is intersecting cone.
static proto void QuatMultiply(out float qout[4], float q1[4], float q2[4])
Multiplies quaternions.
static proto vector NearestPoint(vector beg, vector end, vector pos)
Point on line beg .. end nearest to pos.
static proto 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.
static proto bool IntersectRayCylinder(vector rayStart, vector rayEnd, vector center, float radius, float height)
Tests whether ray is intersecting cylinder.
static proto bool IntersectCylinderOBB(vector mins, vector maxs, vector obbMat[4], vector cylMat[4], float cylinderRadius, float cylinderHeight)
Tests whether cylinder is intersecting oriented box.
static proto bool IntersectSphereBox(vector origin, float radius, vector mins, vector maxs)
Tests whether sphere is intersecting axis aligned box.
static proto vector QuatToAngles(float q[4])
Returns Angles vector from quaternion.
static proto float IntersectRaySphere(vector raybase, vector raycos, vector center, float radius)
Tests whether ray is intersecting sphere.
static proto void MatrixMultiply3(vector mat0[3], vector mat1[3], out vector res[3])
Transforms rotation matrix.
static void ScaleMatrix(float scale, out vector mat[3])
Creates scale matrix.
Definition EnMath3D.c:271
static proto void MatrixInvMultiply4(vector mat0[4], vector mat1[4], out vector res[4])
Invert-transforms matrix.
static proto void MatrixInvMultiply3(vector mat0[3], vector mat1[3], out vector res[3])
Invert-transforms rotation matrix.
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.
Definition EnMath3D.c:233
static proto void DirectionAndUpMatrix(vector dir, vector up, out vector mat[4])
Creates rotation matrix from direction and up vector.
static proto void MatrixOrthogonalize4(vector mat[4])
Orthogonalizes matrix.
static proto float IntersectRayBox(vector start, vector end, vector mins, vector maxs)
Tests whether ray is intersecting axis aligned box.
static vector GetRandomDir()
Returns randon normalized direction.
Definition EnMath3D.c:424
static proto native vector Curve(ECurveType type, float param, notnull array< vector > points)
Computes curve.
static void MatrixIdentity3(out vector mat[3])
Creates identity matrix.
Definition EnMath3D.c:252
static proto bool IntersectWholeSphereCone(vector origin, float radius, vector conepos, vector axis, float angle)
Tests whether sphere is fully inside cone.
@ NaturalCubic
Definition EnMath3D.c:23
@ CatmullRom
Definition EnMath3D.c:22
@ UniformCubic
Definition EnMath3D.c:24
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Definition EnMath.c:106