.. index:: pair: struct; ThreeDViewer.Mathematics.Vector4 .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4: struct ThreeDViewer.Mathematics.Vector4 ======================================= .. toctree:: :hidden: Overview ~~~~~~~~ Represents a 3D position vector with homogeneous coordinates. :ref:`More...` .. ref-code-block:: C# :class: doxyrest-overview-code-block struct Vector4: IEquatable< Vector4 > { // fields static readonly int :ref:`SizeInBytes` = Unsafe.SizeOf(); static readonly Vector4 :ref:`Origin` = new(0, 0, 0, 0); static readonly Vector4 :ref:`XAxis` = new(1, 0, 0, 0); static readonly Vector4 :ref:`YAxis` = new(0, 1, 0, 0); static readonly Vector4 :ref:`ZAxis` = new(0, 0, 1, 0); static readonly Vector4 :ref:`WAxis` = new(0, 0, 0, 1); static readonly Vector4 :ref:`MinValue` = new(double.MinValue, double.MinValue, double.MinValue, double.MinValue); static readonly Vector4 :ref:`MaxValue` = new(double.MaxValue, double.MaxValue, double.MaxValue, double.MaxValue); static readonly Vector4 :ref:`Epsilon` = new(double.Epsilon, double.Epsilon, double.Epsilon, double.Epsilon); static readonly Vector4 :ref:`One` = new(1, 1, 1, 1); static readonly Vector4 :ref:`Zero` = :ref:`Origin`; static readonly Vector4 :ref:`NaN` = new(double.NaN, double.NaN, double.NaN, double.NaN); // properties double :ref:`X`; double :ref:`Y`; double :ref:`Z`; double :ref:`W`; double[] :ref:`Array`; double :ref:`Magnitude`; double :ref:`MagnitudeSquared`; Vector4 :ref:`Normalized`; double :ref:`this[int index]`; // methods :ref:`Vector4`(double x, double y, double z, double w); :ref:`Vector4`(double[] xyzw); :ref:`Vector4`(Vector4 v1); :ref:`Vector4`(:ref:`Vector3` v1); :ref:`Vector4`(:ref:`Vector3` v1, double w); double :ref:`Dot`(Vector4 other); Vector4 :ref:`SquareComponents`(); double :ref:`SumComponents`(); Vector4 :ref:`Normalize`(); :ref:`Vector3` :ref:`ToPhysicalCoords`(); PointF :ref:`ToPointF`(); bool :target:`Equals`(Vector4 other); override bool :target:`Equals`(object obj); override int :target:`GetHashCode`(); static Vector4 :target:`operator +` (Vector4 v1, Vector4 v2); static Vector4 :target:`operator -` (Vector4 v1, Vector4 v2); static Vector4 :target:`operator -` (Vector4 v1); static Vector4 :target:`operator +` (Vector4 v1); static bool :target:`operator <` (Vector4 v1, Vector4 v2); static bool :target:`operator <=` (Vector4 v1, Vector4 v2); static bool :target:`operator >` (Vector4 v1, Vector4 v2); static bool :target:`operator >=` (Vector4 v1, Vector4 v2); static bool :target:`operator ==` (Vector4 v1, Vector4 v2); static bool :target:`operator !=` (Vector4 v1, Vector4 v2); static Vector4 :target:`operator *` (Vector4 v1, double s2); static Vector4 :target:`operator *` (double s1, Vector4 v2); static Vector4 :target:`operator/` (Vector4 v1, double s2); static Vector4 :ref:`operator *` (Vector4 v1, :ref:`Matrix4` m2); }; .. _details-struct_three_d_viewer_1_1_mathematics_1_1_vector4: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Represents a 3D position vector with homogeneous coordinates. Based on this tutorial : `https://www.codeproject.com/articles/17425/a-vector-type-for-c `__. Fields ------ .. index:: pair: variable; SizeInBytes .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a5ace29ca20ad79d214f88958211e5067: .. ref-code-block:: C# :class: doxyrest-title-code-block static readonly int SizeInBytes = Unsafe.SizeOf() Size of the :ref:`Vector4 ` struct in bytes. .. index:: pair: variable; Origin .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a636bd7dbf2ae15e702a983898637ac52: .. ref-code-block:: C# :class: doxyrest-title-code-block static readonly Vector4 Origin = new(0, 0, 0, 0) An origin vector. Is equal to Vector(0, 0, 0, 0). Same as Zero. .. index:: pair: variable; XAxis .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a993e69f8ac54a7d95533eda7dc05705e: .. ref-code-block:: C# :class: doxyrest-title-code-block static readonly Vector4 XAxis = new(1, 0, 0, 0) Represents the X axis. Is equal to Vector(1, 0, 0, 0). .. index:: pair: variable; YAxis .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1aabaa91118168198542570a84f7624344: .. ref-code-block:: C# :class: doxyrest-title-code-block static readonly Vector4 YAxis = new(0, 1, 0, 0) Represents the Y axis. Is equal to Vector(0, 1, 0, 0). .. index:: pair: variable; ZAxis .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1af0208df497c82cd18fa7c620cb24cb1a: .. ref-code-block:: C# :class: doxyrest-title-code-block static readonly Vector4 ZAxis = new(0, 0, 1, 0) Represents the Z axis. Is equal to Vector(0, 0, 1, 0). .. index:: pair: variable; WAxis .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1ab92e462174c0137cc174b0b5041d08eb: .. ref-code-block:: C# :class: doxyrest-title-code-block static readonly Vector4 WAxis = new(0, 0, 0, 1) Represents the W axis. Is equal to Vector(0, 0, 0, 1). .. index:: pair: variable; MinValue .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1af12959948e2bb463a084a7d9e1925cb9: .. ref-code-block:: C# :class: doxyrest-title-code-block static readonly Vector4 MinValue = new(double.MinValue, double.MinValue, double.MinValue, double.MinValue) A vector with every components equal to double.MinValue. .. index:: pair: variable; MaxValue .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1abc8cb7a334614a94f783736af267174f: .. ref-code-block:: C# :class: doxyrest-title-code-block static readonly Vector4 MaxValue = new(double.MaxValue, double.MaxValue, double.MaxValue, double.MaxValue) A vector with every components equal to double.MaxValue. .. index:: pair: variable; Epsilon .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1aa948acdfac327440dd285b6d6e94be7c: .. ref-code-block:: C# :class: doxyrest-title-code-block static readonly Vector4 Epsilon = new(double.Epsilon, double.Epsilon, double.Epsilon, double.Epsilon) A vector with every components equal to double.Epsilon. .. index:: pair: variable; One .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1ab0c4c4abafafd8c4dcca6a8484e8ef5d: .. ref-code-block:: C# :class: doxyrest-title-code-block static readonly Vector4 One = new(1, 1, 1, 1) An instance with all components set to 1. .. index:: pair: variable; Zero .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a508e81b543b05905a0f5c6d6dd13cbd7: .. ref-code-block:: C# :class: doxyrest-title-code-block static readonly Vector4 Zero = :ref:`Origin` A zero vector. Is equal to Vector(0, 0, 0, 0). Same as Origin. .. index:: pair: variable; NaN .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a2a504eea2eef884f2542dc8bf3543318: .. ref-code-block:: C# :class: doxyrest-title-code-block static readonly Vector4 NaN = new(double.NaN, double.NaN, double.NaN, double.NaN) A vector with every components equal to double.NaN. Properties ---------- .. index:: pair: property; X .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a932210f2a8e23840382fb1baa0878f79: .. ref-code-block:: C# :class: doxyrest-title-code-block double X Gets the X component of the vector. .. index:: pair: property; Y .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a39309eabd94952199c25533f1ae0e8d4: .. ref-code-block:: C# :class: doxyrest-title-code-block double Y Gets the Y component of the vector. .. index:: pair: property; Z .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a2f32c1983fc47dca8a2057ff5a18060c: .. ref-code-block:: C# :class: doxyrest-title-code-block double Z Gets the Z component of the vector. .. index:: pair: property; W .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1afcbb8559459e42f366dec03462f830fc: .. ref-code-block:: C# :class: doxyrest-title-code-block double W Gets the W component of the vector. .. index:: pair: property; Array .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a9b64dbb808b0be139ac327409a5c9f70: .. ref-code-block:: C# :class: doxyrest-title-code-block double[] Array Gets the vector as an array. .. index:: pair: property; Magnitude .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1ab7a6c71bd83c35d4ef81e8d5b329b57a: .. ref-code-block:: C# :class: doxyrest-title-code-block double Magnitude Gets the magnitude (aka. length or absolute value) of the vector. .. index:: pair: property; MagnitudeSquared .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a7f4bcb58a4d6f6fcd9220d43d04b84cb: .. ref-code-block:: C# :class: doxyrest-title-code-block double MagnitudeSquared Gets the squared magnitude of this vector, can be used for better performance than Magnitude. .. index:: pair: property; Normalized .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a76f3c264fe3286efac87db51a217d332: .. ref-code-block:: C# :class: doxyrest-title-code-block Vector4 Normalized Gets this vector but normalized. .. index:: pair: property; this[int index] .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1ab6f760673757311cf019d4f5155b42d6: .. ref-code-block:: C# :class: doxyrest-title-code-block double this[int index] An index accessor for a vector, mapping index [0] -> X, [1] -> Y, [2] -> Z and [3] -> W. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - index - The array index referring to a component within the vector (i.e. x, y, z, w). .. rubric:: Returns: Returns X if 0, Y if 1, Z if 2 and W if 3. Methods ------- .. index:: pair: function; Vector4 .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1ad70cd02b04b425fc0381d9fb5c40a694: .. ref-code-block:: C# :class: doxyrest-title-code-block Vector4(double x, double y, double z, double w) Initializes a new instance of the :ref:`Vector4 ` struct. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - x - X component of the vector. * - y - Y component of the vector. * - z - Z component of the vector. * - w - W component of the vector. .. index:: pair: function; Vector4 .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a34209c37054c6c2f986c277633845c7e: .. ref-code-block:: C# :class: doxyrest-title-code-block Vector4(double[] xyzw) Initializes a new instance of the :ref:`Vector4 ` struct. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - xyzw - Array with the X, Y, Z and W components fo the vector. * - ArgumentException - Thrown if the array argument does not contain exactly four components. .. index:: pair: function; Vector4 .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1ab8c7ab8dafea28361a0040fff787f0db: .. ref-code-block:: C# :class: doxyrest-title-code-block Vector4(Vector4 v1) Initializes a new instance of the :ref:`Vector4 ` struct. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - v1 - :ref:`Vector4 ` representing the new values for the vector. .. index:: pair: function; Vector4 .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1ab06d31bd3d8e56229f7e5bdba876e299: .. ref-code-block:: C# :class: doxyrest-title-code-block Vector4(:ref:`Vector3` v1) Initializes a new instance of the :ref:`Vector4 ` struct. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - v1 - :ref:`Vector3 ` to create the :ref:`Vector4 ` from. .. index:: pair: function; Vector4 .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a7eea931b276c943a8ab5bba38c0b8416: .. ref-code-block:: C# :class: doxyrest-title-code-block Vector4(:ref:`Vector3` v1, double w) Initializes a new instance of the :ref:`Vector4 ` struct. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - v1 - The vector 3 that contains the X, Y and Z components of that vector. * - w - The W element of the new vector. .. index:: pair: function; Dot .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1aefcf62fc8a23ae44924cb3bda549327d: .. ref-code-block:: C# :class: doxyrest-title-code-block double Dot(Vector4 other) Determines the dot product of two vectors. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - other - The vector to multiply by. .. rubric:: Returns: Returns a scalar representing the dot product of the two vectors. .. index:: pair: function; SquareComponents .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a7ce39ec20844f7945739475f1f044324: .. ref-code-block:: C# :class: doxyrest-title-code-block Vector4 SquareComponents() Squares the vector's components. .. rubric:: Returns: The vector with his components squared. .. index:: pair: function; SumComponents .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a309d62e3eaace9ddc27ec1bd7df75c2e: .. ref-code-block:: C# :class: doxyrest-title-code-block double SumComponents() Sums the components of the vector. .. rubric:: Returns: Returns the sum of the components of the vectors. .. index:: pair: function; Normalize .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a1cd2e3423c735af7c9d87f8f064bcd5b: .. ref-code-block:: C# :class: doxyrest-title-code-block Vector4 Normalize() Normalizes the vector. .. rubric:: Returns: Returns the normalized vector. .. index:: pair: function; ToPhysicalCoords .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1ab4863acfb7b75f4f6b0f5f17419219ce: .. ref-code-block:: C# :class: doxyrest-title-code-block :ref:`Vector3` ToPhysicalCoords() Converts the :ref:`Vector4 ` to physical coords in a :ref:`Vector3 `. Divides the X, Y and Z components by W. If W = 0, it just gives the X, Y and Z components in a :ref:`Vector3 `. .. rubric:: Returns: Returns the physical coordinates of this vector. .. index:: pair: function; ToPointF .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1a9ca41ff85644af725fb839eef399da5c: .. ref-code-block:: C# :class: doxyrest-title-code-block PointF ToPointF() Converts this vector to a PointF. Firsts gets his physical coordinates, then only keeps the X and Y components. .. rubric:: Returns: A PointF containing the physical X and Y coordinates of the vector. .. index:: pair: function; operator* .. _doxid-struct_three_d_viewer_1_1_mathematics_1_1_vector4_1ab1dbad9d389c06efb1114d62f20d612b: .. ref-code-block:: C# :class: doxyrest-title-code-block static Vector4 operator * (Vector4 v1, :ref:`Matrix4` m2) Multiplies a vector with a matrix. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - v1 - The vector to multiply by the matrix. * - m2 - The matrix to multiply the vector by. .. rubric:: Returns: The vector that results from the multiplication.