Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
UInt4.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under MIT License. See LICENSE.md for details.
3 //
4 // Copyright (c) 2010-2011 SharpDX - Alexandre Mutel
5 //
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 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 // THE SOFTWARE.
23 using System;
24 using System.Globalization;
25 using System.Runtime.InteropServices;
26 using SiliconStudio.Core.Serialization;
27 
28 namespace SiliconStudio.Core.Mathematics
29 {
30  /// <summary>
31  /// Represents a four dimensional mathematical vector.
32  /// </summary>
33  [DataContract]
34  [StructLayout(LayoutKind.Sequential, Pack = 4)]
35  public struct UInt4 : IEquatable<UInt4>, IFormattable
36  {
37  /// <summary>
38  /// The size of the <see cref = "UInt4" /> type, in bytes.
39  /// </summary>
40  public static readonly int SizeInBytes = Marshal.SizeOf(typeof (UInt4));
41 
42  /// <summary>
43  /// A <see cref = "UInt4" /> with all of its components set to zero.
44  /// </summary>
45  public static readonly UInt4 Zero = new UInt4();
46 
47  /// <summary>
48  /// The X unit <see cref = "UInt4" /> (1, 0, 0, 0).
49  /// </summary>
50  public static readonly UInt4 UnitX = new UInt4(1, 0, 0, 0);
51 
52  /// <summary>
53  /// The Y unit <see cref = "UInt4" /> (0, 1, 0, 0).
54  /// </summary>
55  public static readonly UInt4 UnitY = new UInt4(0, 1, 0, 0);
56 
57  /// <summary>
58  /// The Z unit <see cref = "UInt4" /> (0, 0, 1, 0).
59  /// </summary>
60  public static readonly UInt4 UnitZ = new UInt4(0, 0, 1, 0);
61 
62  /// <summary>
63  /// The W unit <see cref = "UInt4" /> (0, 0, 0, 1).
64  /// </summary>
65  public static readonly UInt4 UnitW = new UInt4(0, 0, 0, 1);
66 
67  /// <summary>
68  /// A <see cref = "UInt4" /> with all of its components set to one.
69  /// </summary>
70  public static readonly UInt4 One = new UInt4(1, 1, 1, 1);
71 
72  /// <summary>
73  /// The X component of the vector.
74  /// </summary>
75  public uint X;
76 
77  /// <summary>
78  /// The Y component of the vector.
79  /// </summary>
80  public uint Y;
81 
82  /// <summary>
83  /// The Z component of the vector.
84  /// </summary>
85  public uint Z;
86 
87  /// <summary>
88  /// The W component of the vector.
89  /// </summary>
90  public uint W;
91 
92  /// <summary>
93  /// Initializes a new instance of the <see cref = "UInt4" /> struct.
94  /// </summary>
95  /// <param name = "value">The value that will be assigned to all components.</param>
96  public UInt4(uint value)
97  {
98  X = value;
99  Y = value;
100  Z = value;
101  W = value;
102  }
103 
104  /// <summary>
105  /// Initializes a new instance of the <see cref = "UInt4" /> struct.
106  /// </summary>
107  /// <param name = "x">Initial value for the X component of the vector.</param>
108  /// <param name = "y">Initial value for the Y component of the vector.</param>
109  /// <param name = "z">Initial value for the Z component of the vector.</param>
110  /// <param name = "w">Initial value for the W component of the vector.</param>
111  public UInt4(uint x, uint y, uint z, uint w)
112  {
113  X = x;
114  Y = y;
115  Z = z;
116  W = w;
117  }
118 
119 
120  /// <summary>
121  /// Initializes a new instance of the <see cref = "UInt4" /> struct.
122  /// </summary>
123  /// <param name = "values">The values to assign to the X, Y, Z, and W components of the vector. This must be an array with four elements.</param>
124  /// <exception cref = "ArgumentNullException">Thrown when <paramref name = "values" /> is <c>null</c>.</exception>
125  /// <exception cref = "ArgumentOutOfRangeException">Thrown when <paramref name = "values" /> contains more or less than four elements.</exception>
126  public UInt4(uint[] values)
127  {
128  if (values == null)
129  throw new ArgumentNullException("values");
130  if (values.Length != 4)
131  throw new ArgumentOutOfRangeException("values",
132  "There must be four and only four input values for UInt4.");
133 
134  X = values[0];
135  Y = values[1];
136  Z = values[2];
137  W = values[3];
138  }
139 
140  /// <summary>
141  /// Gets or sets the component at the specified index.
142  /// </summary>
143  /// <value>The value of the X, Y, Z, or W component, depending on the index.</value>
144  /// <param name = "index">The index of the component to access. Use 0 for the X component, 1 for the Y component, 2 for the Z component, and 3 for the W component.</param>
145  /// <returns>The value of the component at the specified index.</returns>
146  /// <exception cref = "System.ArgumentOutOfRangeException">Thrown when the <paramref name = "index" /> is out of the range [0, 3].</exception>
147  public uint this[uint index]
148  {
149  get
150  {
151  switch (index)
152  {
153  case 0:
154  return X;
155  case 1:
156  return Y;
157  case 2:
158  return Z;
159  case 3:
160  return W;
161  }
162 
163  throw new ArgumentOutOfRangeException("index", "Indices for UInt4 run from 0 to 3, inclusive.");
164  }
165 
166  set
167  {
168  switch (index)
169  {
170  case 0:
171  X = value;
172  break;
173  case 1:
174  Y = value;
175  break;
176  case 2:
177  Z = value;
178  break;
179  case 3:
180  W = value;
181  break;
182  default:
183  throw new ArgumentOutOfRangeException("index", "Indices for UInt4 run from 0 to 3, inclusive.");
184  }
185  }
186  }
187 
188  /// <summary>
189  /// Creates an array containing the elements of the vector.
190  /// </summary>
191  /// <returns>A four-element array containing the components of the vector.</returns>
192  public uint[] ToArray()
193  {
194  return new uint[] {X, Y, Z, W};
195  }
196 
197  /// <summary>
198  /// Adds two vectors.
199  /// </summary>
200  /// <param name = "left">The first vector to add.</param>
201  /// <param name = "right">The second vector to add.</param>
202  /// <param name = "result">When the method completes, contains the sum of the two vectors.</param>
203  public static void Add(ref UInt4 left, ref UInt4 right, out UInt4 result)
204  {
205  result = new UInt4(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
206  }
207 
208  /// <summary>
209  /// Adds two vectors.
210  /// </summary>
211  /// <param name = "left">The first vector to add.</param>
212  /// <param name = "right">The second vector to add.</param>
213  /// <returns>The sum of the two vectors.</returns>
214  public static UInt4 Add(UInt4 left, UInt4 right)
215  {
216  return new UInt4(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
217  }
218 
219  /// <summary>
220  /// Subtracts two vectors.
221  /// </summary>
222  /// <param name = "left">The first vector to subtract.</param>
223  /// <param name = "right">The second vector to subtract.</param>
224  /// <param name = "result">When the method completes, contains the difference of the two vectors.</param>
225  public static void Subtract(ref UInt4 left, ref UInt4 right, out UInt4 result)
226  {
227  result = new UInt4(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
228  }
229 
230  /// <summary>
231  /// Subtracts two vectors.
232  /// </summary>
233  /// <param name = "left">The first vector to subtract.</param>
234  /// <param name = "right">The second vector to subtract.</param>
235  /// <returns>The difference of the two vectors.</returns>
236  public static UInt4 Subtract(UInt4 left, UInt4 right)
237  {
238  return new UInt4(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
239  }
240 
241  /// <summary>
242  /// Scales a vector by the given value.
243  /// </summary>
244  /// <param name = "value">The vector to scale.</param>
245  /// <param name = "scale">The amount by which to scale the vector.</param>
246  /// <param name = "result">When the method completes, contains the scaled vector.</param>
247  public static void Multiply(ref UInt4 value, uint scale, out UInt4 result)
248  {
249  result = new UInt4(value.X*scale, value.Y*scale, value.Z*scale, value.W*scale);
250  }
251 
252  /// <summary>
253  /// Scales a vector by the given value.
254  /// </summary>
255  /// <param name = "value">The vector to scale.</param>
256  /// <param name = "scale">The amount by which to scale the vector.</param>
257  /// <returns>The scaled vector.</returns>
258  public static UInt4 Multiply(UInt4 value, uint scale)
259  {
260  return new UInt4(value.X*scale, value.Y*scale, value.Z*scale, value.W*scale);
261  }
262 
263  /// <summary>
264  /// Modulates a vector with another by performing component-wise multiplication.
265  /// </summary>
266  /// <param name = "left">The first vector to modulate.</param>
267  /// <param name = "right">The second vector to modulate.</param>
268  /// <param name = "result">When the method completes, contains the modulated vector.</param>
269  public static void Modulate(ref UInt4 left, ref UInt4 right, out UInt4 result)
270  {
271  result = new UInt4(left.X*right.X, left.Y*right.Y, left.Z*right.Z, left.W*right.W);
272  }
273 
274  /// <summary>
275  /// Modulates a vector with another by performing component-wise multiplication.
276  /// </summary>
277  /// <param name = "left">The first vector to modulate.</param>
278  /// <param name = "right">The second vector to modulate.</param>
279  /// <returns>The modulated vector.</returns>
280  public static UInt4 Modulate(UInt4 left, UInt4 right)
281  {
282  return new UInt4(left.X*right.X, left.Y*right.Y, left.Z*right.Z, left.W*right.W);
283  }
284 
285  /// <summary>
286  /// Scales a vector by the given value.
287  /// </summary>
288  /// <param name = "value">The vector to scale.</param>
289  /// <param name = "scale">The amount by which to scale the vector.</param>
290  /// <param name = "result">When the method completes, contains the scaled vector.</param>
291  public static void Divide(ref UInt4 value, uint scale, out UInt4 result)
292  {
293  result = new UInt4(value.X/scale, value.Y/scale, value.Z/scale, value.W/scale);
294  }
295 
296  /// <summary>
297  /// Scales a vector by the given value.
298  /// </summary>
299  /// <param name = "value">The vector to scale.</param>
300  /// <param name = "scale">The amount by which to scale the vector.</param>
301  /// <returns>The scaled vector.</returns>
302  public static UInt4 Divide(UInt4 value, uint scale)
303  {
304  return new UInt4(value.X/scale, value.Y/scale, value.Z/scale, value.W/scale);
305  }
306 
307  /// <summary>
308  /// Restricts a value to be within a specified range.
309  /// </summary>
310  /// <param name = "value">The value to clamp.</param>
311  /// <param name = "min">The minimum value.</param>
312  /// <param name = "max">The maximum value.</param>
313  /// <param name = "result">When the method completes, contains the clamped value.</param>
314  public static void Clamp(ref UInt4 value, ref UInt4 min, ref UInt4 max, out UInt4 result)
315  {
316  uint x = value.X;
317  x = (x > max.X) ? max.X : x;
318  x = (x < min.X) ? min.X : x;
319 
320  uint y = value.Y;
321  y = (y > max.Y) ? max.Y : y;
322  y = (y < min.Y) ? min.Y : y;
323 
324  uint z = value.Z;
325  z = (z > max.Z) ? max.Z : z;
326  z = (z < min.Z) ? min.Z : z;
327 
328  uint w = value.W;
329  w = (w > max.W) ? max.W : w;
330  w = (w < min.W) ? min.W : w;
331 
332  result = new UInt4(x, y, z, w);
333  }
334 
335  /// <summary>
336  /// Restricts a value to be within a specified range.
337  /// </summary>
338  /// <param name = "value">The value to clamp.</param>
339  /// <param name = "min">The minimum value.</param>
340  /// <param name = "max">The maximum value.</param>
341  /// <returns>The clamped value.</returns>
342  public static UInt4 Clamp(UInt4 value, UInt4 min, UInt4 max)
343  {
344  UInt4 result;
345  Clamp(ref value, ref min, ref max, out result);
346  return result;
347  }
348 
349  /// <summary>
350  /// Returns a vector containing the smallest components of the specified vectors.
351  /// </summary>
352  /// <param name = "left">The first source vector.</param>
353  /// <param name = "right">The second source vector.</param>
354  /// <param name = "result">When the method completes, contains an new vector composed of the largest components of the source vectors.</param>
355  public static void Max(ref UInt4 left, ref UInt4 right, out UInt4 result)
356  {
357  result.X = (left.X > right.X) ? left.X : right.X;
358  result.Y = (left.Y > right.Y) ? left.Y : right.Y;
359  result.Z = (left.Z > right.Z) ? left.Z : right.Z;
360  result.W = (left.W > right.W) ? left.W : right.W;
361  }
362 
363  /// <summary>
364  /// Returns a vector containing the largest components of the specified vectors.
365  /// </summary>
366  /// <param name = "left">The first source vector.</param>
367  /// <param name = "right">The second source vector.</param>
368  /// <returns>A vector containing the largest components of the source vectors.</returns>
369  public static UInt4 Max(UInt4 left, UInt4 right)
370  {
371  UInt4 result;
372  Max(ref left, ref right, out result);
373  return result;
374  }
375 
376  /// <summary>
377  /// Returns a vector containing the smallest components of the specified vectors.
378  /// </summary>
379  /// <param name = "left">The first source vector.</param>
380  /// <param name = "right">The second source vector.</param>
381  /// <param name = "result">When the method completes, contains an new vector composed of the smallest components of the source vectors.</param>
382  public static void Min(ref UInt4 left, ref UInt4 right, out UInt4 result)
383  {
384  result.X = (left.X < right.X) ? left.X : right.X;
385  result.Y = (left.Y < right.Y) ? left.Y : right.Y;
386  result.Z = (left.Z < right.Z) ? left.Z : right.Z;
387  result.W = (left.W < right.W) ? left.W : right.W;
388  }
389 
390  /// <summary>
391  /// Returns a vector containing the smallest components of the specified vectors.
392  /// </summary>
393  /// <param name = "left">The first source vector.</param>
394  /// <param name = "right">The second source vector.</param>
395  /// <returns>A vector containing the smallest components of the source vectors.</returns>
396  public static UInt4 Min(UInt4 left, UInt4 right)
397  {
398  UInt4 result;
399  Min(ref left, ref right, out result);
400  return result;
401  }
402 
403  /// <summary>
404  /// Adds two vectors.
405  /// </summary>
406  /// <param name = "left">The first vector to add.</param>
407  /// <param name = "right">The second vector to add.</param>
408  /// <returns>The sum of the two vectors.</returns>
409  public static UInt4 operator +(UInt4 left, UInt4 right)
410  {
411  return new UInt4(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
412  }
413 
414  /// <summary>
415  /// Assert a vector (return it unchanged).
416  /// </summary>
417  /// <param name = "value">The vector to assert (unchange).</param>
418  /// <returns>The asserted (unchanged) vector.</returns>
419  public static UInt4 operator +(UInt4 value)
420  {
421  return value;
422  }
423 
424  /// <summary>
425  /// Subtracts two vectors.
426  /// </summary>
427  /// <param name = "left">The first vector to subtract.</param>
428  /// <param name = "right">The second vector to subtract.</param>
429  /// <returns>The difference of the two vectors.</returns>
430  public static UInt4 operator -(UInt4 left, UInt4 right)
431  {
432  return new UInt4(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
433  }
434 
435  /// <summary>
436  /// Scales a vector by the given value.
437  /// </summary>
438  /// <param name = "value">The vector to scale.</param>
439  /// <param name = "scale">The amount by which to scale the vector.</param>
440  /// <returns>The scaled vector.</returns>
441  public static UInt4 operator *(uint scale, UInt4 value)
442  {
443  return new UInt4(value.X*scale, value.Y*scale, value.Z*scale, value.W*scale);
444  }
445 
446  /// <summary>
447  /// Scales a vector by the given value.
448  /// </summary>
449  /// <param name = "value">The vector to scale.</param>
450  /// <param name = "scale">The amount by which to scale the vector.</param>
451  /// <returns>The scaled vector.</returns>
452  public static UInt4 operator *(UInt4 value, uint scale)
453  {
454  return new UInt4(value.X*scale, value.Y*scale, value.Z*scale, value.W*scale);
455  }
456 
457  /// <summary>
458  /// Scales a vector by the given value.
459  /// </summary>
460  /// <param name = "value">The vector to scale.</param>
461  /// <param name = "scale">The amount by which to scale the vector.</param>
462  /// <returns>The scaled vector.</returns>
463  public static UInt4 operator /(UInt4 value, uint scale)
464  {
465  return new UInt4(value.X/scale, value.Y/scale, value.Z/scale, value.W/scale);
466  }
467 
468  /// <summary>
469  /// Tests for equality between two objects.
470  /// </summary>
471  /// <param name = "left">The first value to compare.</param>
472  /// <param name = "right">The second value to compare.</param>
473  /// <returns><c>true</c> if <paramref name = "left" /> has the same value as <paramref name = "right" />; otherwise, <c>false</c>.</returns>
474  public static bool operator ==(UInt4 left, UInt4 right)
475  {
476  return left.Equals(right);
477  }
478 
479  /// <summary>
480  /// Tests for inequality between two objects.
481  /// </summary>
482  /// <param name = "left">The first value to compare.</param>
483  /// <param name = "right">The second value to compare.</param>
484  /// <returns><c>true</c> if <paramref name = "left" /> has a different value than <paramref name = "right" />; otherwise, <c>false</c>.</returns>
485  public static bool operator !=(UInt4 left, UInt4 right)
486  {
487  return !left.Equals(right);
488  }
489 
490  /// <summary>
491  /// Performs an explicit conversion from <see cref = "UInt4" /> to <see cref = "Vector2" />.
492  /// </summary>
493  /// <param name = "value">The value.</param>
494  /// <returns>The result of the conversion.</returns>
495  public static explicit operator Vector2(UInt4 value)
496  {
497  return new Vector2(value.X, value.Y);
498  }
499 
500  /// <summary>
501  /// Performs an explicit conversion from <see cref = "UInt4" /> to <see cref = "Vector3" />.
502  /// </summary>
503  /// <param name = "value">The value.</param>
504  /// <returns>The result of the conversion.</returns>
505  public static explicit operator Vector3(UInt4 value)
506  {
507  return new Vector3(value.X, value.Y, value.Z);
508  }
509 
510  /// <summary>
511  /// Performs an explicit conversion from <see cref = "UInt4" /> to <see cref = "Vector4" />.
512  /// </summary>
513  /// <param name = "value">The value.</param>
514  /// <returns>The result of the conversion.</returns>
515  public static explicit operator Vector4(UInt4 value)
516  {
517  return new Vector4(value.X, value.Y, value.Z, value.W);
518  }
519 
520  /// <summary>
521  /// Returns a <see cref = "System.String" /> that represents this instance.
522  /// </summary>
523  /// <returns>
524  /// A <see cref = "System.String" /> that represents this instance.
525  /// </returns>
526  public override string ToString()
527  {
528  return string.Format(CultureInfo.CurrentCulture, "X:{0} Y:{1} Z:{2} W:{3}", X, Y, Z, W);
529  }
530 
531  /// <summary>
532  /// Returns a <see cref = "System.String" /> that represents this instance.
533  /// </summary>
534  /// <param name = "format">The format.</param>
535  /// <returns>
536  /// A <see cref = "System.String" /> that represents this instance.
537  /// </returns>
538  public string ToString(string format)
539  {
540  if (format == null)
541  return ToString();
542 
543  return string.Format(CultureInfo.CurrentCulture, "X:{0} Y:{1} Z:{2} W:{3}",
544  X.ToString(format, CultureInfo.CurrentCulture),
545  Y.ToString(format, CultureInfo.CurrentCulture),
546  Z.ToString(format, CultureInfo.CurrentCulture),
547  W.ToString(format, CultureInfo.CurrentCulture));
548  }
549 
550  /// <summary>
551  /// Returns a <see cref = "System.String" /> that represents this instance.
552  /// </summary>
553  /// <param name = "formatProvider">The format provider.</param>
554  /// <returns>
555  /// A <see cref = "System.String" /> that represents this instance.
556  /// </returns>
557  public string ToString(IFormatProvider formatProvider)
558  {
559  return string.Format(formatProvider, "X:{0} Y:{1} Z:{2} W:{3}", X, Y, Z, W);
560  }
561 
562  /// <summary>
563  /// Returns a <see cref = "System.String" /> that represents this instance.
564  /// </summary>
565  /// <param name = "format">The format.</param>
566  /// <param name = "formatProvider">The format provider.</param>
567  /// <returns>
568  /// A <see cref = "System.String" /> that represents this instance.
569  /// </returns>
570  public string ToString(string format, IFormatProvider formatProvider)
571  {
572  if (format == null)
573  ToString(formatProvider);
574 
575  return string.Format(formatProvider, "X:{0} Y:{1} Z:{2} W:{3}", X.ToString(format, formatProvider),
576  Y.ToString(format, formatProvider), Z.ToString(format, formatProvider),
577  W.ToString(format, formatProvider));
578  }
579 
580  /// <summary>
581  /// Returns a hash code for this instance.
582  /// </summary>
583  /// <returns>
584  /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
585  /// </returns>
586  public override int GetHashCode()
587  {
588  return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode() + W.GetHashCode();
589  }
590 
591  /// <summary>
592  /// Determines whether the specified <see cref = "UInt4" /> is equal to this instance.
593  /// </summary>
594  /// <param name = "other">The <see cref = "UInt4" /> to compare with this instance.</param>
595  /// <returns>
596  /// <c>true</c> if the specified <see cref = "UInt4" /> is equal to this instance; otherwise, <c>false</c>.
597  /// </returns>
598  public bool Equals(UInt4 other)
599  {
600  return other.X == X && other.Y == Y && other.Z == Z && other.W == W;
601  }
602 
603  /// <summary>
604  /// Determines whether the specified <see cref = "System.Object" /> is equal to this instance.
605  /// </summary>
606  /// <param name = "value">The <see cref = "System.Object" /> to compare with this instance.</param>
607  /// <returns>
608  /// <c>true</c> if the specified <see cref = "System.Object" /> is equal to this instance; otherwise, <c>false</c>.
609  /// </returns>
610  public override bool Equals(object value)
611  {
612  if (value == null)
613  return false;
614 
615  if (value.GetType() != GetType())
616  return false;
617 
618  return Equals((UInt4) value);
619  }
620 
621  /// <summary>
622  /// Performs an implicit conversion from <see cref="uint"/> array to <see cref="SiliconStudio.Core.Mathematics.UInt4"/>.
623  /// </summary>
624  /// <param name="input">The input.</param>
625  /// <returns>The result of the conversion.</returns>
626  public static implicit operator UInt4(uint[] input)
627  {
628  return new UInt4(input);
629  }
630 
631  /// <summary>
632  /// Performs an implicit conversion from <see cref="SiliconStudio.Core.Mathematics.UInt4"/> to <see cref="System.Int32"/> array.
633  /// </summary>
634  /// <param name="input">The input.</param>
635  /// <returns>The result of the conversion.</returns>
636  public static implicit operator uint[](UInt4 input)
637  {
638  return input.ToArray();
639  }
640  }
641 }
static void Min(ref UInt4 left, ref UInt4 right, out UInt4 result)
Returns a vector containing the smallest components of the specified vectors.
Definition: UInt4.cs:382
static UInt4 Clamp(UInt4 value, UInt4 min, UInt4 max)
Restricts a value to be within a specified range.
Definition: UInt4.cs:342
SiliconStudio.Paradox.Games.Mathematics.Vector2 Vector2
FbxDouble3 operator*(double factor, FbxDouble3 vector)
string ToString(string format, IFormatProvider formatProvider)
Returns a System.String that represents this instance.
Definition: UInt4.cs:570
static void Modulate(ref UInt4 left, ref UInt4 right, out UInt4 result)
Modulates a vector with another by performing component-wise multiplication.
Definition: UInt4.cs:269
uint X
The X component of the vector.
Definition: UInt4.cs:75
static UInt4 Divide(UInt4 value, uint scale)
Scales a vector by the given value.
Definition: UInt4.cs:302
static UInt4 Add(UInt4 left, UInt4 right)
Adds two vectors.
Definition: UInt4.cs:214
static void Divide(ref UInt4 value, uint scale, out UInt4 result)
Scales a vector by the given value.
Definition: UInt4.cs:291
static void Max(ref UInt4 left, ref UInt4 right, out UInt4 result)
Returns a vector containing the smallest components of the specified vectors.
Definition: UInt4.cs:355
override bool Equals(object value)
Determines whether the specified System.Object is equal to this instance.
Definition: UInt4.cs:610
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t y
Definition: DirectXTexP.h:191
uint Z
The Z component of the vector.
Definition: UInt4.cs:85
static void Subtract(ref UInt4 left, ref UInt4 right, out UInt4 result)
Subtracts two vectors.
Definition: UInt4.cs:225
override string ToString()
Returns a System.String that represents this instance.
Definition: UInt4.cs:526
UInt4(uint[] values)
Initializes a new instance of the UInt4 struct.
Definition: UInt4.cs:126
static void Multiply(ref UInt4 value, uint scale, out UInt4 result)
Scales a vector by the given value.
Definition: UInt4.cs:247
bool Equals(UInt4 other)
Determines whether the specified UInt4 is equal to this instance.
Definition: UInt4.cs:598
UInt4(uint x, uint y, uint z, uint w)
Initializes a new instance of the UInt4 struct.
Definition: UInt4.cs:111
Represents a four dimensional mathematical vector.
Definition: Vector4.cs:42
uint[] ToArray()
Creates an array containing the elements of the vector.
Definition: UInt4.cs:192
static UInt4 Max(UInt4 left, UInt4 right)
Returns a vector containing the largest components of the specified vectors.
Definition: UInt4.cs:369
override int GetHashCode()
Returns a hash code for this instance.
Definition: UInt4.cs:586
string ToString(IFormatProvider formatProvider)
Returns a System.String that represents this instance.
Definition: UInt4.cs:557
static void Clamp(ref UInt4 value, ref UInt4 min, ref UInt4 max, out UInt4 result)
Restricts a value to be within a specified range.
Definition: UInt4.cs:314
static UInt4 Min(UInt4 left, UInt4 right)
Returns a vector containing the smallest components of the specified vectors.
Definition: UInt4.cs:396
static void Add(ref UInt4 left, ref UInt4 right, out UInt4 result)
Adds two vectors.
Definition: UInt4.cs:203
UInt4(uint value)
Initializes a new instance of the UInt4 struct.
Definition: UInt4.cs:96
SiliconStudio.Core.Mathematics.Vector3 Vector3
_In_ size_t _In_ size_t _In_ DXGI_FORMAT format
Definition: DirectXTexP.h:175
static UInt4 Subtract(UInt4 left, UInt4 right)
Subtracts two vectors.
Definition: UInt4.cs:236
Represents a four dimensional mathematical vector.
Definition: UInt4.cs:35
uint Y
The Y component of the vector.
Definition: UInt4.cs:80
uint W
The W component of the vector.
Definition: UInt4.cs:90
static UInt4 Multiply(UInt4 value, uint scale)
Scales a vector by the given value.
Definition: UInt4.cs:258
static UInt4 Modulate(UInt4 left, UInt4 right)
Modulates a vector with another by performing component-wise multiplication.
Definition: UInt4.cs:280
string ToString(string format)
Returns a System.String that represents this instance.
Definition: UInt4.cs:538
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t size_t z
Definition: DirectXTexP.h:191