mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 12:05:33 +00:00
Added very basic implementations of all possible matrix sizes up to 4x4
Moved the indexers out of the Properties region and into their own Indexers region
This commit is contained in:
parent
e5adf4d862
commit
8b8ded3232
|
@ -137,6 +137,17 @@ namespace OpenTK.Graphics.ES20
|
|||
GL.Uniform4(location, quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
|
||||
}
|
||||
|
||||
public static void UniformMatrix2(int location, bool transpose, ref Matrix2 matrix)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (float* matrix_ptr = &matrix.Row0.X)
|
||||
{
|
||||
GL.UniformMatrix2(location, 1, transpose, matrix_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UniformMatrix3(int location, bool transpose, ref Matrix3 matrix)
|
||||
{
|
||||
unsafe
|
||||
|
|
|
@ -409,6 +409,8 @@ namespace OpenTK.Graphics.OpenGL
|
|||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Uniform
|
||||
|
||||
[CLSCompliant(false)]
|
||||
|
@ -454,6 +456,50 @@ namespace OpenTK.Graphics.OpenGL
|
|||
GL.Uniform4(location, quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
|
||||
}
|
||||
|
||||
public static void UniformMatrix2(int location, bool transpose, ref Matrix2 matrix)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (float* matrix_ptr = &matrix.Row0.X)
|
||||
{
|
||||
GL.UniformMatrix2(location, 1, transpose, matrix_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UniformMatrix2x3(int location, bool transpose, ref Matrix2x3 matrix)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (float* matrix_ptr = &matrix.Row0.X)
|
||||
{
|
||||
GL.UniformMatrix2x3(location, 1, transpose, matrix_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UniformMatrix2x4(int location, bool transpose, ref Matrix2x4 matrix)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (float* matrix_ptr = &matrix.Row0.X)
|
||||
{
|
||||
GL.UniformMatrix2x4(location, 1, transpose, matrix_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UniformMatrix3x2(int location, bool transpose, ref Matrix3x2 matrix)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (float* matrix_ptr = &matrix.Row0.X)
|
||||
{
|
||||
GL.UniformMatrix3x2(location, 1, transpose, matrix_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UniformMatrix3(int location, bool transpose, ref Matrix3 matrix)
|
||||
{
|
||||
unsafe
|
||||
|
@ -476,6 +522,39 @@ namespace OpenTK.Graphics.OpenGL
|
|||
}
|
||||
}
|
||||
|
||||
public static void UniformMatrix3x4(int location, bool transpose, ref Matrix3x4 matrix)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (float* matrix_ptr = &matrix.Row0.X)
|
||||
{
|
||||
GL.UniformMatrix3x4(location, 1, transpose, matrix_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UniformMatrix4x2(int location, bool transpose, ref Matrix4x2 matrix)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (float* matrix_ptr = &matrix.Row0.X)
|
||||
{
|
||||
GL.UniformMatrix4x2(location, 1, transpose, matrix_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UniformMatrix4x3(int location, bool transpose, ref Matrix4x3 matrix)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (float* matrix_ptr = &matrix.Row0.X)
|
||||
{
|
||||
GL.UniformMatrix4x3(location, 1, transpose, matrix_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UniformMatrix4(int location, bool transpose, ref Matrix4 matrix)
|
||||
{
|
||||
unsafe
|
||||
|
@ -500,8 +579,6 @@ namespace OpenTK.Graphics.OpenGL
|
|||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Shaders
|
||||
|
||||
#region GetActiveAttrib
|
||||
|
|
134
Source/OpenTK/Math/Matrix2.cs
Normal file
134
Source/OpenTK/Math/Matrix2.cs
Normal file
|
@ -0,0 +1,134 @@
|
|||
#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
|
||||
{
|
||||
public struct Matrix2 : IEquatable<Matrix2>
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Top row of the matrix.
|
||||
/// </summary>
|
||||
public Vector2 Row0;
|
||||
|
||||
/// <summary>
|
||||
/// Bottom row of the matrix.
|
||||
/// </summary>
|
||||
public Vector2 Row1;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public Matrix2(Vector2 row0, Vector2 row1)
|
||||
{
|
||||
Row0 = row0;
|
||||
Row1 = row1;
|
||||
}
|
||||
|
||||
public Matrix2(
|
||||
float m00, float m01,
|
||||
float m10, float m11)
|
||||
{
|
||||
Row0 = new Vector2(m00, m01);
|
||||
Row1 = new Vector2(m10, m11);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Members
|
||||
|
||||
#region Properties
|
||||
|
||||
public float Determinant
|
||||
{
|
||||
get
|
||||
{
|
||||
float m11 = Row0.X, m12 = Row0.Y,
|
||||
m21 = Row1.X, m22 = Row1.Y;
|
||||
|
||||
return m11 * m22 - m12 * m21;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 Column0
|
||||
{
|
||||
get { return new Vector2(Row0.X, Row1.X); }
|
||||
set { Row0.X = value.X; Row1.X = value.Y; }
|
||||
}
|
||||
|
||||
public Vector2 Column1
|
||||
{
|
||||
get { return new Vector2(Row0.Y, Row1.Y); }
|
||||
set { Row0.Y = value.X; Row1.Y = value.Y; }
|
||||
}
|
||||
|
||||
public float M11 { get { return Row0.X; } set { Row0.X = value; } }
|
||||
public float M12 { get { return Row0.Y; } set { Row0.Y = value; } }
|
||||
public float M21 { get { return Row1.X; } set { Row1.X = value; } }
|
||||
public float M22 { get { return Row1.Y; } set { Row1.Y = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Indexers
|
||||
|
||||
/// <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];
|
||||
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;
|
||||
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEquatable<Matrix2> Members
|
||||
|
||||
public bool Equals(Matrix2 other)
|
||||
{
|
||||
return
|
||||
Row0 == other.Row0 &&
|
||||
Row1 == other.Row1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
34
Source/OpenTK/Math/Matrix2d.cs
Normal file
34
Source/OpenTK/Math/Matrix2d.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
#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
|
||||
{
|
||||
//TODO copy from Matrix2.cs when it's mostly feature-complete.
|
||||
/*public struct Matrix2d : IEquatable<Matrix2d>
|
||||
{
|
||||
}*/
|
||||
}
|
124
Source/OpenTK/Math/Matrix2x3.cs
Normal file
124
Source/OpenTK/Math/Matrix2x3.cs
Normal file
|
@ -0,0 +1,124 @@
|
|||
#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.Collections.Generic;
|
||||
|
||||
namespace OpenTK
|
||||
{
|
||||
public struct Matrix2x3 : IEquatable<Matrix2x3>
|
||||
{
|
||||
#region Fields
|
||||
|
||||
public Vector3 Row0;
|
||||
public Vector3 Row1;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public Matrix2x3(Vector3 row0, Vector3 row1)
|
||||
{
|
||||
Row0 = row0;
|
||||
Row1 = row1;
|
||||
}
|
||||
|
||||
public Matrix2x3(
|
||||
float m00, float m01, float m02,
|
||||
float m10, float m11, float m12)
|
||||
{
|
||||
Row0 = new Vector3(m00, m01, m02);
|
||||
Row1 = new Vector3(m10, m11, m12);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Members
|
||||
|
||||
#region Properties
|
||||
|
||||
public Vector2 Column0
|
||||
{
|
||||
get { return new Vector2(Row0.X, Row1.X); }
|
||||
set { Row0.X = value.X; Row1.X = value.Y; }
|
||||
}
|
||||
|
||||
public Vector2 Column1
|
||||
{
|
||||
get { return new Vector2(Row0.Y, Row1.Y); }
|
||||
set { Row0.Y = value.X; Row1.Y = value.Y; }
|
||||
}
|
||||
|
||||
public Vector2 Column2
|
||||
{
|
||||
get { return new Vector2(Row0.Z, Row1.Z); }
|
||||
set { Row0.Z = value.X; Row1.Z = value.Y; }
|
||||
}
|
||||
|
||||
public float M11 { get { return Row0.X; } set { Row0.X = value; } }
|
||||
public float M12 { get { return Row0.Y; } set { Row0.Y = value; } }
|
||||
public float M13 { get { return Row0.Z; } set { Row0.Z = value; } }
|
||||
public float M21 { get { return Row1.X; } set { Row1.X = value; } }
|
||||
public float M22 { get { return Row1.Y; } set { Row1.Y = value; } }
|
||||
public float M23 { get { return Row1.Z; } set { Row1.Z = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Indexers
|
||||
|
||||
/// <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];
|
||||
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;
|
||||
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEquatable<Matrix2x3> Members
|
||||
|
||||
public bool Equals(Matrix2x3 other)
|
||||
{
|
||||
return
|
||||
Row0 == other.Row0 &&
|
||||
Row1 == other.Row1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
34
Source/OpenTK/Math/Matrix2x3d.cs
Normal file
34
Source/OpenTK/Math/Matrix2x3d.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
#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
|
||||
{
|
||||
//TODO copy from Matrix2x3.cs when it's mostly feature-complete.
|
||||
/*public struct Matrix2x3d : IEquatable<Matrix2x3d>
|
||||
{
|
||||
}*/
|
||||
}
|
132
Source/OpenTK/Math/Matrix2x4.cs
Normal file
132
Source/OpenTK/Math/Matrix2x4.cs
Normal file
|
@ -0,0 +1,132 @@
|
|||
#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
|
||||
{
|
||||
public struct Matrix2x4 : IEquatable<Matrix2x4>
|
||||
{
|
||||
#region Fields
|
||||
|
||||
public Vector4 Row0;
|
||||
public Vector4 Row1;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public Matrix2x4(Vector4 row0, Vector4 row1)
|
||||
{
|
||||
Row0 = row0;
|
||||
Row1 = row1;
|
||||
}
|
||||
|
||||
public Matrix2x4(
|
||||
float m00, float m01, float m02, float m03,
|
||||
float m10, float m11, float m12, float m13)
|
||||
{
|
||||
Row0 = new Vector4(m00, m01, m02, m03);
|
||||
Row1 = new Vector4(m10, m11, m12, m13);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Members
|
||||
|
||||
#region Properties
|
||||
|
||||
public Vector2 Column0
|
||||
{
|
||||
get { return new Vector2(Row0.X, Row1.X); }
|
||||
set { Row0.X = value.X; Row1.X = value.Y; }
|
||||
}
|
||||
|
||||
public Vector2 Column1
|
||||
{
|
||||
get { return new Vector2(Row0.Y, Row1.Y); }
|
||||
set { Row0.Y = value.X; Row1.Y = value.Y; }
|
||||
}
|
||||
|
||||
public Vector2 Column2
|
||||
{
|
||||
get { return new Vector2(Row0.Z, Row1.Z); }
|
||||
set { Row0.Z = value.X; Row1.Z = value.Y; }
|
||||
}
|
||||
|
||||
public Vector2 Column3
|
||||
{
|
||||
get { return new Vector2(Row0.W, Row1.W); }
|
||||
set { Row0.W = value.X; Row1.W = value.Y; }
|
||||
}
|
||||
|
||||
public float M11 { get { return Row0.X; } set { Row0.X = value; } }
|
||||
public float M12 { get { return Row0.Y; } set { Row0.Y = value; } }
|
||||
public float M13 { get { return Row0.Z; } set { Row0.Z = value; } }
|
||||
public float M14 { get { return Row0.W; } set { Row0.W = value; } }
|
||||
public float M21 { get { return Row1.X; } set { Row1.X = value; } }
|
||||
public float M22 { get { return Row1.Y; } set { Row1.Y = value; } }
|
||||
public float M23 { get { return Row1.Z; } set { Row1.Z = value; } }
|
||||
public float M24 { get { return Row1.W; } set { Row1.W = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Indexers
|
||||
|
||||
/// <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];
|
||||
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;
|
||||
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEquatable<Matrix2x4> Members
|
||||
|
||||
public bool Equals(Matrix2x4 other)
|
||||
{
|
||||
return
|
||||
Row0 == other.Row0 &&
|
||||
Row1 == other.Row1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
34
Source/OpenTK/Math/Matrix2x4d.cs
Normal file
34
Source/OpenTK/Math/Matrix2x4d.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
#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
|
||||
{
|
||||
//TODO copy from Matrix2x4.cs when it's mostly feature-complete.
|
||||
/*public struct Matrix2x4d : IEquatable<Matrix2x4d>
|
||||
{
|
||||
}*/
|
||||
}
|
|
@ -188,11 +188,36 @@ namespace OpenTK
|
|||
public float M33 { get { return Row2.Z; } set { Row2.Z = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Indexers
|
||||
|
||||
/// <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];
|
||||
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;
|
||||
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Instance
|
||||
|
||||
|
||||
#region public void Invert()
|
||||
|
||||
|
||||
public void Invert()
|
||||
{
|
||||
this = Matrix3.Invert(this);
|
||||
|
|
|
@ -188,11 +188,36 @@ namespace OpenTK
|
|||
public double M33 { get { return Row2.Z; } set { Row2.Z = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Indexers
|
||||
|
||||
/// <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];
|
||||
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;
|
||||
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Instance
|
||||
|
||||
|
||||
#region public void Invert()
|
||||
|
||||
|
||||
public void Invert()
|
||||
{
|
||||
this = Matrix3d.Invert(this);
|
||||
|
|
125
Source/OpenTK/Math/Matrix3x2.cs
Normal file
125
Source/OpenTK/Math/Matrix3x2.cs
Normal file
|
@ -0,0 +1,125 @@
|
|||
#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
|
||||
{
|
||||
public struct Matrix3x2 : IEquatable<Matrix3x2>
|
||||
{
|
||||
#region Fields
|
||||
|
||||
public Vector2 Row0;
|
||||
public Vector2 Row1;
|
||||
public Vector2 Row2;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public Matrix3x2(Vector2 row0, Vector2 row1, Vector2 row2)
|
||||
{
|
||||
Row0 = row0;
|
||||
Row1 = row1;
|
||||
Row2 = row2;
|
||||
}
|
||||
|
||||
public Matrix3x2(
|
||||
float m00, float m01,
|
||||
float m10, float m11,
|
||||
float m20, float m21)
|
||||
{
|
||||
Row0 = new Vector2(m00, m01);
|
||||
Row1 = new Vector2(m10, m11);
|
||||
Row2 = new Vector2(m20, m21);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Members
|
||||
|
||||
#region Properties
|
||||
|
||||
public Vector3 Column0
|
||||
{
|
||||
get { return new Vector3(Row0.X, Row1.X, Row2.X); }
|
||||
set { Row0.X = value.X; Row1.X = value.Y; Row2.X = value.Z; }
|
||||
}
|
||||
|
||||
public Vector3 Column1
|
||||
{
|
||||
get { return new Vector3(Row0.Y, Row1.Y, Row2.Y); }
|
||||
set { Row0.Y = value.X; Row1.Y = value.Y; Row2.Y = value.Z; }
|
||||
}
|
||||
|
||||
public float M11 { get { return Row0.X; } set { Row0.X = value; } }
|
||||
public float M12 { get { return Row0.Y; } set { Row0.Y = value; } }
|
||||
public float M21 { get { return Row1.X; } set { Row1.X = value; } }
|
||||
public float M22 { get { return Row1.Y; } set { Row1.Y = value; } }
|
||||
public float M31 { get { return Row2.X; } set { Row2.X = value; } }
|
||||
public float M32 { get { return Row2.Y; } set { Row2.Y = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Indexers
|
||||
|
||||
/// <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];
|
||||
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;
|
||||
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEquatable<Matrix3x2> Members
|
||||
|
||||
public bool Equals(Matrix3x2 other)
|
||||
{
|
||||
return
|
||||
Row0 == other.Row0 &&
|
||||
Row1 == other.Row1 &&
|
||||
Row2 == other.Row2;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
34
Source/OpenTK/Math/Matrix3x2d.cs
Normal file
34
Source/OpenTK/Math/Matrix3x2d.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
#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
|
||||
{
|
||||
//TODO copy from Matrix3x2.cs when it's mostly feature-complete.
|
||||
/*public struct Matrix3x2d : IEquatable<Matrix3x2d>
|
||||
{
|
||||
}*/
|
||||
}
|
|
@ -1,9 +1,31 @@
|
|||
using System;
|
||||
#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;
|
||||
|
||||
using OpenTK;
|
||||
|
||||
namespace TopHat.Mathematics
|
||||
namespace OpenTK
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a 3x4 Matrix
|
||||
|
@ -176,6 +198,31 @@ namespace TopHat.Mathematics
|
|||
|
||||
#endregion
|
||||
|
||||
#region Indexers
|
||||
|
||||
/// <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];
|
||||
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;
|
||||
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Instance
|
||||
|
||||
#region public void Invert()
|
||||
|
|
34
Source/OpenTK/Math/Matrix3x4d.cs
Normal file
34
Source/OpenTK/Math/Matrix3x4d.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
#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
|
||||
{
|
||||
//TODO copy from Matrix3x4.cs when it's mostly feature-complete.
|
||||
/*public struct Matrix3x4d : IEquatable<Matrix3x4d>
|
||||
{
|
||||
}*/
|
||||
}
|
|
@ -117,24 +117,6 @@ namespace OpenTK
|
|||
|
||||
#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>
|
||||
/// The determinant of this matrix
|
||||
/// Gets the determinant of this matrix.
|
||||
|
@ -164,6 +146,7 @@ namespace OpenTK
|
|||
public Vector4 Column0
|
||||
{
|
||||
get { return new Vector4(Row0.X, Row1.X, Row2.X, Row3.X); }
|
||||
set { Row0.X = value.X; Row1.X = value.Y; Row2.X = value.Z; Row3.X = value.W; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -172,6 +155,7 @@ namespace OpenTK
|
|||
public Vector4 Column1
|
||||
{
|
||||
get { return new Vector4(Row0.Y, Row1.Y, Row2.Y, Row3.Y); }
|
||||
set { Row0.Y = value.X; Row1.Y = value.Y; Row2.Y = value.Z; Row3.Y = value.W; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -180,6 +164,7 @@ namespace OpenTK
|
|||
public Vector4 Column2
|
||||
{
|
||||
get { return new Vector4(Row0.Z, Row1.Z, Row2.Z, Row3.Z); }
|
||||
set { Row0.Z = value.X; Row1.Z = value.Y; Row2.Z = value.Z; Row3.Z = value.W; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -188,6 +173,7 @@ namespace OpenTK
|
|||
public Vector4 Column3
|
||||
{
|
||||
get { return new Vector4(Row0.W, Row1.W, Row2.W, Row3.W); }
|
||||
set { Row0.W = value.X; Row1.W = value.Y; Row2.W = value.Z; Row3.W = value.W; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -272,6 +258,33 @@ namespace OpenTK
|
|||
|
||||
#endregion
|
||||
|
||||
#region Indexers
|
||||
|
||||
/// <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 + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Instance
|
||||
|
||||
#region public void Invert()
|
||||
|
|
|
@ -114,24 +114,6 @@ namespace OpenTK
|
|||
|
||||
#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>
|
||||
/// The determinant of this matrix
|
||||
/// </summary>
|
||||
|
@ -263,11 +245,38 @@ namespace OpenTK
|
|||
|
||||
#endregion
|
||||
|
||||
#region Instance
|
||||
#region Indexers
|
||||
|
||||
#region public void Invert()
|
||||
/// <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>
|
||||
#endregion
|
||||
|
||||
#region Instance
|
||||
|
||||
#region public void Invert()
|
||||
|
||||
/// <summary>
|
||||
/// Converts this instance into its inverse.
|
||||
/// </summary>
|
||||
public void Invert()
|
||||
|
|
134
Source/OpenTK/Math/Matrix4x2.cs
Normal file
134
Source/OpenTK/Math/Matrix4x2.cs
Normal file
|
@ -0,0 +1,134 @@
|
|||
#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
|
||||
{
|
||||
public struct Matrix4x2 : IEquatable<Matrix4x2>
|
||||
{
|
||||
#region Fields
|
||||
|
||||
public Vector2 Row0;
|
||||
public Vector2 Row1;
|
||||
public Vector2 Row2;
|
||||
public Vector2 Row3;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public Matrix4x2(Vector2 row0, Vector2 row1, Vector2 row2, Vector2 row3)
|
||||
{
|
||||
Row0 = row0;
|
||||
Row1 = row1;
|
||||
Row2 = row2;
|
||||
Row3 = row3;
|
||||
}
|
||||
|
||||
public Matrix4x2(
|
||||
float m00, float m01,
|
||||
float m10, float m11,
|
||||
float m20, float m21,
|
||||
float m30, float m31)
|
||||
{
|
||||
Row0 = new Vector2(m00, m01);
|
||||
Row1 = new Vector2(m10, m11);
|
||||
Row2 = new Vector2(m20, m21);
|
||||
Row3 = new Vector2(m30, m31);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Members
|
||||
|
||||
#region Properties
|
||||
|
||||
public Vector4 Column0
|
||||
{
|
||||
get { return new Vector4(Row0.X, Row1.X, Row2.X, Row3.X); }
|
||||
set { Row0.X = value.X; Row1.X = value.Y; Row2.X = value.Z; Row3.X = value.W; }
|
||||
}
|
||||
|
||||
public Vector4 Column1
|
||||
{
|
||||
get { return new Vector4(Row0.Y, Row1.Y, Row2.Y, Row3.X); }
|
||||
set { Row0.Y = value.X; Row1.Y = value.Y; Row2.Y = value.Z; Row3.Y = value.W; }
|
||||
}
|
||||
|
||||
public float M11 { get { return Row0.X; } set { Row0.X = value; } }
|
||||
public float M12 { get { return Row0.Y; } set { Row0.Y = value; } }
|
||||
public float M21 { get { return Row1.X; } set { Row1.X = value; } }
|
||||
public float M22 { get { return Row1.Y; } set { Row1.Y = value; } }
|
||||
public float M31 { get { return Row2.X; } set { Row2.X = value; } }
|
||||
public float M32 { get { return Row2.Y; } set { Row2.Y = value; } }
|
||||
public float M41 { get { return Row3.X; } set { Row3.X = value; } }
|
||||
public float M42 { get { return Row3.Y; } set { Row3.Y = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Indexers
|
||||
|
||||
/// <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 + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEquatable<Matrix4x2> Members
|
||||
|
||||
public bool Equals(Matrix4x2 other)
|
||||
{
|
||||
return
|
||||
Row0 == other.Row0 &&
|
||||
Row1 == other.Row1 &&
|
||||
Row2 == other.Row2 &&
|
||||
Row3 == other.Row3;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
34
Source/OpenTK/Math/Matrix4x2d.cs
Normal file
34
Source/OpenTK/Math/Matrix4x2d.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
#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
|
||||
{
|
||||
//TODO copy from Matrix4x2.cs when it's mostly feature-complete.
|
||||
/*public struct Matrix4x2d : IEquatable<Matrix4x2d>
|
||||
{
|
||||
}*/
|
||||
}
|
|
@ -1,9 +1,31 @@
|
|||
using System;
|
||||
#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;
|
||||
|
||||
using OpenTK;
|
||||
|
||||
namespace TopHat.Mathematics
|
||||
namespace OpenTK
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a 3x4 Matrix
|
||||
|
@ -177,6 +199,33 @@ namespace TopHat.Mathematics
|
|||
|
||||
#endregion
|
||||
|
||||
#region Indexers
|
||||
|
||||
/// <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 + ")");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Instance
|
||||
|
||||
#region public void Invert()
|
||||
|
|
34
Source/OpenTK/Math/Matrix4x3d.cs
Normal file
34
Source/OpenTK/Math/Matrix4x3d.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
#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
|
||||
{
|
||||
//TODO copy from Matrix4x3.cs when it's mostly feature-complete.
|
||||
/*public struct Matrix4x3d : IEquatable<Matrix4x3d>
|
||||
{
|
||||
}*/
|
||||
}
|
|
@ -132,9 +132,21 @@
|
|||
<Compile Include="Input\IInputDriver2.cs" />
|
||||
<Compile Include="Input\IKeyboardDriver2.cs" />
|
||||
<Compile Include="Input\IMouseDriver2.cs" />
|
||||
<Compile Include="Math\Matrix2.cs" />
|
||||
<Compile Include="Math\Matrix2d.cs" />
|
||||
<Compile Include="Math\Matrix2x3.cs" />
|
||||
<Compile Include="Math\Matrix2x3d.cs" />
|
||||
<Compile Include="Math\Matrix2x4.cs" />
|
||||
<Compile Include="Math\Matrix2x4d.cs" />
|
||||
<Compile Include="Math\Matrix3.cs" />
|
||||
<Compile Include="Math\Matrix3x2.cs" />
|
||||
<Compile Include="Math\Matrix3x2d.cs" />
|
||||
<Compile Include="Math\Matrix3x4.cs" />
|
||||
<Compile Include="Math\Matrix3x4d.cs" />
|
||||
<Compile Include="Math\Matrix4x2.cs" />
|
||||
<Compile Include="Math\Matrix4x2d.cs" />
|
||||
<Compile Include="Math\Matrix4x3.cs" />
|
||||
<Compile Include="Math\Matrix4x3d.cs" />
|
||||
<Compile Include="Platform\DisplayDeviceBase.cs" />
|
||||
<Compile Include="Platform\Windows\WinInputBase.cs" />
|
||||
<Compile Include="WindowBorder.cs">
|
||||
|
|
Loading…
Reference in a new issue