Vector4.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. #region License
  2. /*
  3. MIT License
  4. Copyright © 2006 The Mono.Xna Team
  5. All rights reserved.
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in all
  13. copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. SOFTWARE.
  21. */
  22. #endregion License
  23. using System;
  24. using System.ComponentModel;
  25. using System.Text;
  26. using System.Runtime.InteropServices;
  27. namespace MonoXnaCompactMaths
  28. {
  29. [Serializable]
  30. [StructLayout(LayoutKind.Sequential)]
  31. //[TypeConverter(typeof(Vector4Converter))]
  32. public struct Vector4 : IEquatable<Vector4>
  33. {
  34. #region Private Fields
  35. private static Vector4 zeroVector = new Vector4();
  36. private static Vector4 unitVector = new Vector4(1f, 1f, 1f, 1f);
  37. private static Vector4 unitXVector = new Vector4(1f, 0f, 0f, 0f);
  38. private static Vector4 unitYVector = new Vector4(0f, 1f, 0f, 0f);
  39. private static Vector4 unitZVector = new Vector4(0f, 0f, 1f, 0f);
  40. private static Vector4 unitWVector = new Vector4(0f, 0f, 0f, 1f);
  41. #endregion Private Fields
  42. #region Public Fields
  43. public float X;
  44. public float Y;
  45. public float Z;
  46. public float W;
  47. #endregion Public Fields
  48. #region Properties
  49. public static Vector4 Zero
  50. {
  51. get { return zeroVector; }
  52. }
  53. public static Vector4 One
  54. {
  55. get { return unitVector; }
  56. }
  57. public static Vector4 UnitX
  58. {
  59. get { return unitXVector; }
  60. }
  61. public static Vector4 UnitY
  62. {
  63. get { return unitYVector; }
  64. }
  65. public static Vector4 UnitZ
  66. {
  67. get { return unitZVector; }
  68. }
  69. public static Vector4 UnitW
  70. {
  71. get { return unitWVector; }
  72. }
  73. #endregion Properties
  74. #region Constructors
  75. public Vector4(float x, float y, float z, float w)
  76. {
  77. this.X = x;
  78. this.Y = y;
  79. this.Z = z;
  80. this.W = w;
  81. }
  82. /*public Vector4(Vector2 value, float z, float w)
  83. {
  84. this.X = value.X;
  85. this.Y = value.Y;
  86. this.Z = z;
  87. this.W = w;
  88. }*/
  89. public Vector4(Vector3 value, float w)
  90. {
  91. this.X = value.X;
  92. this.Y = value.Y;
  93. this.Z = value.Z;
  94. this.W = w;
  95. }
  96. public Vector4(float value)
  97. {
  98. this.X = value;
  99. this.Y = value;
  100. this.Z = value;
  101. this.W = value;
  102. }
  103. #endregion
  104. #region Public Methods
  105. public static Vector4 Add(Vector4 value1, Vector4 value2)
  106. {
  107. value1.W += value2.W;
  108. value1.X += value2.X;
  109. value1.Y += value2.Y;
  110. value1.Z += value2.Z;
  111. return value1;
  112. }
  113. public static void Add(ref Vector4 value1, ref Vector4 value2, out Vector4 result)
  114. {
  115. result.W = value1.W + value2.W;
  116. result.X = value1.X + value2.X;
  117. result.Y = value1.Y + value2.Y;
  118. result.Z = value1.Z + value2.Z;
  119. }
  120. /*public static Vector4 Barycentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2)
  121. {
  122. return new Vector4(
  123. MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
  124. MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2),
  125. MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2),
  126. MathHelper.Barycentric(value1.W, value2.W, value3.W, amount1, amount2));
  127. }*/
  128. /*public static void Barycentric(ref Vector4 value1, ref Vector4 value2, ref Vector4 value3, float amount1, float amount2, out Vector4 result)
  129. {
  130. result = new Vector4(
  131. MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
  132. MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2),
  133. MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2),
  134. MathHelper.Barycentric(value1.W, value2.W, value3.W, amount1, amount2));
  135. }*/
  136. /*public static Vector4 CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount)
  137. {
  138. return new Vector4(
  139. MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount),
  140. MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount),
  141. MathHelper.CatmullRom(value1.Z, value2.Z, value3.Z, value4.Z, amount),
  142. MathHelper.CatmullRom(value1.W, value2.W, value3.W, value4.W, amount));
  143. }*/
  144. /*public static void CatmullRom(ref Vector4 value1, ref Vector4 value2, ref Vector4 value3, ref Vector4 value4, float amount, out Vector4 result)
  145. {
  146. result = new Vector4(
  147. MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount),
  148. MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount),
  149. MathHelper.CatmullRom(value1.Z, value2.Z, value3.Z, value4.Z, amount),
  150. MathHelper.CatmullRom(value1.W, value2.W, value3.W, value4.W, amount));
  151. }*/
  152. /*public static Vector4 Clamp(Vector4 value1, Vector4 min, Vector4 max)
  153. {
  154. return new Vector4(
  155. MathHelper.Clamp(value1.X, min.X, max.X),
  156. MathHelper.Clamp(value1.Y, min.Y, max.Y),
  157. MathHelper.Clamp(value1.Z, min.Z, max.Z),
  158. MathHelper.Clamp(value1.W, min.W, max.W));
  159. }*/
  160. /*public static void Clamp(ref Vector4 value1, ref Vector4 min, ref Vector4 max, out Vector4 result)
  161. {
  162. result = new Vector4(
  163. MathHelper.Clamp(value1.X, min.X, max.X),
  164. MathHelper.Clamp(value1.Y, min.Y, max.Y),
  165. MathHelper.Clamp(value1.Z, min.Z, max.Z),
  166. MathHelper.Clamp(value1.W, min.W, max.W));
  167. }*/
  168. public static float Distance(Vector4 value1, Vector4 value2)
  169. {
  170. return (float)Math.Sqrt(DistanceSquared(value1, value2));
  171. }
  172. public static void Distance(ref Vector4 value1, ref Vector4 value2, out float result)
  173. {
  174. result = (float)Math.Sqrt(DistanceSquared(value1, value2));
  175. }
  176. public static float DistanceSquared(Vector4 value1, Vector4 value2)
  177. {
  178. float result;
  179. DistanceSquared(ref value1, ref value2, out result);
  180. return result;
  181. }
  182. public static void DistanceSquared(ref Vector4 value1, ref Vector4 value2, out float result)
  183. {
  184. result = (value1.W - value2.W) * (value1.W - value2.W) +
  185. (value1.X - value2.X) * (value1.X - value2.X) +
  186. (value1.Y - value2.Y) * (value1.Y - value2.Y) +
  187. (value1.Z - value2.Z) * (value1.Z - value2.Z);
  188. }
  189. public static Vector4 Divide(Vector4 value1, Vector4 value2)
  190. {
  191. value1.W /= value2.W;
  192. value1.X /= value2.X;
  193. value1.Y /= value2.Y;
  194. value1.Z /= value2.Z;
  195. return value1;
  196. }
  197. public static Vector4 Divide(Vector4 value1, float divider)
  198. {
  199. float factor = 1f / divider;
  200. value1.W *= factor;
  201. value1.X *= factor;
  202. value1.Y *= factor;
  203. value1.Z *= factor;
  204. return value1;
  205. }
  206. public static void Divide(ref Vector4 value1, float divider, out Vector4 result)
  207. {
  208. float factor = 1f / divider;
  209. result.W = value1.W * factor;
  210. result.X = value1.X * factor;
  211. result.Y = value1.Y * factor;
  212. result.Z = value1.Z * factor;
  213. }
  214. public static void Divide(ref Vector4 value1, ref Vector4 value2, out Vector4 result)
  215. {
  216. result.W = value1.W / value2.W;
  217. result.X = value1.X / value2.X;
  218. result.Y = value1.Y / value2.Y;
  219. result.Z = value1.Z / value2.Z;
  220. }
  221. public static float Dot(Vector4 vector1, Vector4 vector2)
  222. {
  223. return vector1.X * vector2.X + vector1.Y * vector2.Y + vector1.Z * vector2.Z + vector1.W * vector2.W;
  224. }
  225. public static void Dot(ref Vector4 vector1, ref Vector4 vector2, out float result)
  226. {
  227. result = vector1.X * vector2.X + vector1.Y * vector2.Y + vector1.Z * vector2.Z + vector1.W * vector2.W;
  228. }
  229. public override bool Equals(object obj)
  230. {
  231. return (obj is Vector4) ? this == (Vector4)obj : false;
  232. }
  233. public bool Equals(Vector4 other)
  234. {
  235. return this.W == other.W
  236. && this.X == other.X
  237. && this.Y == other.Y
  238. && this.Z == other.Z;
  239. }
  240. public override int GetHashCode()
  241. {
  242. return (int)(this.W + this.X + this.Y + this.Y);
  243. }
  244. /*public static Vector4 Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount)
  245. {
  246. Vector4 result = new Vector4();
  247. Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out result);
  248. return result;
  249. }*/
  250. /*public static void Hermite(ref Vector4 value1, ref Vector4 tangent1, ref Vector4 value2, ref Vector4 tangent2, float amount, out Vector4 result)
  251. {
  252. result.W = MathHelper.Hermite(value1.W, tangent1.W, value2.W, tangent2.W, amount);
  253. result.X = MathHelper.Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount);
  254. result.Y = MathHelper.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount);
  255. result.Z = MathHelper.Hermite(value1.Z, tangent1.Z, value2.Z, tangent2.Z, amount);
  256. }*/
  257. public float Length()
  258. {
  259. float result;
  260. DistanceSquared(ref this, ref zeroVector, out result);
  261. return (float)Math.Sqrt(result);
  262. }
  263. public float LengthSquared()
  264. {
  265. float result;
  266. DistanceSquared(ref this, ref zeroVector, out result);
  267. return result;
  268. }
  269. /*public static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount)
  270. {
  271. return new Vector4(
  272. MathHelper.Lerp(value1.X, value2.X, amount),
  273. MathHelper.Lerp(value1.Y, value2.Y, amount),
  274. MathHelper.Lerp(value1.Z, value2.Z, amount),
  275. MathHelper.Lerp(value1.W, value2.W, amount));
  276. }*/
  277. /*public static void Lerp(ref Vector4 value1, ref Vector4 value2, float amount, out Vector4 result)
  278. {
  279. result = new Vector4(
  280. MathHelper.Lerp(value1.X, value2.X, amount),
  281. MathHelper.Lerp(value1.Y, value2.Y, amount),
  282. MathHelper.Lerp(value1.Z, value2.Z, amount),
  283. MathHelper.Lerp(value1.W, value2.W, amount));
  284. }*/
  285. /*public static Vector4 Max(Vector4 value1, Vector4 value2)
  286. {
  287. return new Vector4(
  288. MathHelper.Max(value1.X, value2.X),
  289. MathHelper.Max(value1.Y, value2.Y),
  290. MathHelper.Max(value1.Z, value2.Z),
  291. MathHelper.Max(value1.W, value2.W));
  292. }*/
  293. /*public static void Max(ref Vector4 value1, ref Vector4 value2, out Vector4 result)
  294. {
  295. result = new Vector4(
  296. MathHelper.Max(value1.X, value2.X),
  297. MathHelper.Max(value1.Y, value2.Y),
  298. MathHelper.Max(value1.Z, value2.Z),
  299. MathHelper.Max(value1.W, value2.W));
  300. }*/
  301. /*public static Vector4 Min(Vector4 value1, Vector4 value2)
  302. {
  303. return new Vector4(
  304. MathHelper.Min(value1.X, value2.X),
  305. MathHelper.Min(value1.Y, value2.Y),
  306. MathHelper.Min(value1.Z, value2.Z),
  307. MathHelper.Min(value1.W, value2.W));
  308. }*/
  309. /*public static void Min(ref Vector4 value1, ref Vector4 value2, out Vector4 result)
  310. {
  311. result = new Vector4(
  312. MathHelper.Min(value1.X, value2.X),
  313. MathHelper.Min(value1.Y, value2.Y),
  314. MathHelper.Min(value1.Z, value2.Z),
  315. MathHelper.Min(value1.W, value2.W));
  316. }*/
  317. public static Vector4 Multiply(Vector4 value1, Vector4 value2)
  318. {
  319. value1.W *= value2.W;
  320. value1.X *= value2.X;
  321. value1.Y *= value2.Y;
  322. value1.Z *= value2.Z;
  323. return value1;
  324. }
  325. public static Vector4 Multiply(Vector4 value1, float scaleFactor)
  326. {
  327. value1.W *= scaleFactor;
  328. value1.X *= scaleFactor;
  329. value1.Y *= scaleFactor;
  330. value1.Z *= scaleFactor;
  331. return value1;
  332. }
  333. public static void Multiply(ref Vector4 value1, float scaleFactor, out Vector4 result)
  334. {
  335. result.W = value1.W * scaleFactor;
  336. result.X = value1.X * scaleFactor;
  337. result.Y = value1.Y * scaleFactor;
  338. result.Z = value1.Z * scaleFactor;
  339. }
  340. public static void Multiply(ref Vector4 value1, ref Vector4 value2, out Vector4 result)
  341. {
  342. result.W = value1.W * value2.W;
  343. result.X = value1.X * value2.X;
  344. result.Y = value1.Y * value2.Y;
  345. result.Z = value1.Z * value2.Z;
  346. }
  347. public static Vector4 Negate(Vector4 value)
  348. {
  349. value = new Vector4(-value.X, -value.Y, -value.Z, -value.W);
  350. return value;
  351. }
  352. public static void Negate(ref Vector4 value, out Vector4 result)
  353. {
  354. result = new Vector4(-value.X, -value.Y, -value.Z,-value.W);
  355. }
  356. public void Normalize()
  357. {
  358. Normalize(ref this, out this);
  359. }
  360. public static Vector4 Normalize(Vector4 vector)
  361. {
  362. Normalize(ref vector, out vector);
  363. return vector;
  364. }
  365. public static void Normalize(ref Vector4 vector, out Vector4 result)
  366. {
  367. float factor;
  368. DistanceSquared(ref vector, ref zeroVector, out factor);
  369. factor = 1f / (float)Math.Sqrt(factor);
  370. result.W = vector.W * factor;
  371. result.X = vector.X * factor;
  372. result.Y = vector.Y * factor;
  373. result.Z = vector.Z * factor;
  374. }
  375. /*public static Vector4 SmoothStep(Vector4 value1, Vector4 value2, float amount)
  376. {
  377. return new Vector4(
  378. MathHelper.SmoothStep(value1.X, value2.X, amount),
  379. MathHelper.SmoothStep(value1.Y, value2.Y, amount),
  380. MathHelper.SmoothStep(value1.Z, value2.Z, amount),
  381. MathHelper.SmoothStep(value1.W, value2.W, amount));
  382. }*/
  383. /*public static void SmoothStep(ref Vector4 value1, ref Vector4 value2, float amount, out Vector4 result)
  384. {
  385. result = new Vector4(
  386. MathHelper.SmoothStep(value1.X, value2.X, amount),
  387. MathHelper.SmoothStep(value1.Y, value2.Y, amount),
  388. MathHelper.SmoothStep(value1.Z, value2.Z, amount),
  389. MathHelper.SmoothStep(value1.W, value2.W, amount));
  390. }*/
  391. public static Vector4 Subtract(Vector4 value1, Vector4 value2)
  392. {
  393. value1.W -= value2.W;
  394. value1.X -= value2.X;
  395. value1.Y -= value2.Y;
  396. value1.Z -= value2.Z;
  397. return value1;
  398. }
  399. public static void Subtract(ref Vector4 value1, ref Vector4 value2, out Vector4 result)
  400. {
  401. result.W = value1.W - value2.W;
  402. result.X = value1.X - value2.X;
  403. result.Y = value1.Y - value2.Y;
  404. result.Z = value1.Z - value2.Z;
  405. }
  406. /*public static Vector4 Transform(Vector2 position, Matrix matrix)
  407. {
  408. Vector4 result;
  409. Transform(ref position, ref matrix, out result);
  410. return result;
  411. }*/
  412. public static Vector4 Transform(Vector3 position, Matrix matrix)
  413. {
  414. Vector4 result;
  415. Transform(ref position, ref matrix, out result);
  416. return result;
  417. }
  418. public static Vector4 Transform(Vector4 vector, Matrix matrix)
  419. {
  420. Transform(ref vector, ref matrix, out vector);
  421. return vector;
  422. }
  423. /*public static void Transform(ref Vector2 position, ref Matrix matrix, out Vector4 result)
  424. {
  425. result = new Vector4((position.X * matrix.M11) + (position.Y * matrix.M21) + matrix.M41,
  426. (position.X * matrix.M12) + (position.Y * matrix.M22) + matrix.M42,
  427. (position.X * matrix.M13) + (position.Y * matrix.M23) + matrix.M43,
  428. (position.X * matrix.M14) + (position.Y * matrix.M24) + matrix.M44);
  429. }*/
  430. public static void Transform(ref Vector3 position, ref Matrix matrix, out Vector4 result)
  431. {
  432. result = new Vector4((position.X * matrix.M11) + (position.Y * matrix.M21) + (position.Z * matrix.M31) + matrix.M41,
  433. (position.X * matrix.M12) + (position.Y * matrix.M22) + (position.Z * matrix.M32) + matrix.M42,
  434. (position.X * matrix.M13) + (position.Y * matrix.M23) + (position.Z * matrix.M33) + matrix.M43,
  435. (position.X * matrix.M14) + (position.Y * matrix.M24) + (position.Z * matrix.M34) + matrix.M44);
  436. }
  437. public static void Transform(ref Vector4 vector, ref Matrix matrix, out Vector4 result)
  438. {
  439. result = new Vector4((vector.X * matrix.M11) + (vector.Y * matrix.M21) + (vector.Z * matrix.M31) + (vector.W * matrix.M41),
  440. (vector.X * matrix.M12) + (vector.Y * matrix.M22) + (vector.Z * matrix.M32) + (vector.W * matrix.M42),
  441. (vector.X * matrix.M13) + (vector.Y * matrix.M23) + (vector.Z * matrix.M33) + (vector.W * matrix.M43),
  442. (vector.X * matrix.M14) + (vector.Y * matrix.M24) + (vector.Z * matrix.M34) + (vector.W * matrix.M44));
  443. }
  444. public override string ToString()
  445. {
  446. StringBuilder sb = new StringBuilder(32);
  447. sb.Append("{X:");
  448. sb.Append(this.X);
  449. sb.Append(" Y:");
  450. sb.Append(this.Y);
  451. sb.Append(" Z:");
  452. sb.Append(this.Z);
  453. sb.Append(" W:");
  454. sb.Append(this.W);
  455. sb.Append("}");
  456. return sb.ToString();
  457. }
  458. #endregion Public Methods
  459. #region Operators
  460. public static Vector4 operator -(Vector4 value)
  461. {
  462. return new Vector4(-value.X, -value.Y, -value.Z, -value.W);
  463. }
  464. public static bool operator ==(Vector4 value1, Vector4 value2)
  465. {
  466. return value1.W == value2.W
  467. && value1.X == value2.X
  468. && value1.Y == value2.Y
  469. && value1.Z == value2.Z;
  470. }
  471. public static bool operator !=(Vector4 value1, Vector4 value2)
  472. {
  473. return !(value1 == value2);
  474. }
  475. public static Vector4 operator +(Vector4 value1, Vector4 value2)
  476. {
  477. value1.W += value2.W;
  478. value1.X += value2.X;
  479. value1.Y += value2.Y;
  480. value1.Z += value2.Z;
  481. return value1;
  482. }
  483. public static Vector4 operator -(Vector4 value1, Vector4 value2)
  484. {
  485. value1.W -= value2.W;
  486. value1.X -= value2.X;
  487. value1.Y -= value2.Y;
  488. value1.Z -= value2.Z;
  489. return value1;
  490. }
  491. public static Vector4 operator *(Vector4 value1, Vector4 value2)
  492. {
  493. value1.W *= value2.W;
  494. value1.X *= value2.X;
  495. value1.Y *= value2.Y;
  496. value1.Z *= value2.Z;
  497. return value1;
  498. }
  499. public static Vector4 operator *(Vector4 value1, float scaleFactor)
  500. {
  501. value1.W *= scaleFactor;
  502. value1.X *= scaleFactor;
  503. value1.Y *= scaleFactor;
  504. value1.Z *= scaleFactor;
  505. return value1;
  506. }
  507. public static Vector4 operator *(float scaleFactor, Vector4 value1)
  508. {
  509. value1.W *= scaleFactor;
  510. value1.X *= scaleFactor;
  511. value1.Y *= scaleFactor;
  512. value1.Z *= scaleFactor;
  513. return value1;
  514. }
  515. public static Vector4 operator /(Vector4 value1, Vector4 value2)
  516. {
  517. value1.W /= value2.W;
  518. value1.X /= value2.X;
  519. value1.Y /= value2.Y;
  520. value1.Z /= value2.Z;
  521. return value1;
  522. }
  523. public static Vector4 operator /(Vector4 value1, float divider)
  524. {
  525. float factor = 1f / divider;
  526. value1.W *= factor;
  527. value1.X *= factor;
  528. value1.Y *= factor;
  529. value1.Z *= factor;
  530. return value1;
  531. }
  532. #endregion Operators
  533. }
  534. }