Added index getters and settors for Vector and Matrix classes

This commit is contained in:
Andy Korth 2013-01-03 10:39:15 -06:00
parent 0c7c1e8bd9
commit 1939bc789d
8 changed files with 139 additions and 0 deletions

View file

@ -114,6 +114,24 @@ namespace OpenTK
#region Properties #region Properties
/// <summary>
/// Gets or sets the value at a specified row and column.
/// </summary>
public float this[int rowIndex, int columnIndex] { get{
if(rowIndex == 0) return Row0[columnIndex];
else if(rowIndex == 1) return Row1[columnIndex];
else if(rowIndex == 2) return Row2[columnIndex];
else if(rowIndex == 3) return Row3[columnIndex];
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
} set{
if(rowIndex == 0) Row0[columnIndex] = value;
else if(rowIndex == 1) Row1[columnIndex] = value;
else if(rowIndex == 2) Row2[columnIndex] = value;
else if(rowIndex == 3) Row3[columnIndex] = value;
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
}
}
/// <summary> /// <summary>
/// The determinant of this matrix /// The determinant of this matrix
/// </summary> /// </summary>

View file

@ -114,6 +114,24 @@ namespace OpenTK
#region Properties #region Properties
/// <summary>
/// Gets or sets the value at a specified row and column.
/// </summary>
public double this[int rowIndex, int columnIndex] { get{
if(rowIndex == 0) return Row0[columnIndex];
else if(rowIndex == 1) return Row1[columnIndex];
else if(rowIndex == 2) return Row2[columnIndex];
else if(rowIndex == 3) return Row3[columnIndex];
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
} set{
if(rowIndex == 0) Row0[columnIndex] = value;
else if(rowIndex == 1) Row1[columnIndex] = value;
else if(rowIndex == 2) Row2[columnIndex] = value;
else if(rowIndex == 3) Row3[columnIndex] = value;
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
}
}
/// <summary> /// <summary>
/// The determinant of this matrix /// The determinant of this matrix
/// </summary> /// </summary>

View file

@ -108,6 +108,21 @@ namespace OpenTK
#region Public Members #region Public Members
/// <summary>
/// Gets or sets the value at the index of the Vector.
/// </summary>
public float this[int index] {
get{
if(index == 0) return X;
else if(index == 1) return Y;
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
} set{
if(index == 0) X = value;
else if(index == 1) Y = value;
throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
}
}
#region Instance #region Instance
#region public void Add() #region public void Add()

View file

@ -92,6 +92,21 @@ namespace OpenTK
#region Public Members #region Public Members
/// <summary>
/// Gets or sets the value at the index of the Vector.
/// </summary>
public double this[int index] {
get{
if(index == 0) return X;
else if(index == 1) return Y;
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
} set{
if(index == 0) X = value;
else if(index == 1) Y = value;
throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
}
}
#region Instance #region Instance
#region public void Add() #region public void Add()

View file

@ -119,6 +119,24 @@ namespace OpenTK
#region Public Members #region Public Members
/// <summary>
/// Gets or sets the value at the index of the Vector.
/// </summary>
public float this[int index] {
get{
if(index == 0) return X;
else if(index == 1) return Y;
else if(index == 2) return Z;
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
} set{
if(index == 0) X = value;
else if(index == 1) Y = value;
else if(index == 2) Z = value;
throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
}
}
#region Instance #region Instance
#region public void Add() #region public void Add()

View file

@ -118,6 +118,23 @@ namespace OpenTK
#region Public Members #region Public Members
/// <summary>
/// Gets or sets the value at the index of the Vector.
/// </summary>
public double this[int index] {
get{
if(index == 0) return X;
else if(index == 1) return Y;
else if(index == 2) return Z;
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
} set{
if(index == 0) X = value;
else if(index == 1) Y = value;
else if(index == 2) Z = value;
throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
}
}
#region Instance #region Instance
#region public void Add() #region public void Add()

View file

@ -178,6 +178,25 @@ namespace OpenTK
#region Public Members #region Public Members
/// <summary>
/// Gets or sets the value at the index of the Vector.
/// </summary>
public float this[int index] {
get{
if(index == 0) return X;
else if(index == 1) return Y;
else if(index == 2) return Z;
else if(index == 3) return W;
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
} set{
if(index == 0) X = value;
else if(index == 1) Y = value;
else if(index == 2) Z = value;
else if(index == 3) W = value;
throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
}
}
#region Instance #region Instance
#region public void Add() #region public void Add()

View file

@ -176,6 +176,25 @@ namespace OpenTK
#region Public Members #region Public Members
/// <summary>
/// Gets or sets the value at the index of the Vector.
/// </summary>
public double this[int index] {
get{
if(index == 0) return X;
else if(index == 1) return Y;
else if(index == 2) return Z;
else if(index == 3) return W;
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
} set{
if(index == 0) X = value;
else if(index == 1) Y = value;
else if(index == 2) Z = value;
else if(index == 3) W = value;
throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
}
}
#region Instance #region Instance
#region public void Add() #region public void Add()