Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreatePerspectiveFieldOfView()

static Matrix4x4 System.Numerics.Matrix4x4.CreatePerspectiveFieldOfView ( float fieldOfView,
float aspectRatio,
float nearPlaneDistance,
float farPlaneDistance )
inlinestatic

Definition at line 548 of file Matrix4x4.cs.

549 {
550 if (fieldOfView <= 0f || fieldOfView >= (float)Math.PI)
551 {
552 throw new ArgumentOutOfRangeException("fieldOfView");
553 }
554 if (nearPlaneDistance <= 0f)
555 {
556 throw new ArgumentOutOfRangeException("nearPlaneDistance");
557 }
558 if (farPlaneDistance <= 0f)
559 {
560 throw new ArgumentOutOfRangeException("farPlaneDistance");
561 }
562 if (nearPlaneDistance >= farPlaneDistance)
563 {
564 throw new ArgumentOutOfRangeException("nearPlaneDistance");
565 }
566 float num = 1f / MathF.Tan(fieldOfView * 0.5f);
567 float m = num / aspectRatio;
568 System.Runtime.CompilerServices.Unsafe.SkipInit(out Matrix4x4 result);
569 result.M11 = m;
570 result.M12 = (result.M13 = (result.M14 = 0f));
571 result.M22 = num;
572 result.M21 = (result.M23 = (result.M24 = 0f));
573 result.M31 = (result.M32 = 0f);
574 float num2 = (result.M33 = (float.IsPositiveInfinity(farPlaneDistance) ? (-1f) : (farPlaneDistance / (nearPlaneDistance - farPlaneDistance))));
575 result.M34 = -1f;
576 result.M41 = (result.M42 = (result.M44 = 0f));
577 result.M43 = nearPlaneDistance * num2;
578 return result;
579 }
Matrix4x4(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)
Definition Matrix4x4.cs:93

References System.Math.PI, and System.MathF.Tan().