108 lines
2.7 KiB
C#
108 lines
2.7 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace StgSharp.Math
|
|
{
|
|
public class Matrix4x3
|
|
{
|
|
internal IntPtr _row0Ptr;
|
|
internal IntPtr _row1Ptr;
|
|
internal IntPtr _row2Ptr;
|
|
internal IntPtr _row3Ptr;
|
|
|
|
private bool _isTransposed;
|
|
private Matrix3x4 _transpose;
|
|
|
|
public Matrix4x3(
|
|
float a00, float a01, float a02,
|
|
float a10, float a11, float a12,
|
|
float a20, float a21, float a22,
|
|
float a30, float a31, float a32
|
|
)
|
|
{
|
|
_row0Ptr = internalIO.load_internal(a00,a01,a02,0);
|
|
_row1Ptr = internalIO.load_internal(a10,a11,a12,0);
|
|
_row2Ptr = internalIO.load_internal(a20,a21,a22,0);
|
|
_row3Ptr = internalIO.load_internal(a30,a31,a32,0);
|
|
|
|
_transpose = new Matrix3x4(this);
|
|
}
|
|
|
|
internal Matrix4x3(Matrix3x4 transpose)
|
|
{
|
|
this._transpose = transpose;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Explicit)]
|
|
public struct matrix4x3 : IEquatable<matrix4x3>
|
|
{
|
|
[FieldOffset(0)]
|
|
public Vec3d row1;
|
|
[FieldOffset(12)]
|
|
public Vec3d row2;
|
|
[FieldOffset(24)]
|
|
public Vec3d row3;
|
|
[FieldOffset(36)]
|
|
public Vec3d row4;
|
|
|
|
public matrix4x3(
|
|
float a11, float a12, float a13,
|
|
float a21, float a22, float a23,
|
|
float a31, float a32, float a33,
|
|
float a41, float a42, float a43
|
|
)
|
|
{
|
|
row1 = new Vec3d(a11, a12, a13);
|
|
row2 = new Vec3d(a21, a22, a23);
|
|
row3 = new Vec3d(a31, a32, a33);
|
|
row4 = new Vec3d(a41, a42, a43);
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (obj == null)
|
|
{
|
|
return false;
|
|
}
|
|
else if (obj.GetType() != typeof(matrix4x3))
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return this.Equals((matrix4x3)obj);
|
|
}
|
|
}
|
|
|
|
bool IEquatable<matrix4x3>.Equals(matrix4x3 other)
|
|
{
|
|
if (this.GetHashCode() != other.GetHashCode())
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return this.row1 == other.row1
|
|
&& this.row2 == other.row2
|
|
&& this.row3 == other.row3
|
|
&& this.row4 == other.row4;
|
|
}
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return base.ToString();
|
|
}
|
|
|
|
|
|
}
|
|
}
|