Vector3.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. using System;
  2. using System.Globalization;
  3. namespace UnityEngine
  4. {
  5. [Serializable]
  6. public struct Vector3: IEquatable<Vector3>
  7. {
  8. private const float k1OverSqrt2 = 0.7071068f;
  9. private const float epsilon = 1E-05f;
  10. public static readonly Vector3 zero = new Vector3();
  11. public static readonly Vector3 one = new Vector3(1f, 1f, 1f);
  12. public static readonly Vector3 up = new Vector3(0.0f, 1f, 0.0f);
  13. public static readonly Vector3 down = new Vector3(0.0f, -1f, 0.0f);
  14. public static readonly Vector3 right = new Vector3(1f, 0.0f, 0.0f);
  15. public static readonly Vector3 left = new Vector3(-1f, 0.0f, 0.0f);
  16. public static readonly Vector3 forward = new Vector3(0.0f, 0.0f, 1f);
  17. public static readonly Vector3 back = new Vector3(0.0f, 0.0f, -1f);
  18. public float x;
  19. public float y;
  20. public float z;
  21. public Vector3(float x, float y, float z)
  22. {
  23. this.x = x;
  24. this.y = y;
  25. this.z = z;
  26. }
  27. public Vector3(float value)
  28. {
  29. this.x = this.y = this.z = value;
  30. }
  31. public Vector3(Vector2 value, float z)
  32. {
  33. this.x = value.x;
  34. this.y = value.y;
  35. this.z = z;
  36. }
  37. public override string ToString()
  38. {
  39. CultureInfo currentCulture = CultureInfo.CurrentCulture;
  40. return string.Format(currentCulture, "({0}, {1}, {2})", this.x.ToString(currentCulture),
  41. this.y.ToString(currentCulture),
  42. this.z.ToString(currentCulture));
  43. }
  44. public bool Equals(Vector3 other)
  45. {
  46. if (this.x == (double) other.x && this.y == (double) other.y)
  47. return this.z == (double) other.z;
  48. return false;
  49. }
  50. public override bool Equals(object obj)
  51. {
  52. bool flag = false;
  53. if (obj is Vector3)
  54. flag = this.Equals((Vector3) obj);
  55. return flag;
  56. }
  57. public override int GetHashCode()
  58. {
  59. return this.x.GetHashCode() + this.y.GetHashCode() + this.z.GetHashCode();
  60. }
  61. public float Length()
  62. {
  63. return (float) Math.Sqrt(this.x * (double) this.x + this.y * (double) this.y + this.z * (double) this.z);
  64. }
  65. public float LengthSquared()
  66. {
  67. return (float) (this.x * (double) this.x + this.y * (double) this.y + this.z * (double) this.z);
  68. }
  69. public float magnitude
  70. {
  71. get
  72. {
  73. return this.Length();
  74. }
  75. }
  76. public float sqrMagnitude
  77. {
  78. get
  79. {
  80. return this.LengthSquared();
  81. }
  82. }
  83. public static float Distance(Vector3 value1, Vector3 value2)
  84. {
  85. float num1 = value1.x - value2.x;
  86. float num2 = value1.y - value2.y;
  87. float num3 = value1.z - value2.z;
  88. return (float) Math.Sqrt(num1 * (double) num1 + num2 * (double) num2 + num3 * (double) num3);
  89. }
  90. public static void Distance(ref Vector3 value1, ref Vector3 value2, out float result)
  91. {
  92. float num1 = value1.x - value2.x;
  93. float num2 = value1.y - value2.y;
  94. float num3 = value1.z - value2.z;
  95. float num4 = (float) (num1 * (double) num1 + num2 * (double) num2 + num3 * (double) num3);
  96. result = (float) Math.Sqrt(num4);
  97. }
  98. public static float DistanceSquared(Vector3 value1, Vector3 value2)
  99. {
  100. float num1 = value1.x - value2.x;
  101. float num2 = value1.y - value2.y;
  102. float num3 = value1.z - value2.z;
  103. return (float) (num1 * (double) num1 + num2 * (double) num2 + num3 * (double) num3);
  104. }
  105. public static void DistanceSquared(ref Vector3 value1, ref Vector3 value2, out float result)
  106. {
  107. float num1 = value1.x - value2.x;
  108. float num2 = value1.y - value2.y;
  109. float num3 = value1.z - value2.z;
  110. result = (float) (num1 * (double) num1 + num2 * (double) num2 + num3 * (double) num3);
  111. }
  112. public static float Dot(Vector3 vector1, Vector3 vector2)
  113. {
  114. return (float) (vector1.x * (double) vector2.x + vector1.y * (double) vector2.y +
  115. vector1.z * (double) vector2.z);
  116. }
  117. public static void Dot(ref Vector3 vector1, ref Vector3 vector2, out float result)
  118. {
  119. result = (float) (vector1.x * (double) vector2.x + vector1.y * (double) vector2.y +
  120. vector1.z * (double) vector2.z);
  121. }
  122. public void Normalize()
  123. {
  124. float num1 = (float) (this.x * (double) this.x + this.y * (double) this.y + this.z * (double) this.z);
  125. if (num1 < (double) Mathf.Epsilon)
  126. return;
  127. float num2 = 1f / (float) Math.Sqrt(num1);
  128. this.x *= num2;
  129. this.y *= num2;
  130. this.z *= num2;
  131. }
  132. public Vector3 normalized
  133. {
  134. get
  135. {
  136. return Vector3.Normalize(this);
  137. }
  138. }
  139. public static Vector3 Normalize(Vector3 value)
  140. {
  141. float num1 = (float) (value.x * (double) value.x + value.y * (double) value.y + value.z * (double) value.z);
  142. if (num1 < (double) Mathf.Epsilon)
  143. return value;
  144. float num2 = 1f / (float) Math.Sqrt(num1);
  145. Vector3 vector3;
  146. vector3.x = value.x * num2;
  147. vector3.y = value.y * num2;
  148. vector3.z = value.z * num2;
  149. return vector3;
  150. }
  151. public static void Normalize(ref Vector3 value, out Vector3 result)
  152. {
  153. float num1 = (float) (value.x * (double) value.x + value.y * (double) value.y + value.z * (double) value.z);
  154. if (num1 < (double) Mathf.Epsilon)
  155. {
  156. result = value;
  157. }
  158. else
  159. {
  160. float num2 = 1f / (float) Math.Sqrt(num1);
  161. result.x = value.x * num2;
  162. result.y = value.y * num2;
  163. result.z = value.z * num2;
  164. }
  165. }
  166. public static Vector3 Cross(Vector3 vector1, Vector3 vector2)
  167. {
  168. Vector3 vector3;
  169. vector3.x = (float) (vector1.y * (double) vector2.z - vector1.z * (double) vector2.y);
  170. vector3.y = (float) (vector1.z * (double) vector2.x - vector1.x * (double) vector2.z);
  171. vector3.z = (float) (vector1.x * (double) vector2.y - vector1.y * (double) vector2.x);
  172. return vector3;
  173. }
  174. public static void Cross(ref Vector3 vector1, ref Vector3 vector2, out Vector3 result)
  175. {
  176. float num1 = (float) (vector1.y * (double) vector2.z - vector1.z * (double) vector2.y);
  177. float num2 = (float) (vector1.z * (double) vector2.x - vector1.x * (double) vector2.z);
  178. float num3 = (float) (vector1.x * (double) vector2.y - vector1.y * (double) vector2.x);
  179. result.x = num1;
  180. result.y = num2;
  181. result.z = num3;
  182. }
  183. public static Vector3 Reflect(Vector3 vector, Vector3 normal)
  184. {
  185. float num =
  186. (float) (vector.x * (double) normal.x + vector.y * (double) normal.y + vector.z * (double) normal.z);
  187. Vector3 vector3;
  188. vector3.x = vector.x - 2f * num * normal.x;
  189. vector3.y = vector.y - 2f * num * normal.y;
  190. vector3.z = vector.z - 2f * num * normal.z;
  191. return vector3;
  192. }
  193. public static void Reflect(ref Vector3 vector, ref Vector3 normal, out Vector3 result)
  194. {
  195. float num =
  196. (float) (vector.x * (double) normal.x + vector.y * (double) normal.y + vector.z * (double) normal.z);
  197. result.x = vector.x - 2f * num * normal.x;
  198. result.y = vector.y - 2f * num * normal.y;
  199. result.z = vector.z - 2f * num * normal.z;
  200. }
  201. public static Vector3 Min(Vector3 value1, Vector3 value2)
  202. {
  203. Vector3 vector3;
  204. vector3.x = (double) value1.x < (double) value2.x? value1.x : value2.x;
  205. vector3.y = (double) value1.y < (double) value2.y? value1.y : value2.y;
  206. vector3.z = (double) value1.z < (double) value2.z? value1.z : value2.z;
  207. return vector3;
  208. }
  209. public static void Min(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
  210. {
  211. result.x = (double) value1.x < (double) value2.x? value1.x : value2.x;
  212. result.y = (double) value1.y < (double) value2.y? value1.y : value2.y;
  213. result.z = (double) value1.z < (double) value2.z? value1.z : value2.z;
  214. }
  215. public static Vector3 Max(Vector3 value1, Vector3 value2)
  216. {
  217. Vector3 vector3;
  218. vector3.x = (double) value1.x > (double) value2.x? value1.x : value2.x;
  219. vector3.y = (double) value1.y > (double) value2.y? value1.y : value2.y;
  220. vector3.z = (double) value1.z > (double) value2.z? value1.z : value2.z;
  221. return vector3;
  222. }
  223. public static void Max(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
  224. {
  225. result.x = (double) value1.x > (double) value2.x? value1.x : value2.x;
  226. result.y = (double) value1.y > (double) value2.y? value1.y : value2.y;
  227. result.z = (double) value1.z > (double) value2.z? value1.z : value2.z;
  228. }
  229. public static Vector3 Clamp(Vector3 value1, Vector3 min, Vector3 max)
  230. {
  231. float x = value1.x;
  232. float num1 = (double) x > (double) max.x? max.x : x;
  233. float num2 = (double) num1 < (double) min.x? min.x : num1;
  234. float y = value1.y;
  235. float num3 = (double) y > (double) max.y? max.y : y;
  236. float num4 = (double) num3 < (double) min.y? min.y : num3;
  237. float z = value1.z;
  238. float num5 = (double) z > (double) max.z? max.z : z;
  239. float num6 = (double) num5 < (double) min.z? min.z : num5;
  240. Vector3 vector3;
  241. vector3.x = num2;
  242. vector3.y = num4;
  243. vector3.z = num6;
  244. return vector3;
  245. }
  246. public static void Clamp(ref Vector3 value1, ref Vector3 min, ref Vector3 max, out Vector3 result)
  247. {
  248. float x = value1.x;
  249. float num1 = (double) x > (double) max.x? max.x : x;
  250. float num2 = (double) num1 < (double) min.x? min.x : num1;
  251. float y = value1.y;
  252. float num3 = (double) y > (double) max.y? max.y : y;
  253. float num4 = (double) num3 < (double) min.y? min.y : num3;
  254. float z = value1.z;
  255. float num5 = (double) z > (double) max.z? max.z : z;
  256. float num6 = (double) num5 < (double) min.z? min.z : num5;
  257. result.x = num2;
  258. result.y = num4;
  259. result.z = num6;
  260. }
  261. public static Vector3 Lerp(Vector3 value1, Vector3 value2, float amount)
  262. {
  263. Vector3 vector3;
  264. vector3.x = value1.x + (value2.x - value1.x) * amount;
  265. vector3.y = value1.y + (value2.y - value1.y) * amount;
  266. vector3.z = value1.z + (value2.z - value1.z) * amount;
  267. return vector3;
  268. }
  269. public static void Lerp(ref Vector3 value1, ref Vector3 value2, float amount, out Vector3 result)
  270. {
  271. result.x = value1.x + (value2.x - value1.x) * amount;
  272. result.y = value1.y + (value2.y - value1.y) * amount;
  273. result.z = value1.z + (value2.z - value1.z) * amount;
  274. }
  275. public static Vector3 SmoothStep(Vector3 value1, Vector3 value2, float amount)
  276. {
  277. amount = (double) amount > 1.0? 1f : ((double) amount < 0.0? 0.0f : amount);
  278. amount = (float) (amount * (double) amount * (3.0 - 2.0 * amount));
  279. Vector3 vector3;
  280. vector3.x = value1.x + (value2.x - value1.x) * amount;
  281. vector3.y = value1.y + (value2.y - value1.y) * amount;
  282. vector3.z = value1.z + (value2.z - value1.z) * amount;
  283. return vector3;
  284. }
  285. public static void SmoothStep(ref Vector3 value1, ref Vector3 value2, float amount, out Vector3 result)
  286. {
  287. amount = (double) amount > 1.0? 1f : ((double) amount < 0.0? 0.0f : amount);
  288. amount = (float) (amount * (double) amount * (3.0 - 2.0 * amount));
  289. result.x = value1.x + (value2.x - value1.x) * amount;
  290. result.y = value1.y + (value2.y - value1.y) * amount;
  291. result.z = value1.z + (value2.z - value1.z) * amount;
  292. }
  293. public static Vector3 Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount)
  294. {
  295. float num1 = amount * amount;
  296. float num2 = amount * num1;
  297. float num3 = (float) (2.0 * num2 - 3.0 * num1 + 1.0);
  298. float num4 = (float) (-2.0 * num2 + 3.0 * num1);
  299. float num5 = num2 - 2f * num1 + amount;
  300. float num6 = num2 - num1;
  301. Vector3 vector3;
  302. vector3.x = (float) (value1.x * (double) num3 + value2.x * (double) num4 + tangent1.x * (double) num5 +
  303. tangent2.x * (double) num6);
  304. vector3.y = (float) (value1.y * (double) num3 + value2.y * (double) num4 + tangent1.y * (double) num5 +
  305. tangent2.y * (double) num6);
  306. vector3.z = (float) (value1.z * (double) num3 + value2.z * (double) num4 + tangent1.z * (double) num5 +
  307. tangent2.z * (double) num6);
  308. return vector3;
  309. }
  310. public static void Hermite(
  311. ref Vector3 value1, ref Vector3 tangent1, ref Vector3 value2, ref Vector3 tangent2, float amount, out Vector3 result)
  312. {
  313. float num1 = amount * amount;
  314. float num2 = amount * num1;
  315. float num3 = (float) (2.0 * num2 - 3.0 * num1 + 1.0);
  316. float num4 = (float) (-2.0 * num2 + 3.0 * num1);
  317. float num5 = num2 - 2f * num1 + amount;
  318. float num6 = num2 - num1;
  319. result.x = (float) (value1.x * (double) num3 + value2.x * (double) num4 + tangent1.x * (double) num5 +
  320. tangent2.x * (double) num6);
  321. result.y = (float) (value1.y * (double) num3 + value2.y * (double) num4 + tangent1.y * (double) num5 +
  322. tangent2.y * (double) num6);
  323. result.z = (float) (value1.z * (double) num3 + value2.z * (double) num4 + tangent1.z * (double) num5 +
  324. tangent2.z * (double) num6);
  325. }
  326. public static Vector3 Negate(Vector3 value)
  327. {
  328. Vector3 vector3;
  329. vector3.x = -value.x;
  330. vector3.y = -value.y;
  331. vector3.z = -value.z;
  332. return vector3;
  333. }
  334. public static void Negate(ref Vector3 value, out Vector3 result)
  335. {
  336. result.x = -value.x;
  337. result.y = -value.y;
  338. result.z = -value.z;
  339. }
  340. public static Vector3 Add(Vector3 value1, Vector3 value2)
  341. {
  342. Vector3 vector3;
  343. vector3.x = value1.x + value2.x;
  344. vector3.y = value1.y + value2.y;
  345. vector3.z = value1.z + value2.z;
  346. return vector3;
  347. }
  348. public static void Add(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
  349. {
  350. result.x = value1.x + value2.x;
  351. result.y = value1.y + value2.y;
  352. result.z = value1.z + value2.z;
  353. }
  354. public static Vector3 Sub(Vector3 value1, Vector3 value2)
  355. {
  356. Vector3 vector3;
  357. vector3.x = value1.x - value2.x;
  358. vector3.y = value1.y - value2.y;
  359. vector3.z = value1.z - value2.z;
  360. return vector3;
  361. }
  362. public static void Sub(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
  363. {
  364. result.x = value1.x - value2.x;
  365. result.y = value1.y - value2.y;
  366. result.z = value1.z - value2.z;
  367. }
  368. public static Vector3 Multiply(Vector3 value1, Vector3 value2)
  369. {
  370. Vector3 vector3;
  371. vector3.x = value1.x * value2.x;
  372. vector3.y = value1.y * value2.y;
  373. vector3.z = value1.z * value2.z;
  374. return vector3;
  375. }
  376. public static void Multiply(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
  377. {
  378. result.x = value1.x * value2.x;
  379. result.y = value1.y * value2.y;
  380. result.z = value1.z * value2.z;
  381. }
  382. public static Vector3 Multiply(Vector3 value1, float scaleFactor)
  383. {
  384. Vector3 vector3;
  385. vector3.x = value1.x * scaleFactor;
  386. vector3.y = value1.y * scaleFactor;
  387. vector3.z = value1.z * scaleFactor;
  388. return vector3;
  389. }
  390. public static void Multiply(ref Vector3 value1, float scaleFactor, out Vector3 result)
  391. {
  392. result.x = value1.x * scaleFactor;
  393. result.y = value1.y * scaleFactor;
  394. result.z = value1.z * scaleFactor;
  395. }
  396. public static Vector3 Divide(Vector3 value1, Vector3 value2)
  397. {
  398. Vector3 vector3;
  399. vector3.x = value1.x / value2.x;
  400. vector3.y = value1.y / value2.y;
  401. vector3.z = value1.z / value2.z;
  402. return vector3;
  403. }
  404. public static void Divide(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
  405. {
  406. result.x = value1.x / value2.x;
  407. result.y = value1.y / value2.y;
  408. result.z = value1.z / value2.z;
  409. }
  410. public static Vector3 Divide(Vector3 value1, float divider)
  411. {
  412. float num = 1f / divider;
  413. Vector3 vector3;
  414. vector3.x = value1.x * num;
  415. vector3.y = value1.y * num;
  416. vector3.z = value1.z * num;
  417. return vector3;
  418. }
  419. public static void Divide(ref Vector3 value1, float divider, out Vector3 result)
  420. {
  421. float num = 1f / divider;
  422. result.x = value1.x * num;
  423. result.y = value1.y * num;
  424. result.z = value1.z * num;
  425. }
  426. private static float magnitudeStatic(ref Vector3 inV)
  427. {
  428. return (float) Math.Sqrt(Vector3.Dot(inV, inV));
  429. }
  430. private static Vector3 orthoNormalVectorFast(ref Vector3 n)
  431. {
  432. Vector3 vector3;
  433. if (Math.Abs(n.z) > (double) Vector3.k1OverSqrt2)
  434. {
  435. float num = 1f / (float) Math.Sqrt(n.y * (double) n.y + n.z * (double) n.z);
  436. vector3.x = 0.0f;
  437. vector3.y = -n.z * num;
  438. vector3.z = n.y * num;
  439. }
  440. else
  441. {
  442. float num = 1f / (float) Math.Sqrt(n.x * (double) n.x + n.y * (double) n.y);
  443. vector3.x = -n.y * num;
  444. vector3.y = n.x * num;
  445. vector3.z = 0.0f;
  446. }
  447. return vector3;
  448. }
  449. public static void OrthoNormalize(ref Vector3 normal, ref Vector3 tangent)
  450. {
  451. float num1 = Vector3.magnitudeStatic(ref normal);
  452. if (num1 > (double) Mathf.Epsilon)
  453. normal /= num1;
  454. else
  455. normal = new Vector3(1f, 0.0f, 0.0f);
  456. float num2 = Vector3.Dot(normal, tangent);
  457. tangent -= num2 * normal;
  458. float num3 = Vector3.magnitudeStatic(ref tangent);
  459. if (num3 < (double) Mathf.Epsilon)
  460. tangent = Vector3.orthoNormalVectorFast(ref normal);
  461. else
  462. tangent /= num3;
  463. }
  464. public static void OrthoNormalize(ref Vector3 normal, ref Vector3 tangent, ref Vector3 binormal)
  465. {
  466. float num1 = Vector3.magnitudeStatic(ref normal);
  467. if (num1 > (double) Mathf.Epsilon)
  468. normal /= num1;
  469. else
  470. normal = new Vector3(1f, 0.0f, 0.0f);
  471. float num2 = Vector3.Dot(normal, tangent);
  472. tangent -= num2 * normal;
  473. float num3 = Vector3.magnitudeStatic(ref tangent);
  474. if (num3 > (double) Mathf.Epsilon)
  475. tangent /= num3;
  476. else
  477. tangent = Vector3.orthoNormalVectorFast(ref normal);
  478. float num4 = Vector3.Dot(tangent, binormal);
  479. float num5 = Vector3.Dot(normal, binormal);
  480. binormal -= num5 * normal + num4 * tangent;
  481. float num6 = Vector3.magnitudeStatic(ref binormal);
  482. if (num6 > (double) Mathf.Epsilon)
  483. binormal /= num6;
  484. else
  485. binormal = Vector3.Cross(normal, tangent);
  486. }
  487. public static Vector3 Project(Vector3 vector, Vector3 onNormal)
  488. {
  489. return onNormal * Vector3.Dot(vector, onNormal) / Vector3.Dot(onNormal, onNormal);
  490. }
  491. public static void Project(ref Vector3 vector, ref Vector3 onNormal, out Vector3 result)
  492. {
  493. result = onNormal * Vector3.Dot(vector, onNormal) / Vector3.Dot(onNormal, onNormal);
  494. }
  495. public static float Angle(Vector3 from, Vector3 to)
  496. {
  497. from.Normalize();
  498. to.Normalize();
  499. float result;
  500. Vector3.Dot(ref from, ref to, out result);
  501. return Mathf.Acos(Mathf.Clamp(result, -1f, 1f)) * 57.29578f;
  502. }
  503. public static void Angle(ref Vector3 from, ref Vector3 to, out float result)
  504. {
  505. from.Normalize();
  506. to.Normalize();
  507. float result1;
  508. Vector3.Dot(ref from, ref to, out result1);
  509. result = Mathf.Acos(Mathf.Clamp(result1, -1f, 1f)) * 57.29578f;
  510. }
  511. public static Vector3 operator -(Vector3 value)
  512. {
  513. Vector3 vector3;
  514. vector3.x = -value.x;
  515. vector3.y = -value.y;
  516. vector3.z = -value.z;
  517. return vector3;
  518. }
  519. public static bool operator ==(Vector3 lhs, Vector3 rhs)
  520. {
  521. return (lhs - rhs).sqrMagnitude < 9.99999943962493E-11;
  522. }
  523. public static bool operator !=(Vector3 lhs, Vector3 rhs)
  524. {
  525. return !(lhs == rhs);
  526. }
  527. public static Vector3 operator +(Vector3 value1, Vector3 value2)
  528. {
  529. Vector3 vector3;
  530. vector3.x = value1.x + value2.x;
  531. vector3.y = value1.y + value2.y;
  532. vector3.z = value1.z + value2.z;
  533. return vector3;
  534. }
  535. public static Vector3 operator -(Vector3 value1, Vector3 value2)
  536. {
  537. Vector3 vector3;
  538. vector3.x = value1.x - value2.x;
  539. vector3.y = value1.y - value2.y;
  540. vector3.z = value1.z - value2.z;
  541. return vector3;
  542. }
  543. public static Vector3 operator *(Vector3 value1, Vector3 value2)
  544. {
  545. Vector3 vector3;
  546. vector3.x = value1.x * value2.x;
  547. vector3.y = value1.y * value2.y;
  548. vector3.z = value1.z * value2.z;
  549. return vector3;
  550. }
  551. public static Vector3 operator *(Vector3 value, float scaleFactor)
  552. {
  553. Vector3 vector3;
  554. vector3.x = value.x * scaleFactor;
  555. vector3.y = value.y * scaleFactor;
  556. vector3.z = value.z * scaleFactor;
  557. return vector3;
  558. }
  559. public static Vector3 operator *(float scaleFactor, Vector3 value)
  560. {
  561. Vector3 vector3;
  562. vector3.x = value.x * scaleFactor;
  563. vector3.y = value.y * scaleFactor;
  564. vector3.z = value.z * scaleFactor;
  565. return vector3;
  566. }
  567. public static Vector3 operator /(Vector3 value1, Vector3 value2)
  568. {
  569. Vector3 vector3;
  570. vector3.x = value1.x / value2.x;
  571. vector3.y = value1.y / value2.y;
  572. vector3.z = value1.z / value2.z;
  573. return vector3;
  574. }
  575. public static Vector3 operator /(Vector3 value, float divider)
  576. {
  577. float num = 1f / divider;
  578. Vector3 vector3;
  579. vector3.x = value.x * num;
  580. vector3.y = value.y * num;
  581. vector3.z = value.z * num;
  582. return vector3;
  583. }
  584. }
  585. }