A Matrix in StereoKit is a 4x4 grid of numbers that is used to represent a transformation for any sort of position or vector! This is an oversimplification of what a matrix actually is, but it's accurate in this case. Matrices are really useful for transforms because you can chain together all sorts of transforms into a single Matrix! A Matrix transform really shines when applied to many
| 27 | /// Matrices are prominently used within shaders for mesh transforms! |
| 28 | /// </summary> |
| 29 | public struct Matrix |
| 30 | { |
| 31 | /// <summary>The internal, wrapped System.Numerics type. This can be |
| 32 | /// nice to have around so you can pass its fields as 'ref', which you |
| 33 | /// can't do with properties. You won't often need this, as implicit |
| 34 | /// conversions to System.Numerics types are also provided.</summary> |
| 35 | public Matrix4x4 m; |
| 36 | |
| 37 | /// <summary>This constructor is for manually creating a matrix from a |
| 38 | /// grid of floats! You'll likely want to use one of the static Matrix |
| 39 | /// functions to create a Matrix instead.</summary> |
| 40 | /// <param name="m11">m11</param> |
| 41 | /// <param name="m12">m12</param> |
| 42 | /// <param name="m13">m13</param> |
| 43 | /// <param name="m14">m14</param> |
| 44 | /// <param name="m21">m21</param> |
| 45 | /// <param name="m22">m22</param> |
| 46 | /// <param name="m23">m23</param> |
| 47 | /// <param name="m24">m24</param> |
| 48 | /// <param name="m31">m31</param> |
| 49 | /// <param name="m32">m32</param> |
| 50 | /// <param name="m33">m33</param> |
| 51 | /// <param name="m34">m34</param> |
| 52 | /// <param name="m41">m41</param> |
| 53 | /// <param name="m42">m42</param> |
| 54 | /// <param name="m43">m43</param> |
| 55 | /// <param name="m44">m44</param> |
| 56 | public Matrix(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) |
| 57 | => m = new Matrix4x4( |
| 58 | m11, m12, m13, m14, |
| 59 | m21, m22, m23, m24, |
| 60 | m31, m32, m33, m34, |
| 61 | m41, m42, m43, m44); |
| 62 | /// <summary>Create a Matrix from the equivalent System.Numerics Matrix |
| 63 | /// type. You can also implicitly convert between these types, as this |
| 64 | /// Matrix is backed by the System.Numerics type anyhow.</summary> |
| 65 | /// <param name="matrix">A System.Numerics matrix.</param> |
| 66 | public Matrix(Matrix4x4 matrix) |
| 67 | => m = matrix; |
| 68 | |
| 69 | /// <summary>Allows implicit conversion from System.Numerics.Matrix4x4 |
| 70 | /// to StereoKit.Matrix.</summary> |
| 71 | /// <param name="m">Any System.Numerics Matrix4x4.</param> |
| 72 | /// <returns>A StereoKit compatible matrix.</returns> |
| 73 | public static implicit operator Matrix(Matrix4x4 m) => new Matrix(m); |
| 74 | /// <summary>Allows implicit conversion from StereoKit.Matrix to |
| 75 | /// System.Numerics.Matrix4x4</summary> |
| 76 | /// <param name="m">Any StereoKit.Matrix.</param> |
| 77 | /// <returns>A System.Numerics compatible matrix.</returns> |
| 78 | public static implicit operator Matrix4x4(Matrix m) => m.m; |
| 79 | |
| 80 | /// <summary>Multiplies two matrices together! This is a great way to |
| 81 | /// combine transform operations. Note that StereoKit's matrices are |
| 82 | /// row-major, and multiplication order is important! To translate, |
| 83 | /// then scale, multiply in order of 'translate * scale'.</summary> |
| 84 | /// <param name="a">First Matrix.</param> |
| 85 | /// <param name="b">Second Matrix.</param> |
| 86 | /// <returns>Result of matrix multiplication.</returns> |
nothing calls this directly
no test coverage detected