24 using System.Globalization;
25 using System.Runtime.InteropServices;
26 using SiliconStudio.Core.Serialization;
28 namespace SiliconStudio.Core.Mathematics
34 [StructLayout(LayoutKind.Sequential, Pack = 4)]
40 public static readonly
int SizeInBytes = Marshal.SizeOf(typeof (
UInt4));
50 public static readonly
UInt4 UnitX =
new UInt4(1, 0, 0, 0);
55 public static readonly
UInt4 UnitY =
new UInt4(0, 1, 0, 0);
60 public static readonly
UInt4 UnitZ =
new UInt4(0, 0, 1, 0);
65 public static readonly
UInt4 UnitW =
new UInt4(0, 0, 0, 1);
70 public static readonly
UInt4 One =
new UInt4(1, 1, 1, 1);
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.");
147 public uint
this[uint index]
163 throw new ArgumentOutOfRangeException(
"index",
"Indices for UInt4 run from 0 to 3, inclusive.");
183 throw new ArgumentOutOfRangeException(
"index",
"Indices for UInt4 run from 0 to 3, inclusive.");
194 return new uint[] {X, Y, Z, W};
205 result =
new UInt4(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
216 return new UInt4(left.
X + right.
X, left.
Y + right.
Y, left.
Z + right.
Z, left.
W + right.
W);
227 result =
new UInt4(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
238 return new UInt4(left.
X - right.
X, left.
Y - right.
Y, left.
Z - right.
Z, left.
W - right.
W);
249 result =
new UInt4(value.X*scale, value.Y*scale, value.Z*scale, value.W*scale);
260 return new UInt4(value.
X*scale, value.
Y*scale, value.
Z*scale, value.
W*scale);
271 result =
new UInt4(left.X*right.X, left.Y*right.Y, left.Z*right.Z, left.W*right.W);
282 return new UInt4(left.
X*right.
X, left.
Y*right.
Y, left.
Z*right.
Z, left.
W*right.
W);
293 result =
new UInt4(value.X/scale, value.Y/scale, value.Z/scale, value.W/scale);
304 return new UInt4(value.
X/scale, value.
Y/scale, value.
Z/scale, value.
W/scale);
317 x = (x > max.X) ? max.X : x;
318 x = (x < min.X) ? min.X : x;
321 y = (y > max.Y) ? max.Y : y;
322 y = (y < min.Y) ? min.Y :
y;
325 z = (z > max.Z) ? max.Z : z;
326 z = (z < min.Z) ? min.Z :
z;
329 w = (w > max.W) ? max.W : w;
330 w = (w < min.W) ? min.W : w;
332 result =
new UInt4(x, y, z, w);
345 Clamp(ref value, ref min, ref max, out result);
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;
372 Max(ref left, ref right, out result);
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;
399 Min(ref left, ref right, out result);
411 return new UInt4(left.
X + right.
X, left.
Y + right.
Y, left.
Z + right.
Z, left.
W + right.
W);
432 return new UInt4(left.
X - right.
X, left.
Y - right.
Y, left.
Z - right.
Z, left.
W - right.
W);
443 return new UInt4(value.
X*scale, value.
Y*scale, value.
Z*scale, value.
W*scale);
454 return new UInt4(value.
X*scale, value.
Y*scale, value.
Z*scale, value.
W*scale);
465 return new UInt4(value.
X/scale, value.
Y/scale, value.
Z/scale, value.
W/scale);
476 return left.Equals(right);
487 return !left.Equals(right);
507 return new Vector3(value.
X, value.
Y, value.
Z);
517 return new Vector4(value.
X, value.
Y, value.
Z, value.
W);
528 return string.Format(CultureInfo.CurrentCulture,
"X:{0} Y:{1} Z:{2} W:{3}", X, Y, Z, W);
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));
557 public string ToString(IFormatProvider formatProvider)
559 return string.Format(formatProvider,
"X:{0} Y:{1} Z:{2} W:{3}", X, Y, Z, W);
573 ToString(formatProvider);
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));
588 return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode() + W.GetHashCode();
600 return other.X == X && other.Y == Y && other.Z == Z && other.W == W;
610 public override bool Equals(
object value)
615 if (value.GetType() != GetType())
618 return Equals((
UInt4) value);
626 public static implicit
operator UInt4(uint[] input)
628 return new UInt4(input);
636 public static implicit
operator uint[](
UInt4 input)
638 return input.ToArray();
static void Min(ref UInt4 left, ref UInt4 right, out UInt4 result)
Returns a vector containing the smallest components of the specified vectors.
static UInt4 Clamp(UInt4 value, UInt4 min, UInt4 max)
Restricts a value to be within a specified range.
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.
static void Modulate(ref UInt4 left, ref UInt4 right, out UInt4 result)
Modulates a vector with another by performing component-wise multiplication.
uint X
The X component of the vector.
static UInt4 Divide(UInt4 value, uint scale)
Scales a vector by the given value.
static UInt4 Add(UInt4 left, UInt4 right)
Adds two vectors.
static void Divide(ref UInt4 value, uint scale, out UInt4 result)
Scales a vector by the given value.
static void Max(ref UInt4 left, ref UInt4 right, out UInt4 result)
Returns a vector containing the smallest components of the specified vectors.
override bool Equals(object value)
Determines whether the specified System.Object is equal to this instance.
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t y
uint Z
The Z component of the vector.
static void Subtract(ref UInt4 left, ref UInt4 right, out UInt4 result)
Subtracts two vectors.
override string ToString()
Returns a System.String that represents this instance.
UInt4(uint[] values)
Initializes a new instance of the UInt4 struct.
static void Multiply(ref UInt4 value, uint scale, out UInt4 result)
Scales a vector by the given value.
bool Equals(UInt4 other)
Determines whether the specified UInt4 is equal to this instance.
UInt4(uint x, uint y, uint z, uint w)
Initializes a new instance of the UInt4 struct.
Represents a four dimensional mathematical vector.
uint[] ToArray()
Creates an array containing the elements of the vector.
static UInt4 Max(UInt4 left, UInt4 right)
Returns a vector containing the largest components of the specified vectors.
override int GetHashCode()
Returns a hash code for this instance.
string ToString(IFormatProvider formatProvider)
Returns a System.String that represents this instance.
static void Clamp(ref UInt4 value, ref UInt4 min, ref UInt4 max, out UInt4 result)
Restricts a value to be within a specified range.
static UInt4 Min(UInt4 left, UInt4 right)
Returns a vector containing the smallest components of the specified vectors.
static void Add(ref UInt4 left, ref UInt4 right, out UInt4 result)
Adds two vectors.
UInt4(uint value)
Initializes a new instance of the UInt4 struct.
SiliconStudio.Core.Mathematics.Vector3 Vector3
_In_ size_t _In_ size_t _In_ DXGI_FORMAT format
static UInt4 Subtract(UInt4 left, UInt4 right)
Subtracts two vectors.
Represents a four dimensional mathematical vector.
uint Y
The Y component of the vector.
uint W
The W component of the vector.
static UInt4 Multiply(UInt4 value, uint scale)
Scales a vector by the given value.
static UInt4 Modulate(UInt4 left, UInt4 right)
Modulates a vector with another by performing component-wise multiplication.
string ToString(string format)
Returns a System.String that represents this instance.
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t size_t z