24 using System.Globalization;
25 using System.Runtime.InteropServices;
27 namespace SiliconStudio.Core.Mathematics
32 [DataContract(
"Int4")]
34 [StructLayout(LayoutKind.Sequential, Pack = 4)]
40 public static readonly
int SizeInBytes = Marshal.SizeOf(typeof (
Int4));
50 public static readonly
Int4 UnitX =
new Int4(1, 0, 0, 0);
55 public static readonly
Int4 UnitY =
new Int4(0, 1, 0, 0);
60 public static readonly
Int4 UnitZ =
new Int4(0, 0, 1, 0);
65 public static readonly
Int4 UnitW =
new Int4(0, 0, 0, 1);
70 public static readonly
Int4 One =
new Int4(1, 1, 1, 1);
134 throw new ArgumentNullException(
"values");
135 if (values.Length != 4)
136 throw new ArgumentOutOfRangeException(
"values",
137 "There must be four and only four input values for Int4.");
152 public int this[
int index]
168 throw new ArgumentOutOfRangeException(
"index",
"Indices for Int4 run from 0 to 3, inclusive.");
188 throw new ArgumentOutOfRangeException(
"index",
"Indices for Int4 run from 0 to 3, inclusive.");
199 return new int[] {X, Y, Z, W};
210 result =
new Int4(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
221 return new Int4(left.
X + right.
X, left.
Y + right.
Y, left.
Z + right.
Z, left.
W + right.
W);
232 result =
new Int4(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
243 return new Int4(left.
X - right.
X, left.
Y - right.
Y, left.
Z - right.
Z, left.
W - right.
W);
254 result =
new Int4(value.X*scale, value.Y*scale, value.Z*scale, value.W*scale);
265 return new Int4(value.
X*scale, value.
Y*scale, value.
Z*scale, value.
W*scale);
276 result =
new Int4(left.X*right.X, left.Y*right.Y, left.Z*right.Z, left.W*right.W);
287 return new Int4(left.
X*right.
X, left.
Y*right.
Y, left.
Z*right.
Z, left.
W*right.
W);
298 result =
new Int4(value.X/scale, value.Y/scale, value.Z/scale, value.W/scale);
309 return new Int4(value.
X/scale, value.
Y/scale, value.
Z/scale, value.
W/scale);
319 result =
new Int4(-value.X, -value.Y, -value.Z, -value.W);
329 return new Int4(-value.
X, -value.
Y, -value.
Z, -value.
W);
342 x = (x > max.X) ? max.X : x;
343 x = (x < min.X) ? min.X : x;
346 y = (y > max.Y) ? max.Y : y;
347 y = (y < min.Y) ? min.Y :
y;
350 z = (z > max.Z) ? max.Z : z;
351 z = (z < min.Z) ? min.Z :
z;
354 w = (w > max.W) ? max.W : w;
355 w = (w < min.W) ? min.W : w;
357 result =
new Int4(x, y, z, w);
370 Clamp(ref value, ref min, ref max, out result);
382 result.X = (left.X > right.X) ? left.X : right.X;
383 result.Y = (left.Y > right.Y) ? left.Y : right.Y;
384 result.Z = (left.Z > right.Z) ? left.Z : right.Z;
385 result.W = (left.W > right.W) ? left.W : right.W;
397 Max(ref left, ref right, out result);
409 result.X = (left.X < right.X) ? left.X : right.X;
410 result.Y = (left.Y < right.Y) ? left.Y : right.Y;
411 result.Z = (left.Z < right.Z) ? left.Z : right.Z;
412 result.W = (left.W < right.W) ? left.W : right.W;
424 Min(ref left, ref right, out result);
436 return new Int4(left.
X + right.
X, left.
Y + right.
Y, left.
Z + right.
Z, left.
W + right.
W);
457 return new Int4(left.
X - right.
X, left.
Y - right.
Y, left.
Z - right.
Z, left.
W - right.
W);
467 return new Int4(-value.
X, -value.
Y, -value.
Z, -value.
W);
478 return new Int4(value.
X*scale, value.
Y*scale, value.
Z*scale, value.
W*scale);
489 return new Int4(value.
X*scale, value.
Y*scale, value.
Z*scale, value.
W*scale);
498 public static Int4 operator /(
Int4 value,
int scale)
500 return new Int4(value.
X/scale, value.
Y/scale, value.
Z/scale, value.
W/scale);
509 public static bool operator ==(
Int4 left,
Int4 right)
511 return left.Equals(right);
520 public static bool operator !=(
Int4 left,
Int4 right)
522 return !left.Equals(right);
542 return new Vector3(value.
X, value.
Y, value.
Z);
552 return new Vector4(value.
X, value.
Y, value.
Z, value.
W);
563 return string.Format(CultureInfo.CurrentCulture,
"X:{0} Y:{1} Z:{2} W:{3}", X, Y, Z, W);
578 return string.Format(CultureInfo.CurrentCulture,
"X:{0} Y:{1} Z:{2} W:{3}",
579 X.ToString(
format, CultureInfo.CurrentCulture),
580 Y.ToString(format, CultureInfo.CurrentCulture),
581 Z.ToString(
format, CultureInfo.CurrentCulture),
582 W.ToString(format, CultureInfo.CurrentCulture));
592 public string ToString(IFormatProvider formatProvider)
594 return string.Format(formatProvider,
"X:{0} Y:{1} Z:{2} W:{3}", X, Y, Z, W);
608 ToString(formatProvider);
610 return string.Format(formatProvider,
"X:{0} Y:{1} Z:{2} W:{3}", X.ToString(
format, formatProvider),
611 Y.ToString(format, formatProvider), Z.ToString(
format, formatProvider),
612 W.ToString(format, formatProvider));
623 return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode() + W.GetHashCode();
635 return other.X == X && other.Y == Y && other.Z == Z && other.W == W;
645 public override bool Equals(
object value)
650 if (value.GetType() != GetType())
653 return Equals((
Int4) value);
661 public static implicit
operator Int4(
int[] input)
663 return new Int4(input);
671 public static implicit
operator int[](
Int4 input)
673 return input.ToArray();
SiliconStudio.Paradox.Games.Mathematics.Vector2 Vector2
FbxDouble3 operator*(double factor, FbxDouble3 vector)
bool Equals(Int4 other)
Determines whether the specified Int4 is equal to this instance.
static void Clamp(ref Int4 value, ref Int4 min, ref Int4 max, out Int4 result)
Restricts a value to be within a specified range.
static Int4 Clamp(Int4 value, Int4 min, Int4 max)
Restricts a value to be within a specified range.
Int4(int x, int y, int z, int w)
Initializes a new instance of the Int4 struct.
string ToString(IFormatProvider formatProvider)
Returns a System.String that represents this instance.
Int4(int[] values)
Initializes a new instance of the Int4 struct.
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t y
static void Subtract(ref Int4 left, ref Int4 right, out Int4 result)
Subtracts two vectors.
static Int4 Divide(Int4 value, int scale)
Scales a vector by the given value.
static void Modulate(ref Int4 left, ref Int4 right, out Int4 result)
Modulates a vector with another by performing component-wise multiplication.
static void Multiply(ref Int4 value, int scale, out Int4 result)
Scales a vector by the given value.
static void Min(ref Int4 left, ref Int4 right, out Int4 result)
Returns a vector containing the smallest components of the specified vectors.
static Int4 Max(Int4 left, Int4 right)
Returns a vector containing the largest components of the specified vectors.
static void Negate(ref Int4 value, out Int4 result)
Reverses the direction of a given vector.
override bool Equals(object value)
Determines whether the specified System.Object is equal to this instance.
Represents a four dimensional mathematical vector.
static void Divide(ref Int4 value, int scale, out Int4 result)
Scales a vector by the given value.
static Int4 Min(Int4 left, Int4 right)
Returns a vector containing the smallest components of the specified vectors.
static Int4 Negate(Int4 value)
Reverses the direction of a given vector.
Represents a four dimensional mathematical vector.
static Int4 Add(Int4 left, Int4 right)
Adds two vectors.
override int GetHashCode()
Returns a hash code for this instance.
static void Add(ref Int4 left, ref Int4 right, out Int4 result)
Adds two vectors.
int Y
The Y component of the vector.
int X
The X component of the vector.
string ToString(string format)
Returns a System.String that represents this instance.
string ToString(string format, IFormatProvider formatProvider)
Returns a System.String that represents this instance.
SiliconStudio.Core.Mathematics.Vector3 Vector3
_In_ size_t _In_ size_t _In_ DXGI_FORMAT format
static void Max(ref Int4 left, ref Int4 right, out Int4 result)
Returns a vector containing the smallest components of the specified vectors.
int[] ToArray()
Creates an array containing the elements of the vector.
Int4(int value)
Initializes a new instance of the Int4 struct.
override string ToString()
Returns a System.String that represents this instance.
static Int4 Multiply(Int4 value, int scale)
Scales a vector by the given value.
static Int4 Subtract(Int4 left, Int4 right)
Subtracts two vectors.
int Z
The Z component of the vector.
int W
The W component of the vector.
static Int4 Modulate(Int4 left, Int4 right)
Modulates a vector with another by performing component-wise multiplication.
DataStyle
Specifies the style used for textual serialization when an array/list or a dictionary/map must be ser...
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t size_t z