mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 07:05:38 +00:00
5438f941dc
Fixed some static fields in the math classes that weren't also readonly.
138 lines
3.7 KiB
C#
138 lines
3.7 KiB
C#
#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;
|
|
|
|
/// <summary>
|
|
/// The zero matrix.
|
|
/// </summary>
|
|
public static Matrix2x4 Zero = new Matrix2x4(Vector4.Zero, Vector4.Zero);
|
|
|
|
#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
|
|
}
|
|
}
|