#region --- License ---
/*
Copyright (c) 2006 - 2008 The Open Toolkit library.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#endregion
using System;
using System.Runtime.InteropServices;
namespace OpenTK
{
/// Represents a 2D vector using two 32-bit integer values.
///
/// The Vector2i structure is suitable for interoperation with unmanaged code requiring two consecutive integers.
///
[Serializable]
public struct Vector2i : IEquatable
{
#region Fields
///
/// The X component of the Vector2i.
///
public int X;
///
/// The Y component of the Vector2i.
///
public int Y;
#endregion
#region Constructors
///
/// Constructs a new Vector2i.
///
/// The x coordinate of the net Vector2i.
/// The y coordinate of the net Vector2i.
public Vector2i(int x, int y)
{
X = x;
Y = y;
}
#endregion
#region Static Fields
///
/// Defines a unit-length Vector2i that points towards the X-axis.
///
public static readonly Vector2i UnitX = new Vector2i(1, 0);
///
/// Defines a unit-length Vector2i that points towards the Y-axis.
///
public static readonly Vector2i UnitY = new Vector2i(0, 1);
///
/// Defines a zero-length Vector2i.
///
public static readonly Vector2i Zero = new Vector2i(0, 0);
///
/// Defines an instance with all components set to 1.
///
public static readonly Vector2i One = new Vector2i(1, 1);
///
/// Defines the size of the Vector2i struct in bytes.
///
public static readonly int SizeInBytes = Marshal.SizeOf(new Vector2i());
#endregion
#region Overrides
#region public override string ToString()
///
/// Returns a System.String that represents the current Vector2i.
///
///
public override string ToString()
{
return String.Format("({0}, {1})", X, Y);
}
#endregion
#region public override int GetHashCode()
///
/// Returns the hashcode for this instance.
///
/// A System.Int32 containing the unique hashcode for this instance.
public override int GetHashCode()
{
return X.GetHashCode() ^ Y.GetHashCode();
}
#endregion
#region public override bool Equals(object obj)
///
/// Indicates whether this instance and a specified object are equal.
///
/// The object to compare to.
/// True if the instances are equal; false otherwise.
public override bool Equals(object obj)
{
if (!(obj is Vector2i))
return false;
return this.Equals((Vector2i)obj);
}
#endregion
#endregion
#region IEquatable Members
/// Indicates whether the current vector is equal to another vector.
/// A vector to compare with this vector.
/// true if the current vector is equal to the vector parameter; otherwise, false.
public bool Equals(Vector2i other)
{
return
X == other.X &&
Y == other.Y;
}
#endregion
}
/// Represents a 2D vector using two 32-bit unsigned integer values.
///
/// The Vector2ui structure is suitable for interoperation with unmanaged code requiring two consecutive unsigned integers.
///
[Serializable]
public struct Vector2ui : IEquatable
{
#region Fields
///
/// The X component of the Vector2ui.
///
public uint X;
///
/// The Y component of the Vector2ui.
///
public uint Y;
#endregion
#region Constructors
///
/// Constructs a new Vector2ui.
///
/// The x coordinate of the net Vector2ui.
/// The y coordinate of the net Vector2ui.
public Vector2ui(uint x, uint y)
{
X = x;
Y = y;
}
#endregion
#region Static Fields
///
/// Defines a unit-length Vector2ui that points towards the X-axis.
///
public static readonly Vector2ui UnitX = new Vector2ui(1, 0);
///
/// Defines a unit-length Vector2ui that points towards the Y-axis.
///
public static readonly Vector2ui UnitY = new Vector2ui(0, 1);
///
/// Defines a zero-length Vector2ui.
///
public static readonly Vector2ui Zero = new Vector2ui(0, 0);
///
/// Defines an instance with all components set to 1.
///
public static readonly Vector2ui One = new Vector2ui(1, 1);
///
/// Defines the size of the Vector2ui struct in bytes.
///
public static readonly int SizeInBytes = Marshal.SizeOf(new Vector2ui());
#endregion
#region Overrides
#region public override string ToString()
///
/// Returns a System.String that represents the current Vector2ui.
///
///
public override string ToString()
{
return String.Format("({0}, {1})", X, Y);
}
#endregion
#region public override int GetHashCode()
///
/// Returns the hashcode for this instance.
///
/// A System.Int32 containing the unique hashcode for this instance.
public override int GetHashCode()
{
return X.GetHashCode() ^ Y.GetHashCode();
}
#endregion
#region public override bool Equals(object obj)
///
/// Indicates whether this instance and a specified object are equal.
///
/// The object to compare to.
/// True if the instances are equal; false otherwise.
public override bool Equals(object obj)
{
if (!(obj is Vector2ui))
return false;
return this.Equals((Vector2ui)obj);
}
#endregion
#endregion
#region IEquatable Members
/// Indicates whether the current vector is equal to another vector.
/// A vector to compare with this vector.
/// true if the current vector is equal to the vector parameter; otherwise, false.
public bool Equals(Vector2ui other)
{
return
X == other.X &&
Y == other.Y;
}
#endregion
}
/// Represents a 3D vector using three 32-bit integer values.
///
/// The Vector3i structure is suitable for interoperation with unmanaged code requiring three consecutive integers.
///
[Serializable]
public struct Vector3i : IEquatable
{
#region Fields
///
/// The X component of the Vector3i.
///
public int X;
///
/// The Y component of the Vector3i.
///
public int Y;
///
/// The Z component of the Vector3i.
///
public int Z;
#endregion
#region Constructors
///
/// Constructs a new Vector3i.
///
/// The x coordinate of the net Vector3i.
/// The y coordinate of the net Vector3i.
/// The z coordinate of the net Vector3i.
public Vector3i(int x, int y, int z)
{
X = x;
Y = y;
Z = z;
}
#endregion
#region Static Fields
///
/// Defines a unit-length Vector3i that points towards the X-axis.
///
public static readonly Vector3i UnitX = new Vector3i(1, 0, 0);
///
/// Defines a unit-length Vector3i that points towards the Y-axis.
///
public static readonly Vector3i UnitY = new Vector3i(0, 1, 0);
///
/// Defines a unit-length Vector3i that points towards the Z-axis.
///
public static readonly Vector3i UnitZ = new Vector3i(0, 0, 1);
///
/// Defines a zero-length Vector3i.
///
public static readonly Vector3i Zero = new Vector3i(0, 0, 0);
///
/// Defines an instance with all components set to 1.
///
public static readonly Vector3i One = new Vector3i(1, 1, 1);
///
/// Defines the size of the Vector3i struct in bytes.
///
public static readonly int SizeInBytes = Marshal.SizeOf(new Vector3i());
#endregion
#region Overrides
#region public override string ToString()
///
/// Returns a System.String that represents the current Vector3i.
///
///
public override string ToString()
{
return String.Format("({0}, {1}, {2})", X, Y, Z);
}
#endregion
#region public override int GetHashCode()
///
/// Returns the hashcode for this instance.
///
/// A System.Int32 containing the unique hashcode for this instance.
public override int GetHashCode()
{
return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode();
}
#endregion
#region public override bool Equals(object obj)
///
/// Indicates whether this instance and a specified object are equal.
///
/// The object to compare to.
/// True if the instances are equal; false otherwise.
public override bool Equals(object obj)
{
if (!(obj is Vector3i))
return false;
return this.Equals((Vector3i)obj);
}
#endregion
#endregion
#region IEquatable Members
/// Indicates whether the current vector is equal to another vector.
/// A vector to compare with this vector.
/// true if the current vector is equal to the vector parameter; otherwise, false.
public bool Equals(Vector3i other)
{
return
X == other.X &&
Y == other.Y &&
Z == other.Z;
}
#endregion
}
/// Represents a 3D vector using three 32-bit unsigned integer values.
///
/// The Vector3ui structure is suitable for interoperation with unmanaged code requiring three consecutive unsigned integers.
///
[Serializable]
public struct Vector3ui : IEquatable
{
#region Fields
///
/// The X component of the Vector3ui.
///
public uint X;
///
/// The Y component of the Vector3ui.
///
public uint Y;
///
/// The Z component of the Vector3ui.
///
public uint Z;
#endregion
#region Constructors
///
/// Constructs a new Vector3ui.
///
/// The x coordinate of the net Vector3ui.
/// The y coordinate of the net Vector3ui.
/// The z coordinate of the net Vector3ui.
public Vector3ui(uint x, uint y, uint z)
{
X = x;
Y = y;
Z = z;
}
#endregion
#region Static Fields
///
/// Defines a unit-length Vector3ui that points towards the X-axis.
///
public static readonly Vector3ui UnitX = new Vector3ui(1, 0, 0);
///
/// Defines a unit-length Vector3ui that points towards the Y-axis.
///
public static readonly Vector3ui UnitY = new Vector3ui(0, 1, 0);
///
/// Defines a unit-length Vector3ui that points towards the Z-axis.
///
public static readonly Vector3ui UnitZ = new Vector3ui(0, 0, 1);
///
/// Defines a zero-length Vector3ui.
///
public static readonly Vector3ui Zero = new Vector3ui(0, 0, 0);
///
/// Defines an instance with all components set to 1.
///
public static readonly Vector3ui One = new Vector3ui(1, 1, 1);
///
/// Defines the size of the Vector3ui struct in bytes.
///
public static readonly int SizeInBytes = Marshal.SizeOf(new Vector3ui());
#endregion
#region Overrides
#region public override string ToString()
///
/// Returns a System.String that represents the current Vector3ui.
///
///
public override string ToString()
{
return String.Format("({0}, {1}, {2})", X, Y, Z);
}
#endregion
#region public override int GetHashCode()
///
/// Returns the hashcode for this instance.
///
/// A System.Int32 containing the unique hashcode for this instance.
public override int GetHashCode()
{
return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode();
}
#endregion
#region public override bool Equals(object obj)
///
/// Indicates whether this instance and a specified object are equal.
///
/// The object to compare to.
/// True if the instances are equal; false otherwise.
public override bool Equals(object obj)
{
if (!(obj is Vector3ui))
return false;
return this.Equals((Vector3ui)obj);
}
#endregion
#endregion
#region IEquatable Members
/// Indicates whether the current vector is equal to another vector.
/// A vector to compare with this vector.
/// true if the current vector is equal to the vector parameter; otherwise, false.
public bool Equals(Vector3ui other)
{
return
X == other.X &&
Y == other.Y &&
Z == other.Z;
}
#endregion
}
/// Represents a 4D vector using four 32-bit integer values.
///
/// The Vector4i structure is suitable for interoperation with unmanaged code requiring four consecutive integers.
///
[Serializable]
public struct Vector4i : IEquatable
{
#region Fields
///
/// The X component of the Vector4i.
///
public int X;
///
/// The Y component of the Vector4i.
///
public int Y;
///
/// The Z component of the Vector4i.
///
public int Z;
///
/// The W component of the Vector4i.
///
public int W;
#endregion
#region Constructors
///
/// Constructs a new Vector4i.
///
/// The x coordinate of the net Vector4i.
/// The y coordinate of the net Vector4i.
/// The z coordinate of the net Vector4i.
/// The w coordinate of the net Vector4i.
public Vector4i(int x, int y, int z, int w)
{
X = x;
Y = y;
Z = z;
W = w;
}
#endregion
#region Static Fields
///
/// Defines a unit-length Vector4i that points towards the X-axis.
///
public static readonly Vector4i UnitX = new Vector4i(1, 0, 0, 0);
///
/// Defines a unit-length Vector4i that points towards the Y-axis.
///
public static readonly Vector4i UnitY = new Vector4i(0, 1, 0, 0);
///
/// Defines a unit-length Vector4i that points towards the Z-axis.
///
public static readonly Vector4i UnitZ = new Vector4i(0, 0, 1, 0);
///
/// Defines a unit-length Vector4i that points towards the W-axis.
///
public static readonly Vector4i UnitW = new Vector4i(0, 0, 0, 1);
///
/// Defines a zero-length Vector4i.
///
public static readonly Vector4i Zero = new Vector4i(0, 0, 0, 0);
///
/// Defines an instance with all components set to 1.
///
public static readonly Vector4i One = new Vector4i(1, 1, 1, 1);
///
/// Defines the size of the Vector4i struct in bytes.
///
public static readonly int SizeInBytes = Marshal.SizeOf(new Vector4i());
#endregion
#region Overrides
#region public override string ToString()
///
/// Returns a System.String that represents the current Vector4i.
///
///
public override string ToString()
{
return String.Format("({0}, {1}, {2}, {3})", X, Y, Z, W);
}
#endregion
#region public override int GetHashCode()
///
/// Returns the hashcode for this instance.
///
/// A System.Int32 containing the unique hashcode for this instance.
public override int GetHashCode()
{
return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode() ^ W.GetHashCode();
}
#endregion
#region public override bool Equals(object obj)
///
/// Indicates whether this instance and a specified object are equal.
///
/// The object to compare to.
/// True if the instances are equal; false otherwise.
public override bool Equals(object obj)
{
if (!(obj is Vector4i))
return false;
return this.Equals((Vector4i)obj);
}
#endregion
#endregion
#region IEquatable Members
/// Indicates whether the current vector is equal to another vector.
/// A vector to compare with this vector.
/// true if the current vector is equal to the vector parameter; otherwise, false.
public bool Equals(Vector4i other)
{
return
X == other.X &&
Y == other.Y &&
Z == other.Z &&
W == other.W;
}
#endregion
}
/// Represents a 4D vector using four 32-bit unsigned integer values.
///
/// The Vector4ui structure is suitable for interoperation with unmanaged code requiring four consecutive unsigned integers.
///
[Serializable]
public struct Vector4ui : IEquatable
{
#region Fields
///
/// The X component of the Vector4ui.
///
public uint X;
///
/// The Y component of the Vector4ui.
///
public uint Y;
///
/// The Z component of the Vector4ui.
///
public uint Z;
///
/// The W component of the Vector4ui.
///
public uint W;
#endregion
#region Constructors
///
/// Constructs a new Vector4ui.
///
/// The x coordinate of the net Vector4ui.
/// The y coordinate of the net Vector4ui.
/// The z coordinate of the net Vector4ui.
/// The w coordinate of the net Vector4ui.
public Vector4ui(uint x, uint y, uint z, uint w)
{
X = x;
Y = y;
Z = z;
W = w;
}
#endregion
#region Static Fields
///
/// Defines a unit-length Vector4ui that points towards the X-axis.
///
public static readonly Vector4ui UnitX = new Vector4ui(1, 0, 0, 0);
///
/// Defines a unit-length Vector4ui that points towards the Y-axis.
///
public static readonly Vector4ui UnitY = new Vector4ui(0, 1, 0, 0);
///
/// Defines a unit-length Vector4ui that points towards the Z-axis.
///
public static readonly Vector4ui UnitZ = new Vector4ui(0, 0, 1, 0);
///
/// Defines a unit-length Vector4ui that points towards the W-axis.
///
public static readonly Vector4ui UnitW = new Vector4ui(0, 0, 0, 1);
///
/// Defines a zero-length Vector4ui.
///
public static readonly Vector4ui Zero = new Vector4ui(0, 0, 0, 0);
///
/// Defines an instance with all components set to 1.
///
public static readonly Vector4ui One = new Vector4ui(1, 1, 1, 1);
///
/// Defines the size of the Vector4ui struct in bytes.
///
public static readonly int SizeInBytes = Marshal.SizeOf(new Vector4ui());
#endregion
#region Overrides
#region public override string ToString()
///
/// Returns a System.String that represents the current Vector4ui.
///
///
public override string ToString()
{
return String.Format("({0}, {1}, {2}, {3})", X, Y, Z, W);
}
#endregion
#region public override int GetHashCode()
///
/// Returns the hashcode for this instance.
///
/// A System.Int32 containing the unique hashcode for this instance.
public override int GetHashCode()
{
return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode() ^ W.GetHashCode();
}
#endregion
#region public override bool Equals(object obj)
///
/// Indicates whether this instance and a specified object are equal.
///
/// The object to compare to.
/// True if the instances are equal; false otherwise.
public override bool Equals(object obj)
{
if (!(obj is Vector4ui))
return false;
return this.Equals((Vector4ui)obj);
}
#endregion
#endregion
#region IEquatable Members
/// Indicates whether the current vector is equal to another vector.
/// A vector to compare with this vector.
/// true if the current vector is equal to the vector parameter; otherwise, false.
public bool Equals(Vector4ui other)
{
return
X == other.X &&
Y == other.Y &&
Z == other.Z &&
W == other.W;
}
#endregion
}
}