From e187ed5a181b61e0199ef9479c2725389df502cd Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Fri, 13 Feb 2009 19:51:35 +0000 Subject: [PATCH] Added Xy and Xyz swizzle operators. --- Source/OpenTK/Math/Vector3.cs | 9 +++++++++ Source/OpenTK/Math/Vector3d.cs | Bin 81058 -> 81648 bytes Source/OpenTK/Math/Vector3h.cs | 9 +++++++++ Source/OpenTK/Math/Vector4.cs | 6 ++++++ Source/OpenTK/Math/Vector4d.cs | 14 ++++++++++++++ Source/OpenTK/Math/Vector4h.cs | 14 ++++++++++++++ 6 files changed, 52 insertions(+) diff --git a/Source/OpenTK/Math/Vector3.cs b/Source/OpenTK/Math/Vector3.cs index 04ad3fc3..8d60d20a 100644 --- a/Source/OpenTK/Math/Vector3.cs +++ b/Source/OpenTK/Math/Vector3.cs @@ -1004,6 +1004,15 @@ namespace OpenTK.Math #endregion + #region Swizzle + + /// + /// Gets or sets an OpenTK.Math.Vector2 with the X and Y components of this instance. + /// + public Vector2 Xy { get { return new Vector2(X, Y); } set { X = value.X; Y = value.Y; } } + + #endregion + #region Operators public static Vector3 operator +(Vector3 left, Vector3 right) diff --git a/Source/OpenTK/Math/Vector3d.cs b/Source/OpenTK/Math/Vector3d.cs index 0bb65b4694f06110eca6f9e83af27ba24e8acdfd..e70ce1884c1a6a1e8bd7a114227333eadc00760d 100644 GIT binary patch delta 239 zcmZ4VljXx-mWC~iA#&Wo4CM@&3{^mwGx?*0^yCY6W|KeYaS7)$6fr0;6f>kUlmJNu zhD3(E$%UMf(>b&m`528R3$}>!MnHraQh;>i!l21u4Ww&<7-BO-2go8@AT9&C gB8QN2Oa + /// Gets or sets an OpenTK.Math.Vector2h with the X and Y components of this instance. + /// + public Vector2h Xy { get { return new Vector2h(X, Y); } set { X = value.X; Y = value.Y; } } + + #endregion + #region Half -> Single /// diff --git a/Source/OpenTK/Math/Vector4.cs b/Source/OpenTK/Math/Vector4.cs index f3f09e81..893a7977 100644 --- a/Source/OpenTK/Math/Vector4.cs +++ b/Source/OpenTK/Math/Vector4.cs @@ -827,8 +827,14 @@ namespace OpenTK.Math #region Swizzle + /// + /// Gets or sets an OpenTK.Math.Vector2 with the X and Y components of this instance. + /// public Vector2 Xy { get { return new Vector2(X, Y); } set { X = value.X; Y = value.Y; } } + /// + /// Gets or sets an OpenTK.Math.Vector3 with the X, Y and Z components of this instance. + /// public Vector3 Xyz { get { return new Vector3(X, Y, Z); } set { X = value.X; Y = value.Y; Z = value.Z; } } #endregion diff --git a/Source/OpenTK/Math/Vector4d.cs b/Source/OpenTK/Math/Vector4d.cs index 76a253a8..b1914c7a 100644 --- a/Source/OpenTK/Math/Vector4d.cs +++ b/Source/OpenTK/Math/Vector4d.cs @@ -822,6 +822,20 @@ namespace OpenTK.Math #endregion + #region Swizzle + + /// + /// Gets or sets an OpenTK.Math.Vector2d with the X and Y components of this instance. + /// + public Vector2d Xy { get { return new Vector2d(X, Y); } set { X = value.X; Y = value.Y; } } + + /// + /// Gets or sets an OpenTK.Math.Vector3d with the X, Y and Z components of this instance. + /// + public Vector3d Xyz { get { return new Vector3d(X, Y, Z); } set { X = value.X; Y = value.Y; Z = value.Z; } } + + #endregion + #region Operators public static Vector4d operator +(Vector4d left, Vector4d right) diff --git a/Source/OpenTK/Math/Vector4h.cs b/Source/OpenTK/Math/Vector4h.cs index 7bd6198c..83c0e550 100644 --- a/Source/OpenTK/Math/Vector4h.cs +++ b/Source/OpenTK/Math/Vector4h.cs @@ -206,6 +206,20 @@ namespace OpenTK.Math #endregion Constructors + #region Swizzle + + /// + /// Gets or sets an OpenTK.Math.Vector2h with the X and Y components of this instance. + /// + public Vector2h Xy { get { return new Vector2h(X, Y); } set { X = value.X; Y = value.Y; } } + + /// + /// Gets or sets an OpenTK.Math.Vector3h with the X, Y and Z components of this instance. + /// + public Vector3h Xyz { get { return new Vector3h(X, Y, Z); } set { X = value.X; Y = value.Y; Z = value.Z; } } + + #endregion + #region Half -> Single ///