Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

float2x2.gen.cs 40KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. //------------------------------------------------------------------------------
  2. // <auto-generated>
  3. // This code was generated by a tool.
  4. //
  5. // Changes to this file may cause incorrect behavior and will be lost if
  6. // the code is regenerated. To update the generation of this file, modify and re-run Unity.Mathematics.CodeGen.
  7. // </auto-generated>
  8. //------------------------------------------------------------------------------
  9. using System;
  10. using System.Runtime.CompilerServices;
  11. using Unity.IL2CPP.CompilerServices;
  12. #pragma warning disable 0660, 0661
  13. namespace Unity.Mathematics
  14. {
  15. /// <summary>A 2x2 matrix of floats.</summary>
  16. [System.Serializable]
  17. [Il2CppEagerStaticClassConstruction]
  18. public partial struct float2x2 : System.IEquatable<float2x2>, IFormattable
  19. {
  20. /// <summary>Column 0 of the matrix.</summary>
  21. public float2 c0;
  22. /// <summary>Column 1 of the matrix.</summary>
  23. public float2 c1;
  24. /// <summary>float2x2 identity transform.</summary>
  25. public static readonly float2x2 identity = new float2x2(1.0f, 0.0f, 0.0f, 1.0f);
  26. /// <summary>float2x2 zero value.</summary>
  27. public static readonly float2x2 zero;
  28. /// <summary>Constructs a float2x2 matrix from two float2 vectors.</summary>
  29. /// <param name="c0">The matrix column c0 will be set to this value.</param>
  30. /// <param name="c1">The matrix column c1 will be set to this value.</param>
  31. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  32. public float2x2(float2 c0, float2 c1)
  33. {
  34. this.c0 = c0;
  35. this.c1 = c1;
  36. }
  37. /// <summary>Constructs a float2x2 matrix from 4 float values given in row-major order.</summary>
  38. /// <param name="m00">The matrix at row 0, column 0 will be set to this value.</param>
  39. /// <param name="m01">The matrix at row 0, column 1 will be set to this value.</param>
  40. /// <param name="m10">The matrix at row 1, column 0 will be set to this value.</param>
  41. /// <param name="m11">The matrix at row 1, column 1 will be set to this value.</param>
  42. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  43. public float2x2(float m00, float m01,
  44. float m10, float m11)
  45. {
  46. this.c0 = new float2(m00, m10);
  47. this.c1 = new float2(m01, m11);
  48. }
  49. /// <summary>Constructs a float2x2 matrix from a single float value by assigning it to every component.</summary>
  50. /// <param name="v">float to convert to float2x2</param>
  51. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  52. public float2x2(float v)
  53. {
  54. this.c0 = v;
  55. this.c1 = v;
  56. }
  57. /// <summary>Constructs a float2x2 matrix from a single bool value by converting it to float and assigning it to every component.</summary>
  58. /// <param name="v">bool to convert to float2x2</param>
  59. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  60. public float2x2(bool v)
  61. {
  62. this.c0 = math.select(new float2(0.0f), new float2(1.0f), v);
  63. this.c1 = math.select(new float2(0.0f), new float2(1.0f), v);
  64. }
  65. /// <summary>Constructs a float2x2 matrix from a bool2x2 matrix by componentwise conversion.</summary>
  66. /// <param name="v">bool2x2 to convert to float2x2</param>
  67. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  68. public float2x2(bool2x2 v)
  69. {
  70. this.c0 = math.select(new float2(0.0f), new float2(1.0f), v.c0);
  71. this.c1 = math.select(new float2(0.0f), new float2(1.0f), v.c1);
  72. }
  73. /// <summary>Constructs a float2x2 matrix from a single int value by converting it to float and assigning it to every component.</summary>
  74. /// <param name="v">int to convert to float2x2</param>
  75. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  76. public float2x2(int v)
  77. {
  78. this.c0 = v;
  79. this.c1 = v;
  80. }
  81. /// <summary>Constructs a float2x2 matrix from a int2x2 matrix by componentwise conversion.</summary>
  82. /// <param name="v">int2x2 to convert to float2x2</param>
  83. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  84. public float2x2(int2x2 v)
  85. {
  86. this.c0 = v.c0;
  87. this.c1 = v.c1;
  88. }
  89. /// <summary>Constructs a float2x2 matrix from a single uint value by converting it to float and assigning it to every component.</summary>
  90. /// <param name="v">uint to convert to float2x2</param>
  91. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  92. public float2x2(uint v)
  93. {
  94. this.c0 = v;
  95. this.c1 = v;
  96. }
  97. /// <summary>Constructs a float2x2 matrix from a uint2x2 matrix by componentwise conversion.</summary>
  98. /// <param name="v">uint2x2 to convert to float2x2</param>
  99. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  100. public float2x2(uint2x2 v)
  101. {
  102. this.c0 = v.c0;
  103. this.c1 = v.c1;
  104. }
  105. /// <summary>Constructs a float2x2 matrix from a single double value by converting it to float and assigning it to every component.</summary>
  106. /// <param name="v">double to convert to float2x2</param>
  107. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  108. public float2x2(double v)
  109. {
  110. this.c0 = (float2)v;
  111. this.c1 = (float2)v;
  112. }
  113. /// <summary>Constructs a float2x2 matrix from a double2x2 matrix by componentwise conversion.</summary>
  114. /// <param name="v">double2x2 to convert to float2x2</param>
  115. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  116. public float2x2(double2x2 v)
  117. {
  118. this.c0 = (float2)v.c0;
  119. this.c1 = (float2)v.c1;
  120. }
  121. /// <summary>Implicitly converts a single float value to a float2x2 matrix by assigning it to every component.</summary>
  122. /// <param name="v">float to convert to float2x2</param>
  123. /// <returns>Converted value.</returns>
  124. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  125. public static implicit operator float2x2(float v) { return new float2x2(v); }
  126. /// <summary>Explicitly converts a single bool value to a float2x2 matrix by converting it to float and assigning it to every component.</summary>
  127. /// <param name="v">bool to convert to float2x2</param>
  128. /// <returns>Converted value.</returns>
  129. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  130. public static explicit operator float2x2(bool v) { return new float2x2(v); }
  131. /// <summary>Explicitly converts a bool2x2 matrix to a float2x2 matrix by componentwise conversion.</summary>
  132. /// <param name="v">bool2x2 to convert to float2x2</param>
  133. /// <returns>Converted value.</returns>
  134. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  135. public static explicit operator float2x2(bool2x2 v) { return new float2x2(v); }
  136. /// <summary>Implicitly converts a single int value to a float2x2 matrix by converting it to float and assigning it to every component.</summary>
  137. /// <param name="v">int to convert to float2x2</param>
  138. /// <returns>Converted value.</returns>
  139. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  140. public static implicit operator float2x2(int v) { return new float2x2(v); }
  141. /// <summary>Implicitly converts a int2x2 matrix to a float2x2 matrix by componentwise conversion.</summary>
  142. /// <param name="v">int2x2 to convert to float2x2</param>
  143. /// <returns>Converted value.</returns>
  144. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  145. public static implicit operator float2x2(int2x2 v) { return new float2x2(v); }
  146. /// <summary>Implicitly converts a single uint value to a float2x2 matrix by converting it to float and assigning it to every component.</summary>
  147. /// <param name="v">uint to convert to float2x2</param>
  148. /// <returns>Converted value.</returns>
  149. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  150. public static implicit operator float2x2(uint v) { return new float2x2(v); }
  151. /// <summary>Implicitly converts a uint2x2 matrix to a float2x2 matrix by componentwise conversion.</summary>
  152. /// <param name="v">uint2x2 to convert to float2x2</param>
  153. /// <returns>Converted value.</returns>
  154. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  155. public static implicit operator float2x2(uint2x2 v) { return new float2x2(v); }
  156. /// <summary>Explicitly converts a single double value to a float2x2 matrix by converting it to float and assigning it to every component.</summary>
  157. /// <param name="v">double to convert to float2x2</param>
  158. /// <returns>Converted value.</returns>
  159. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  160. public static explicit operator float2x2(double v) { return new float2x2(v); }
  161. /// <summary>Explicitly converts a double2x2 matrix to a float2x2 matrix by componentwise conversion.</summary>
  162. /// <param name="v">double2x2 to convert to float2x2</param>
  163. /// <returns>Converted value.</returns>
  164. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  165. public static explicit operator float2x2(double2x2 v) { return new float2x2(v); }
  166. /// <summary>Returns the result of a componentwise multiplication operation on two float2x2 matrices.</summary>
  167. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise multiplication.</param>
  168. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise multiplication.</param>
  169. /// <returns>float2x2 result of the componentwise multiplication.</returns>
  170. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  171. public static float2x2 operator * (float2x2 lhs, float2x2 rhs) { return new float2x2 (lhs.c0 * rhs.c0, lhs.c1 * rhs.c1); }
  172. /// <summary>Returns the result of a componentwise multiplication operation on a float2x2 matrix and a float value.</summary>
  173. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise multiplication.</param>
  174. /// <param name="rhs">Right hand side float to use to compute componentwise multiplication.</param>
  175. /// <returns>float2x2 result of the componentwise multiplication.</returns>
  176. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  177. public static float2x2 operator * (float2x2 lhs, float rhs) { return new float2x2 (lhs.c0 * rhs, lhs.c1 * rhs); }
  178. /// <summary>Returns the result of a componentwise multiplication operation on a float value and a float2x2 matrix.</summary>
  179. /// <param name="lhs">Left hand side float to use to compute componentwise multiplication.</param>
  180. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise multiplication.</param>
  181. /// <returns>float2x2 result of the componentwise multiplication.</returns>
  182. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  183. public static float2x2 operator * (float lhs, float2x2 rhs) { return new float2x2 (lhs * rhs.c0, lhs * rhs.c1); }
  184. /// <summary>Returns the result of a componentwise addition operation on two float2x2 matrices.</summary>
  185. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise addition.</param>
  186. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise addition.</param>
  187. /// <returns>float2x2 result of the componentwise addition.</returns>
  188. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  189. public static float2x2 operator + (float2x2 lhs, float2x2 rhs) { return new float2x2 (lhs.c0 + rhs.c0, lhs.c1 + rhs.c1); }
  190. /// <summary>Returns the result of a componentwise addition operation on a float2x2 matrix and a float value.</summary>
  191. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise addition.</param>
  192. /// <param name="rhs">Right hand side float to use to compute componentwise addition.</param>
  193. /// <returns>float2x2 result of the componentwise addition.</returns>
  194. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  195. public static float2x2 operator + (float2x2 lhs, float rhs) { return new float2x2 (lhs.c0 + rhs, lhs.c1 + rhs); }
  196. /// <summary>Returns the result of a componentwise addition operation on a float value and a float2x2 matrix.</summary>
  197. /// <param name="lhs">Left hand side float to use to compute componentwise addition.</param>
  198. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise addition.</param>
  199. /// <returns>float2x2 result of the componentwise addition.</returns>
  200. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  201. public static float2x2 operator + (float lhs, float2x2 rhs) { return new float2x2 (lhs + rhs.c0, lhs + rhs.c1); }
  202. /// <summary>Returns the result of a componentwise subtraction operation on two float2x2 matrices.</summary>
  203. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise subtraction.</param>
  204. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise subtraction.</param>
  205. /// <returns>float2x2 result of the componentwise subtraction.</returns>
  206. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  207. public static float2x2 operator - (float2x2 lhs, float2x2 rhs) { return new float2x2 (lhs.c0 - rhs.c0, lhs.c1 - rhs.c1); }
  208. /// <summary>Returns the result of a componentwise subtraction operation on a float2x2 matrix and a float value.</summary>
  209. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise subtraction.</param>
  210. /// <param name="rhs">Right hand side float to use to compute componentwise subtraction.</param>
  211. /// <returns>float2x2 result of the componentwise subtraction.</returns>
  212. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  213. public static float2x2 operator - (float2x2 lhs, float rhs) { return new float2x2 (lhs.c0 - rhs, lhs.c1 - rhs); }
  214. /// <summary>Returns the result of a componentwise subtraction operation on a float value and a float2x2 matrix.</summary>
  215. /// <param name="lhs">Left hand side float to use to compute componentwise subtraction.</param>
  216. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise subtraction.</param>
  217. /// <returns>float2x2 result of the componentwise subtraction.</returns>
  218. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  219. public static float2x2 operator - (float lhs, float2x2 rhs) { return new float2x2 (lhs - rhs.c0, lhs - rhs.c1); }
  220. /// <summary>Returns the result of a componentwise division operation on two float2x2 matrices.</summary>
  221. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise division.</param>
  222. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise division.</param>
  223. /// <returns>float2x2 result of the componentwise division.</returns>
  224. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  225. public static float2x2 operator / (float2x2 lhs, float2x2 rhs) { return new float2x2 (lhs.c0 / rhs.c0, lhs.c1 / rhs.c1); }
  226. /// <summary>Returns the result of a componentwise division operation on a float2x2 matrix and a float value.</summary>
  227. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise division.</param>
  228. /// <param name="rhs">Right hand side float to use to compute componentwise division.</param>
  229. /// <returns>float2x2 result of the componentwise division.</returns>
  230. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  231. public static float2x2 operator / (float2x2 lhs, float rhs) { return new float2x2 (lhs.c0 / rhs, lhs.c1 / rhs); }
  232. /// <summary>Returns the result of a componentwise division operation on a float value and a float2x2 matrix.</summary>
  233. /// <param name="lhs">Left hand side float to use to compute componentwise division.</param>
  234. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise division.</param>
  235. /// <returns>float2x2 result of the componentwise division.</returns>
  236. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  237. public static float2x2 operator / (float lhs, float2x2 rhs) { return new float2x2 (lhs / rhs.c0, lhs / rhs.c1); }
  238. /// <summary>Returns the result of a componentwise modulus operation on two float2x2 matrices.</summary>
  239. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise modulus.</param>
  240. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise modulus.</param>
  241. /// <returns>float2x2 result of the componentwise modulus.</returns>
  242. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  243. public static float2x2 operator % (float2x2 lhs, float2x2 rhs) { return new float2x2 (lhs.c0 % rhs.c0, lhs.c1 % rhs.c1); }
  244. /// <summary>Returns the result of a componentwise modulus operation on a float2x2 matrix and a float value.</summary>
  245. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise modulus.</param>
  246. /// <param name="rhs">Right hand side float to use to compute componentwise modulus.</param>
  247. /// <returns>float2x2 result of the componentwise modulus.</returns>
  248. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  249. public static float2x2 operator % (float2x2 lhs, float rhs) { return new float2x2 (lhs.c0 % rhs, lhs.c1 % rhs); }
  250. /// <summary>Returns the result of a componentwise modulus operation on a float value and a float2x2 matrix.</summary>
  251. /// <param name="lhs">Left hand side float to use to compute componentwise modulus.</param>
  252. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise modulus.</param>
  253. /// <returns>float2x2 result of the componentwise modulus.</returns>
  254. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  255. public static float2x2 operator % (float lhs, float2x2 rhs) { return new float2x2 (lhs % rhs.c0, lhs % rhs.c1); }
  256. /// <summary>Returns the result of a componentwise increment operation on a float2x2 matrix.</summary>
  257. /// <param name="val">Value to use when computing the componentwise increment.</param>
  258. /// <returns>float2x2 result of the componentwise increment.</returns>
  259. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  260. public static float2x2 operator ++ (float2x2 val) { return new float2x2 (++val.c0, ++val.c1); }
  261. /// <summary>Returns the result of a componentwise decrement operation on a float2x2 matrix.</summary>
  262. /// <param name="val">Value to use when computing the componentwise decrement.</param>
  263. /// <returns>float2x2 result of the componentwise decrement.</returns>
  264. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  265. public static float2x2 operator -- (float2x2 val) { return new float2x2 (--val.c0, --val.c1); }
  266. /// <summary>Returns the result of a componentwise less than operation on two float2x2 matrices.</summary>
  267. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise less than.</param>
  268. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise less than.</param>
  269. /// <returns>bool2x2 result of the componentwise less than.</returns>
  270. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  271. public static bool2x2 operator < (float2x2 lhs, float2x2 rhs) { return new bool2x2 (lhs.c0 < rhs.c0, lhs.c1 < rhs.c1); }
  272. /// <summary>Returns the result of a componentwise less than operation on a float2x2 matrix and a float value.</summary>
  273. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise less than.</param>
  274. /// <param name="rhs">Right hand side float to use to compute componentwise less than.</param>
  275. /// <returns>bool2x2 result of the componentwise less than.</returns>
  276. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  277. public static bool2x2 operator < (float2x2 lhs, float rhs) { return new bool2x2 (lhs.c0 < rhs, lhs.c1 < rhs); }
  278. /// <summary>Returns the result of a componentwise less than operation on a float value and a float2x2 matrix.</summary>
  279. /// <param name="lhs">Left hand side float to use to compute componentwise less than.</param>
  280. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise less than.</param>
  281. /// <returns>bool2x2 result of the componentwise less than.</returns>
  282. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  283. public static bool2x2 operator < (float lhs, float2x2 rhs) { return new bool2x2 (lhs < rhs.c0, lhs < rhs.c1); }
  284. /// <summary>Returns the result of a componentwise less or equal operation on two float2x2 matrices.</summary>
  285. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise less or equal.</param>
  286. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise less or equal.</param>
  287. /// <returns>bool2x2 result of the componentwise less or equal.</returns>
  288. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  289. public static bool2x2 operator <= (float2x2 lhs, float2x2 rhs) { return new bool2x2 (lhs.c0 <= rhs.c0, lhs.c1 <= rhs.c1); }
  290. /// <summary>Returns the result of a componentwise less or equal operation on a float2x2 matrix and a float value.</summary>
  291. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise less or equal.</param>
  292. /// <param name="rhs">Right hand side float to use to compute componentwise less or equal.</param>
  293. /// <returns>bool2x2 result of the componentwise less or equal.</returns>
  294. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  295. public static bool2x2 operator <= (float2x2 lhs, float rhs) { return new bool2x2 (lhs.c0 <= rhs, lhs.c1 <= rhs); }
  296. /// <summary>Returns the result of a componentwise less or equal operation on a float value and a float2x2 matrix.</summary>
  297. /// <param name="lhs">Left hand side float to use to compute componentwise less or equal.</param>
  298. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise less or equal.</param>
  299. /// <returns>bool2x2 result of the componentwise less or equal.</returns>
  300. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  301. public static bool2x2 operator <= (float lhs, float2x2 rhs) { return new bool2x2 (lhs <= rhs.c0, lhs <= rhs.c1); }
  302. /// <summary>Returns the result of a componentwise greater than operation on two float2x2 matrices.</summary>
  303. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise greater than.</param>
  304. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise greater than.</param>
  305. /// <returns>bool2x2 result of the componentwise greater than.</returns>
  306. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  307. public static bool2x2 operator > (float2x2 lhs, float2x2 rhs) { return new bool2x2 (lhs.c0 > rhs.c0, lhs.c1 > rhs.c1); }
  308. /// <summary>Returns the result of a componentwise greater than operation on a float2x2 matrix and a float value.</summary>
  309. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise greater than.</param>
  310. /// <param name="rhs">Right hand side float to use to compute componentwise greater than.</param>
  311. /// <returns>bool2x2 result of the componentwise greater than.</returns>
  312. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  313. public static bool2x2 operator > (float2x2 lhs, float rhs) { return new bool2x2 (lhs.c0 > rhs, lhs.c1 > rhs); }
  314. /// <summary>Returns the result of a componentwise greater than operation on a float value and a float2x2 matrix.</summary>
  315. /// <param name="lhs">Left hand side float to use to compute componentwise greater than.</param>
  316. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise greater than.</param>
  317. /// <returns>bool2x2 result of the componentwise greater than.</returns>
  318. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  319. public static bool2x2 operator > (float lhs, float2x2 rhs) { return new bool2x2 (lhs > rhs.c0, lhs > rhs.c1); }
  320. /// <summary>Returns the result of a componentwise greater or equal operation on two float2x2 matrices.</summary>
  321. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise greater or equal.</param>
  322. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise greater or equal.</param>
  323. /// <returns>bool2x2 result of the componentwise greater or equal.</returns>
  324. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  325. public static bool2x2 operator >= (float2x2 lhs, float2x2 rhs) { return new bool2x2 (lhs.c0 >= rhs.c0, lhs.c1 >= rhs.c1); }
  326. /// <summary>Returns the result of a componentwise greater or equal operation on a float2x2 matrix and a float value.</summary>
  327. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise greater or equal.</param>
  328. /// <param name="rhs">Right hand side float to use to compute componentwise greater or equal.</param>
  329. /// <returns>bool2x2 result of the componentwise greater or equal.</returns>
  330. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  331. public static bool2x2 operator >= (float2x2 lhs, float rhs) { return new bool2x2 (lhs.c0 >= rhs, lhs.c1 >= rhs); }
  332. /// <summary>Returns the result of a componentwise greater or equal operation on a float value and a float2x2 matrix.</summary>
  333. /// <param name="lhs">Left hand side float to use to compute componentwise greater or equal.</param>
  334. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise greater or equal.</param>
  335. /// <returns>bool2x2 result of the componentwise greater or equal.</returns>
  336. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  337. public static bool2x2 operator >= (float lhs, float2x2 rhs) { return new bool2x2 (lhs >= rhs.c0, lhs >= rhs.c1); }
  338. /// <summary>Returns the result of a componentwise unary minus operation on a float2x2 matrix.</summary>
  339. /// <param name="val">Value to use when computing the componentwise unary minus.</param>
  340. /// <returns>float2x2 result of the componentwise unary minus.</returns>
  341. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  342. public static float2x2 operator - (float2x2 val) { return new float2x2 (-val.c0, -val.c1); }
  343. /// <summary>Returns the result of a componentwise unary plus operation on a float2x2 matrix.</summary>
  344. /// <param name="val">Value to use when computing the componentwise unary plus.</param>
  345. /// <returns>float2x2 result of the componentwise unary plus.</returns>
  346. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  347. public static float2x2 operator + (float2x2 val) { return new float2x2 (+val.c0, +val.c1); }
  348. /// <summary>Returns the result of a componentwise equality operation on two float2x2 matrices.</summary>
  349. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise equality.</param>
  350. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise equality.</param>
  351. /// <returns>bool2x2 result of the componentwise equality.</returns>
  352. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  353. public static bool2x2 operator == (float2x2 lhs, float2x2 rhs) { return new bool2x2 (lhs.c0 == rhs.c0, lhs.c1 == rhs.c1); }
  354. /// <summary>Returns the result of a componentwise equality operation on a float2x2 matrix and a float value.</summary>
  355. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise equality.</param>
  356. /// <param name="rhs">Right hand side float to use to compute componentwise equality.</param>
  357. /// <returns>bool2x2 result of the componentwise equality.</returns>
  358. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  359. public static bool2x2 operator == (float2x2 lhs, float rhs) { return new bool2x2 (lhs.c0 == rhs, lhs.c1 == rhs); }
  360. /// <summary>Returns the result of a componentwise equality operation on a float value and a float2x2 matrix.</summary>
  361. /// <param name="lhs">Left hand side float to use to compute componentwise equality.</param>
  362. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise equality.</param>
  363. /// <returns>bool2x2 result of the componentwise equality.</returns>
  364. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  365. public static bool2x2 operator == (float lhs, float2x2 rhs) { return new bool2x2 (lhs == rhs.c0, lhs == rhs.c1); }
  366. /// <summary>Returns the result of a componentwise not equal operation on two float2x2 matrices.</summary>
  367. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise not equal.</param>
  368. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise not equal.</param>
  369. /// <returns>bool2x2 result of the componentwise not equal.</returns>
  370. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  371. public static bool2x2 operator != (float2x2 lhs, float2x2 rhs) { return new bool2x2 (lhs.c0 != rhs.c0, lhs.c1 != rhs.c1); }
  372. /// <summary>Returns the result of a componentwise not equal operation on a float2x2 matrix and a float value.</summary>
  373. /// <param name="lhs">Left hand side float2x2 to use to compute componentwise not equal.</param>
  374. /// <param name="rhs">Right hand side float to use to compute componentwise not equal.</param>
  375. /// <returns>bool2x2 result of the componentwise not equal.</returns>
  376. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  377. public static bool2x2 operator != (float2x2 lhs, float rhs) { return new bool2x2 (lhs.c0 != rhs, lhs.c1 != rhs); }
  378. /// <summary>Returns the result of a componentwise not equal operation on a float value and a float2x2 matrix.</summary>
  379. /// <param name="lhs">Left hand side float to use to compute componentwise not equal.</param>
  380. /// <param name="rhs">Right hand side float2x2 to use to compute componentwise not equal.</param>
  381. /// <returns>bool2x2 result of the componentwise not equal.</returns>
  382. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  383. public static bool2x2 operator != (float lhs, float2x2 rhs) { return new bool2x2 (lhs != rhs.c0, lhs != rhs.c1); }
  384. /// <summary>Returns the float2 element at a specified index.</summary>
  385. unsafe public ref float2 this[int index]
  386. {
  387. get
  388. {
  389. #if ENABLE_UNITY_COLLECTIONS_CHECKS
  390. if ((uint)index >= 2)
  391. throw new System.ArgumentException("index must be between[0...1]");
  392. #endif
  393. fixed (float2x2* array = &this) { return ref ((float2*)array)[index]; }
  394. }
  395. }
  396. /// <summary>Returns true if the float2x2 is equal to a given float2x2, false otherwise.</summary>
  397. /// <param name="rhs">Right hand side argument to compare equality with.</param>
  398. /// <returns>The result of the equality comparison.</returns>
  399. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  400. public bool Equals(float2x2 rhs) { return c0.Equals(rhs.c0) && c1.Equals(rhs.c1); }
  401. /// <summary>Returns true if the float2x2 is equal to a given float2x2, false otherwise.</summary>
  402. /// <param name="o">Right hand side argument to compare equality with.</param>
  403. /// <returns>The result of the equality comparison.</returns>
  404. public override bool Equals(object o) { return o is float2x2 converted && Equals(converted); }
  405. /// <summary>Returns a hash code for the float2x2.</summary>
  406. /// <returns>The computed hash code.</returns>
  407. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  408. public override int GetHashCode() { return (int)math.hash(this); }
  409. /// <summary>Returns a string representation of the float2x2.</summary>
  410. /// <returns>String representation of the value.</returns>
  411. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  412. public override string ToString()
  413. {
  414. return string.Format("float2x2({0}f, {1}f, {2}f, {3}f)", c0.x, c1.x, c0.y, c1.y);
  415. }
  416. /// <summary>Returns a string representation of the float2x2 using a specified format and culture-specific format information.</summary>
  417. /// <param name="format">Format string to use during string formatting.</param>
  418. /// <param name="formatProvider">Format provider to use during string formatting.</param>
  419. /// <returns>String representation of the value.</returns>
  420. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  421. public string ToString(string format, IFormatProvider formatProvider)
  422. {
  423. return string.Format("float2x2({0}f, {1}f, {2}f, {3}f)", c0.x.ToString(format, formatProvider), c1.x.ToString(format, formatProvider), c0.y.ToString(format, formatProvider), c1.y.ToString(format, formatProvider));
  424. }
  425. }
  426. public static partial class math
  427. {
  428. /// <summary>Returns a float2x2 matrix constructed from two float2 vectors.</summary>
  429. /// <param name="c0">The matrix column c0 will be set to this value.</param>
  430. /// <param name="c1">The matrix column c1 will be set to this value.</param>
  431. /// <returns>float2x2 constructed from arguments.</returns>
  432. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  433. public static float2x2 float2x2(float2 c0, float2 c1) { return new float2x2(c0, c1); }
  434. /// <summary>Returns a float2x2 matrix constructed from from 4 float values given in row-major order.</summary>
  435. /// <param name="m00">The matrix at row 0, column 0 will be set to this value.</param>
  436. /// <param name="m01">The matrix at row 0, column 1 will be set to this value.</param>
  437. /// <param name="m10">The matrix at row 1, column 0 will be set to this value.</param>
  438. /// <param name="m11">The matrix at row 1, column 1 will be set to this value.</param>
  439. /// <returns>float2x2 constructed from arguments.</returns>
  440. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  441. public static float2x2 float2x2(float m00, float m01,
  442. float m10, float m11)
  443. {
  444. return new float2x2(m00, m01,
  445. m10, m11);
  446. }
  447. /// <summary>Returns a float2x2 matrix constructed from a single float value by assigning it to every component.</summary>
  448. /// <param name="v">float to convert to float2x2</param>
  449. /// <returns>Converted value.</returns>
  450. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  451. public static float2x2 float2x2(float v) { return new float2x2(v); }
  452. /// <summary>Returns a float2x2 matrix constructed from a single bool value by converting it to float and assigning it to every component.</summary>
  453. /// <param name="v">bool to convert to float2x2</param>
  454. /// <returns>Converted value.</returns>
  455. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  456. public static float2x2 float2x2(bool v) { return new float2x2(v); }
  457. /// <summary>Return a float2x2 matrix constructed from a bool2x2 matrix by componentwise conversion.</summary>
  458. /// <param name="v">bool2x2 to convert to float2x2</param>
  459. /// <returns>Converted value.</returns>
  460. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  461. public static float2x2 float2x2(bool2x2 v) { return new float2x2(v); }
  462. /// <summary>Returns a float2x2 matrix constructed from a single int value by converting it to float and assigning it to every component.</summary>
  463. /// <param name="v">int to convert to float2x2</param>
  464. /// <returns>Converted value.</returns>
  465. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  466. public static float2x2 float2x2(int v) { return new float2x2(v); }
  467. /// <summary>Return a float2x2 matrix constructed from a int2x2 matrix by componentwise conversion.</summary>
  468. /// <param name="v">int2x2 to convert to float2x2</param>
  469. /// <returns>Converted value.</returns>
  470. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  471. public static float2x2 float2x2(int2x2 v) { return new float2x2(v); }
  472. /// <summary>Returns a float2x2 matrix constructed from a single uint value by converting it to float and assigning it to every component.</summary>
  473. /// <param name="v">uint to convert to float2x2</param>
  474. /// <returns>Converted value.</returns>
  475. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  476. public static float2x2 float2x2(uint v) { return new float2x2(v); }
  477. /// <summary>Return a float2x2 matrix constructed from a uint2x2 matrix by componentwise conversion.</summary>
  478. /// <param name="v">uint2x2 to convert to float2x2</param>
  479. /// <returns>Converted value.</returns>
  480. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  481. public static float2x2 float2x2(uint2x2 v) { return new float2x2(v); }
  482. /// <summary>Returns a float2x2 matrix constructed from a single double value by converting it to float and assigning it to every component.</summary>
  483. /// <param name="v">double to convert to float2x2</param>
  484. /// <returns>Converted value.</returns>
  485. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  486. public static float2x2 float2x2(double v) { return new float2x2(v); }
  487. /// <summary>Return a float2x2 matrix constructed from a double2x2 matrix by componentwise conversion.</summary>
  488. /// <param name="v">double2x2 to convert to float2x2</param>
  489. /// <returns>Converted value.</returns>
  490. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  491. public static float2x2 float2x2(double2x2 v) { return new float2x2(v); }
  492. /// <summary>Return the float2x2 transpose of a float2x2 matrix.</summary>
  493. /// <param name="v">Value to transpose.</param>
  494. /// <returns>Transposed value.</returns>
  495. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  496. public static float2x2 transpose(float2x2 v)
  497. {
  498. return float2x2(
  499. v.c0.x, v.c0.y,
  500. v.c1.x, v.c1.y);
  501. }
  502. /// <summary>Returns the float2x2 full inverse of a float2x2 matrix.</summary>
  503. /// <param name="m">Matrix to invert.</param>
  504. /// <returns>The inverted matrix.</returns>
  505. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  506. public static float2x2 inverse(float2x2 m)
  507. {
  508. float a = m.c0.x;
  509. float b = m.c1.x;
  510. float c = m.c0.y;
  511. float d = m.c1.y;
  512. float det = a * d - b * c;
  513. return float2x2(d, -b, -c, a) * (1.0f / det);
  514. }
  515. /// <summary>Returns the determinant of a float2x2 matrix.</summary>
  516. /// <param name="m">Matrix to use when computing determinant.</param>
  517. /// <returns>The determinant of the matrix.</returns>
  518. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  519. public static float determinant(float2x2 m)
  520. {
  521. float a = m.c0.x;
  522. float b = m.c1.x;
  523. float c = m.c0.y;
  524. float d = m.c1.y;
  525. return a * d - b * c;
  526. }
  527. /// <summary>Returns a uint hash code of a float2x2 matrix.</summary>
  528. /// <param name="v">Matrix value to hash.</param>
  529. /// <returns>uint hash of the argument.</returns>
  530. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  531. public static uint hash(float2x2 v)
  532. {
  533. return csum(asuint(v.c0) * uint2(0x9C9F0823u, 0x5A9CA13Bu) +
  534. asuint(v.c1) * uint2(0xAFCDD5EFu, 0xA88D187Du)) + 0xCF6EBA1Du;
  535. }
  536. /// <summary>
  537. /// Returns a uint2 vector hash code of a float2x2 matrix.
  538. /// When multiple elements are to be hashes together, it can more efficient to calculate and combine wide hash
  539. /// that are only reduced to a narrow uint hash at the very end instead of at every step.
  540. /// </summary>
  541. /// <param name="v">Matrix value to hash.</param>
  542. /// <returns>uint2 hash of the argument.</returns>
  543. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  544. public static uint2 hashwide(float2x2 v)
  545. {
  546. return (asuint(v.c0) * uint2(0x9D88E5A1u, 0xEADF0775u) +
  547. asuint(v.c1) * uint2(0x747A9D7Bu, 0x4111F799u)) + 0xB5F05AF1u;
  548. }
  549. }
  550. }