New IO structure, unexpexted error in C code
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
|
||||
internal class Cordination
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static unsafe partial class Vector
|
||||
{
|
||||
|
||||
public static float Det(matrix2x2 array)
|
||||
{
|
||||
return Cross(array.row1,array.row2);
|
||||
return Cross(array.row1, array.row2);
|
||||
}
|
||||
|
||||
public static unsafe float Det(matrix3x3 array)
|
||||
@@ -29,7 +25,7 @@ namespace StgSharp.Math
|
||||
*(p + 6), *(p + 7)
|
||||
);
|
||||
|
||||
return
|
||||
return
|
||||
*p * Det(matrix1)
|
||||
- *(p + 1) * Det(matrix2)
|
||||
+ *(p + 2) * Det(matrix3)
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static unsafe partial class Vector
|
||||
{
|
||||
public static float GetAngle(vec2d vec1, vec2d vec2)
|
||||
{
|
||||
return Calc.ACos(
|
||||
vec1 .multiple(vec2)
|
||||
vec1.multiple(vec2)
|
||||
/ (vec1.GetLength() * vec2.GetLength())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static unsafe partial class Vector
|
||||
{
|
||||
@@ -18,7 +14,7 @@ namespace StgSharp.Math
|
||||
public static float GetLength(this vec2d vec)
|
||||
{
|
||||
return Calc.Sqrt(
|
||||
vec.X * vec.X +
|
||||
vec.X * vec.X +
|
||||
vec.Y * vec.Y
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static unsafe partial class Vector
|
||||
{
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static unsafe partial class VectorCalc
|
||||
{
|
||||
@@ -131,7 +126,7 @@ namespace StgSharp.Math
|
||||
*(p1 + 2) * *(p2 + 0) + *(p1 + 3) * *(p2 + 1)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -373,8 +368,8 @@ namespace StgSharp.Math
|
||||
var c2 = a1.multiple(b12) + a2.multiple(b22);
|
||||
|
||||
return new matrix2x4(
|
||||
new vec4d(c1.row1,c2.row1),
|
||||
new vec4d(c1.row2,c2.row2)
|
||||
new vec4d(c1.row1, c2.row1),
|
||||
new vec4d(c1.row2, c2.row2)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -448,11 +443,11 @@ namespace StgSharp.Math
|
||||
float* p2 = &matrix2.row1.X;
|
||||
|
||||
return new matrix2x3(
|
||||
getMatrixMember(p1,p2), getMatrixMember(p1, p2+1), getMatrixMember(p1, p2+2),
|
||||
getMatrixMember(p1+4, p2), getMatrixMember(p1+4, p2+1), getMatrixMember(p1+4, p2 + 2)
|
||||
getMatrixMember(p1, p2), getMatrixMember(p1, p2 + 1), getMatrixMember(p1, p2 + 2),
|
||||
getMatrixMember(p1 + 4, p2), getMatrixMember(p1 + 4, p2 + 1), getMatrixMember(p1 + 4, p2 + 2)
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -464,19 +459,19 @@ namespace StgSharp.Math
|
||||
public static unsafe matrix2x4 multiple(this matrix2x4 matrix1, matrix4x4 matrix2)
|
||||
{
|
||||
|
||||
matrix2x2 a1 = new matrix2x2(matrix1.row1.Point1,matrix1.row2.Point1);
|
||||
matrix2x2 a1 = new matrix2x2(matrix1.row1.Point1, matrix1.row2.Point1);
|
||||
matrix2x2 a2 = new matrix2x2(matrix1.row1.Point2, matrix1.row2.Point2);
|
||||
|
||||
matrix2x2 b11 = new matrix2x2(matrix2.row1.Point1, matrix2.row2.Point1);
|
||||
matrix2x2 b12 = new matrix2x2(matrix2.row1.Point2, matrix2.row2.Point2);
|
||||
matrix2x2 b21 = new matrix2x2(matrix2.row3.Point1, matrix2.row4.Point1);
|
||||
matrix2x2 b22 = new matrix2x2(matrix2.row3.Point2, matrix2.row4.Point2);
|
||||
|
||||
|
||||
var c1 = a1.multiple(b11) + a2.multiple(b21);
|
||||
var c2 = a1.multiple(b12) + a2.multiple(b22);
|
||||
|
||||
return new matrix2x4(
|
||||
new vec4d(c1.row1, c2.row1),
|
||||
new vec4d(c1.row1, c2.row1),
|
||||
new vec4d(c1.row2, c2.row2));
|
||||
}
|
||||
|
||||
@@ -533,9 +528,9 @@ namespace StgSharp.Math
|
||||
float* p3 = &m11.row1.X;
|
||||
|
||||
return new matrix3x3(
|
||||
*(p3 + 0), *(p3 + 1),m12.X,
|
||||
*(p3 + 2), *(p3 + 3),m12.Y,
|
||||
m21.X, m21.Y, m22
|
||||
*(p3 + 0), *(p3 + 1), m12.X,
|
||||
*(p3 + 2), *(p3 + 3), m12.Y,
|
||||
m21.X, m21.Y, m22
|
||||
);
|
||||
}
|
||||
|
||||
@@ -547,7 +542,7 @@ namespace StgSharp.Math
|
||||
/// <returns></returns>
|
||||
public static unsafe matrix3x4 multiple(this matrix3x2 matrix1, matrix2x4 matrix2)
|
||||
{
|
||||
var a1 = new matrix2x2(matrix1.row1,matrix1.row2);
|
||||
var a1 = new matrix2x2(matrix1.row1, matrix1.row2);
|
||||
var a2 = matrix1.row3;
|
||||
|
||||
var b1 = new matrix2x2(matrix2.row1.Point1, matrix2.row2.Point1);
|
||||
@@ -589,13 +584,13 @@ namespace StgSharp.Math
|
||||
var a21 = new vec2d(*(p1 + 6), *(p1 + 7));
|
||||
var a22 = *(p1 + 8);
|
||||
|
||||
var b1 = new matrix2x2(matrix2.row1,matrix2.row2);
|
||||
var b1 = new matrix2x2(matrix2.row1, matrix2.row2);
|
||||
var b2 = matrix2.row3;
|
||||
|
||||
var c1 = a11.multiple(b1) + a12.multiple(b2);
|
||||
var c2 = a21.multiple(b1) + b2 * a22;
|
||||
|
||||
return new matrix3x2(c1.row1,c1.row2,c2);
|
||||
return new matrix3x2(c1.row1, c1.row2, c2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -655,9 +650,9 @@ namespace StgSharp.Math
|
||||
|
||||
|
||||
return new matrix3x4(
|
||||
new vec4d(c11.row1,c12.row1),
|
||||
new vec4d(c11.row2,c12.row2),
|
||||
new vec4d(c21,c22)
|
||||
new vec4d(c11.row1, c12.row1),
|
||||
new vec4d(c11.row2, c12.row2),
|
||||
new vec4d(c21, c22)
|
||||
);
|
||||
|
||||
}
|
||||
@@ -693,7 +688,7 @@ namespace StgSharp.Math
|
||||
var c1 = a11.multiple(b1) + a12.multiple(b2);
|
||||
var c2 = a21.multiple(b1) + a22.multiple(b2);
|
||||
|
||||
return new matrix3x2(c1.row1,c1.row2,c2);
|
||||
return new matrix3x2(c1.row1, c1.row2, c2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -750,8 +745,8 @@ namespace StgSharp.Math
|
||||
float* p1 = &matrix1.row1.X;
|
||||
float* p2 = &matrix2.row1.X;
|
||||
|
||||
var a11 = new matrix2x2(matrix1.row1.Point1,matrix1.row2.Point1);
|
||||
var a12 = new matrix2x2(matrix1.row1.Point2,matrix1.row2.Point2);
|
||||
var a11 = new matrix2x2(matrix1.row1.Point1, matrix1.row2.Point1);
|
||||
var a12 = new matrix2x2(matrix1.row1.Point2, matrix1.row2.Point2);
|
||||
var a21 = matrix1.row3.Point1;
|
||||
var a22 = matrix1.row3.Point2;
|
||||
|
||||
@@ -766,10 +761,10 @@ namespace StgSharp.Math
|
||||
var c4 = a21.multiple(b12) + a22.multiple(b22);
|
||||
|
||||
return new matrix3x4(
|
||||
new vec4d(c1.row1,c2.row1),
|
||||
new vec4d(c1.row2,c2.row2),
|
||||
new vec4d(c3,c4)
|
||||
) ;
|
||||
new vec4d(c1.row1, c2.row1),
|
||||
new vec4d(c1.row2, c2.row2),
|
||||
new vec4d(c3, c4)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -813,10 +808,10 @@ namespace StgSharp.Math
|
||||
var u7 = u3 + m5;
|
||||
|
||||
return new matrix4x2(
|
||||
new vec2d(u1.X,u5.X),
|
||||
new vec2d(u1.Y,u5.Y),
|
||||
new vec2d(u6.X,u7.X),
|
||||
new vec2d(u6.Y,u7.Y)
|
||||
new vec2d(u1.X, u5.X),
|
||||
new vec2d(u1.Y, u5.Y),
|
||||
new vec2d(u6.X, u7.X),
|
||||
new vec2d(u6.Y, u7.Y)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -839,10 +834,10 @@ namespace StgSharp.Math
|
||||
float* pc2 = &c21.row1.X;
|
||||
|
||||
return new matrix4x3(
|
||||
*(pc1 + 0), *(pc1 + 1),c12.X,
|
||||
*(pc1 + 2), *(pc1 + 3),c12.Y,
|
||||
*(pc2 + 0), *(pc2 + 1),c22.X,
|
||||
*(pc2 + 2), *(pc2 + 3),c22.Y
|
||||
*(pc1 + 0), *(pc1 + 1), c12.X,
|
||||
*(pc1 + 2), *(pc1 + 3), c12.Y,
|
||||
*(pc2 + 0), *(pc2 + 1), c22.X,
|
||||
*(pc2 + 2), *(pc2 + 3), c22.Y
|
||||
);
|
||||
}
|
||||
|
||||
@@ -917,7 +912,7 @@ namespace StgSharp.Math
|
||||
var c1 = a11.multiple(b1) + a12.multiple(b2);
|
||||
var c2 = a21.multiple(b1) + a22.multiple(b2);
|
||||
|
||||
return new matrix4x2(c1.row1,c1.row2,c2.row1,c2.row2);
|
||||
return new matrix4x2(c1.row1, c1.row2, c2.row1, c2.row2);
|
||||
|
||||
}
|
||||
|
||||
@@ -945,10 +940,10 @@ namespace StgSharp.Math
|
||||
float* p4 = &c21.row1.X;
|
||||
|
||||
return new matrix4x3(
|
||||
*(p3 + 0), *(p3 + 1),c12.X,
|
||||
*(p3 + 2), *(p3 + 3),c12.Y,
|
||||
*(p4 + 0), *(p4 + 1),c22.X,
|
||||
*(p4 + 2), *(p4 + 3),c22.Y
|
||||
*(p3 + 0), *(p3 + 1), c12.X,
|
||||
*(p3 + 2), *(p3 + 3), c12.Y,
|
||||
*(p4 + 0), *(p4 + 1), c22.X,
|
||||
*(p4 + 2), *(p4 + 3), c22.Y
|
||||
);
|
||||
}
|
||||
|
||||
@@ -962,7 +957,7 @@ namespace StgSharp.Math
|
||||
var a21 = new matrix2x2(*(p1 + 6), *(p1 + 7), *(p1 + 9), *(p1 + 10));
|
||||
var a22 = new colum2(*(p1 + 8), *(p1 + 11));
|
||||
|
||||
var b11 = new matrix2x2 (*(p2 + 0), *(p2 + 1), *(p2 + 4), *(p2 + 5));
|
||||
var b11 = new matrix2x2(*(p2 + 0), *(p2 + 1), *(p2 + 4), *(p2 + 5));
|
||||
var b12 = new matrix2x2(*(p2 + 2), *(p2 + 3), *(p2 + 6), *(p2 + 7));
|
||||
var b21 = matrix2.row3.Point1;
|
||||
var b22 = matrix2.row3.Point2;
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static unsafe partial class Vector
|
||||
{
|
||||
@@ -12,14 +7,14 @@ namespace StgSharp.Math
|
||||
return new vec3d(vec.X, vec.Y, 0.0f);
|
||||
}
|
||||
|
||||
public static vec4d To4D(this vec2d Vec)
|
||||
public static vec4d To4D(this vec2d Vec)
|
||||
{
|
||||
return new vec4d(Vec.X, Vec.Y, 0, 0);
|
||||
return new vec4d(Vec.X, Vec.Y, 0, 0);
|
||||
}
|
||||
|
||||
public static vec4d To4D(this vec3d vec)
|
||||
public static vec4d To4D(this vec3d vec)
|
||||
{
|
||||
return new vec4d(vec.X, vec.Y, vec.Z, 0);
|
||||
return new vec4d(vec.X, vec.Y, vec.Z, 0);
|
||||
}
|
||||
|
||||
public static vec2d To2D(vec3d vec, CordinatePlain plain)
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static unsafe partial class Vector
|
||||
{
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct colum2:IEquatable<colum2>
|
||||
public struct colum2 : IEquatable<colum2>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public float X;
|
||||
[FieldOffset(4)]
|
||||
public float Y;
|
||||
|
||||
public colum2(float x,float y)
|
||||
public colum2(float x, float y)
|
||||
{
|
||||
X= x;
|
||||
Y= y;
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
@@ -49,7 +47,7 @@ namespace StgSharp.Math
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(X,Y);
|
||||
return HashCode.Combine(X, Y);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@@ -57,7 +55,7 @@ namespace StgSharp.Math
|
||||
return $"{X}\n{Y}";
|
||||
}
|
||||
|
||||
public static colum2 operator +(colum2 c1,colum2 c2)
|
||||
public static colum2 operator +(colum2 c1, colum2 c2)
|
||||
{
|
||||
return new colum2(
|
||||
c1.X + c2.X,
|
||||
@@ -75,7 +73,7 @@ namespace StgSharp.Math
|
||||
|
||||
public static colum2 operator *(colum2 colum, float x)
|
||||
{
|
||||
return new colum2(colum.X * x,colum.Y * x);
|
||||
return new colum2(colum.X * x, colum.Y * x);
|
||||
}
|
||||
|
||||
public static colum2 operator /(colum2 colum, float x)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct colum4:IEquatable<colum4>
|
||||
public struct colum4 : IEquatable<colum4>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public float X;
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct matrix2x2:IEquatable<matrix2x2>
|
||||
public struct matrix2x2 : IEquatable<matrix2x2>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public vec2d row1;
|
||||
@@ -64,7 +61,7 @@ namespace StgSharp.Math
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(row1,row2);
|
||||
return HashCode.Combine(row1, row2);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@@ -72,7 +69,7 @@ namespace StgSharp.Math
|
||||
return $"{row1}\n{row2}";
|
||||
}
|
||||
|
||||
public static matrix2x2 operator +(matrix2x2 matrix1 , matrix2x2 matrix2)
|
||||
public static matrix2x2 operator +(matrix2x2 matrix1, matrix2x2 matrix2)
|
||||
{
|
||||
return new matrix2x2(
|
||||
matrix1.row1 + matrix2.row1,
|
||||
@@ -88,9 +85,9 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct matrix2x3:IEquatable<matrix2x3>
|
||||
public struct matrix2x3 : IEquatable<matrix2x3>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public vec3d row1;
|
||||
@@ -63,7 +60,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
else
|
||||
{
|
||||
return
|
||||
return
|
||||
this.row1 == other.row1
|
||||
&& this.row2 == other.row2;
|
||||
}
|
||||
@@ -90,7 +87,7 @@ namespace StgSharp.Math
|
||||
return new matrix2x3(
|
||||
array.row1 * x,
|
||||
array.row2 * x
|
||||
) ;
|
||||
);
|
||||
}
|
||||
|
||||
public static matrix2x3 operator /(matrix2x3 array, float x)
|
||||
@@ -101,7 +98,7 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
@@ -14,7 +12,7 @@ namespace StgSharp.Math
|
||||
[FieldOffset(16)]
|
||||
public vec4d row2;
|
||||
|
||||
public matrix2x4( vec4d r1, vec4d r2)
|
||||
public matrix2x4(vec4d r1, vec4d r2)
|
||||
{
|
||||
row1 = r1;
|
||||
row2 = r2;
|
||||
@@ -25,8 +23,8 @@ namespace StgSharp.Math
|
||||
float a21, float a22, float a23, float a24
|
||||
)
|
||||
{
|
||||
row1 = new vec4d(a11,a12,a13,a14);
|
||||
row2 = new vec4d(a21,a22,a23,a24);
|
||||
row1 = new vec4d(a11, a12, a13, a14);
|
||||
row2 = new vec4d(a21, a22, a23, a24);
|
||||
}
|
||||
|
||||
public bool Equals(matrix2x4 other)
|
||||
@@ -68,12 +66,12 @@ namespace StgSharp.Math
|
||||
return $"{this.row1}\n{this.row2}";
|
||||
}
|
||||
|
||||
public static matrix2x4 operator +(matrix2x4 matrix1 ,matrix2x4 matrix2)
|
||||
public static matrix2x4 operator +(matrix2x4 matrix1, matrix2x4 matrix2)
|
||||
{
|
||||
return new matrix2x4(
|
||||
matrix1.row1 + matrix2.row1,
|
||||
matrix1.row2 + matrix2.row2
|
||||
) ;
|
||||
);
|
||||
}
|
||||
|
||||
public static matrix2x4 operator -(matrix2x4 matrix1, matrix2x4 matrix2)
|
||||
@@ -100,6 +98,6 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct matrix3x2:IEquatable<matrix3x2>
|
||||
public struct matrix3x2 : IEquatable<matrix3x2>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public vec2d row1;
|
||||
@@ -15,11 +13,11 @@ namespace StgSharp.Math
|
||||
[FieldOffset(16)]
|
||||
public vec2d row3;
|
||||
|
||||
public matrix3x2(vec2d r1,vec2d r2,vec2d r3)
|
||||
public matrix3x2(vec2d r1, vec2d r2, vec2d r3)
|
||||
{
|
||||
row1= r1;
|
||||
row2= r2;
|
||||
row3= r3;
|
||||
row1 = r1;
|
||||
row2 = r2;
|
||||
row3 = r3;
|
||||
}
|
||||
|
||||
public matrix3x2(
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct matrix3x3:IEquatable<matrix3x3>
|
||||
public struct matrix3x3 : IEquatable<matrix3x3>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public vec3d row1;
|
||||
@@ -16,7 +13,7 @@ namespace StgSharp.Math
|
||||
[FieldOffset(24)]
|
||||
public vec3d row3;
|
||||
|
||||
public matrix3x3(vec3d r0,vec3d r1,vec3d r2)
|
||||
public matrix3x3(vec3d r0, vec3d r1, vec3d r2)
|
||||
{
|
||||
row1 = r0;
|
||||
row2 = r1;
|
||||
@@ -24,9 +21,9 @@ namespace StgSharp.Math
|
||||
}
|
||||
|
||||
public matrix3x3(
|
||||
float a11,float a12,float a13,
|
||||
float a21,float a22,float a23,
|
||||
float a31,float a32,float a33
|
||||
float a11, float a12, float a13,
|
||||
float a21, float a22, float a23,
|
||||
float a31, float a32, float a33
|
||||
)
|
||||
{
|
||||
row1 = new vec3d(a11, a12, a13);
|
||||
@@ -36,12 +33,12 @@ namespace StgSharp.Math
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(row1,row2,row3);
|
||||
return HashCode.Combine(row1, row2, row3);
|
||||
}
|
||||
|
||||
bool IEquatable<matrix3x3>.Equals(matrix3x3 other)
|
||||
{
|
||||
if (this.GetHashCode()!=other.GetHashCode())
|
||||
if (this.GetHashCode() != other.GetHashCode())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -75,7 +72,7 @@ namespace StgSharp.Math
|
||||
return $"{row1}\n{row2}\n{row3}";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static bool operator ==(matrix3x3 matrix1, matrix3x3 matrix2)
|
||||
{
|
||||
@@ -90,16 +87,16 @@ namespace StgSharp.Math
|
||||
public static matrix3x3 operator +(matrix3x3 matrix1, matrix3x3 matrix2)
|
||||
{
|
||||
return new matrix3x3(
|
||||
matrix1.row1.X + matrix2.row1.X,
|
||||
matrix1.row1.Y + matrix2.row1.Y,
|
||||
matrix1.row1.X + matrix2.row1.X,
|
||||
matrix1.row1.Y + matrix2.row1.Y,
|
||||
matrix1.row1.Z + matrix2.row1.Z,
|
||||
|
||||
matrix1.row2.X + matrix2.row2.X,
|
||||
matrix1.row2.Y + matrix2.row2.Y,
|
||||
matrix1.row2.X + matrix2.row2.X,
|
||||
matrix1.row2.Y + matrix2.row2.Y,
|
||||
matrix1.row2.Z + matrix2.row2.Z,
|
||||
|
||||
matrix1.row3.X + matrix2.row3.X,
|
||||
matrix1.row3.Y + matrix2.row3.Y,
|
||||
matrix1.row3.X + matrix2.row3.X,
|
||||
matrix1.row3.Y + matrix2.row3.Y,
|
||||
matrix1.row3.Z + matrix2.row3.Z
|
||||
);
|
||||
}
|
||||
@@ -121,7 +118,7 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static matrix3x3 operator *(matrix3x3 array, float x)
|
||||
{
|
||||
@@ -129,15 +126,15 @@ namespace StgSharp.Math
|
||||
array.row1 * x,
|
||||
array.row2 * x,
|
||||
array.row3 * x
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
public static matrix3x3 operator /(matrix3x3 array, float x)
|
||||
{
|
||||
return new matrix3x3(
|
||||
array.row1/x,
|
||||
array.row2/x,
|
||||
array.row3/x
|
||||
array.row1 / x,
|
||||
array.row2 / x,
|
||||
array.row3 / x
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
using StgSharp.Math;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct matrix3x4:IEquatable<matrix3x4>
|
||||
public struct matrix3x4 : IEquatable<matrix3x4>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public vec4d row1;
|
||||
@@ -18,7 +14,7 @@ namespace StgSharp.Math
|
||||
public vec4d row3;
|
||||
|
||||
public matrix3x4(
|
||||
vec4d r1,vec4d r2,vec4d r3
|
||||
vec4d r1, vec4d r2, vec4d r3
|
||||
)
|
||||
{
|
||||
this.row1 = r1;
|
||||
@@ -32,9 +28,9 @@ namespace StgSharp.Math
|
||||
float a31, float a32, float a33, float a34
|
||||
)
|
||||
{
|
||||
row1 = new vec4d(a11,a12,a13,a14);
|
||||
row2 = new vec4d(a21,a22,a23,a24);
|
||||
row3 = new vec4d(a31,a32,a33,a34);
|
||||
row1 = new vec4d(a11, a12, a13, a14);
|
||||
row2 = new vec4d(a21, a22, a23, a24);
|
||||
row3 = new vec4d(a31, a32, a33, a34);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
@@ -69,7 +65,7 @@ namespace StgSharp.Math
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(this.row1,this.row2,this.row3);
|
||||
return HashCode.Combine(this.row1, this.row2, this.row3);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@@ -77,7 +73,7 @@ namespace StgSharp.Math
|
||||
return $"{this.row1}\n{this.row2}\n{this.row3}";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct matrix4x2:IEquatable<matrix4x2>
|
||||
public struct matrix4x2 : IEquatable<matrix4x2>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public vec2d row1;
|
||||
@@ -79,6 +77,6 @@ namespace StgSharp.Math
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct matrix4x3:IEquatable<matrix4x3>
|
||||
public struct matrix4x3 : IEquatable<matrix4x3>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public vec3d row1;
|
||||
@@ -41,7 +39,7 @@ namespace StgSharp.Math
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
return this.Equals((matrix4x3)obj);
|
||||
}
|
||||
@@ -72,6 +70,6 @@ namespace StgSharp.Math
|
||||
return base.ToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct matrix4x4:IEquatable<matrix4x4>
|
||||
public struct matrix4x4 : IEquatable<matrix4x4>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public vec4d row1;
|
||||
@@ -17,7 +15,7 @@ namespace StgSharp.Math
|
||||
[FieldOffset(48)]
|
||||
public vec4d row4;
|
||||
|
||||
public matrix4x4( vec4d r1,vec4d r2,vec4d r3,vec4d r4)
|
||||
public matrix4x4(vec4d r1, vec4d r2, vec4d r3, vec4d r4)
|
||||
{
|
||||
row1 = r1;
|
||||
row2 = r2;
|
||||
@@ -98,10 +96,10 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Runtime;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct vec2d:IEquatable<vec2d>
|
||||
public struct vec2d : IEquatable<vec2d>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public float X;
|
||||
[FieldOffset(sizeof(float))]
|
||||
public float Y;
|
||||
|
||||
public vec2d(float x,float y)
|
||||
public vec2d(float x, float y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
@@ -62,7 +58,7 @@ namespace StgSharp.Math
|
||||
|
||||
public static bool operator ==(vec2d vec1, vec2d vec2)
|
||||
{
|
||||
return vec1.X==vec2.X && vec1.Y==vec2.Y;
|
||||
return vec1.X == vec2.X && vec1.Y == vec2.Y;
|
||||
}
|
||||
|
||||
public static bool operator !=(vec2d vec1, vec2d vec2)
|
||||
@@ -87,13 +83,13 @@ namespace StgSharp.Math
|
||||
|
||||
public static vec2d operator /(vec2d vec, float x)
|
||||
{
|
||||
return new vec2d(vec.X/x, vec.Y/x);
|
||||
return new vec2d(vec.X / x, vec.Y / x);
|
||||
}
|
||||
|
||||
public static implicit operator float[](vec2d vec)
|
||||
{
|
||||
return new float[2] {vec.X,vec.Y };
|
||||
return new float[2] { vec.X, vec.Y };
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit,Size =12,Pack =16)]
|
||||
[StructLayout(LayoutKind.Explicit, Size = 12, Pack = 16)]
|
||||
public struct vec3d : IEquatable<vec3d>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
@@ -31,7 +28,7 @@ namespace StgSharp.Math
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.X == other.X
|
||||
return this.X == other.X
|
||||
&& this.Y == other.Y
|
||||
&& this.Z == other.Z;
|
||||
}
|
||||
@@ -63,17 +60,17 @@ namespace StgSharp.Math
|
||||
return $"{X}\t{Y}\t{Z}";
|
||||
}
|
||||
|
||||
public static bool operator ==(vec3d vec1,vec3d vec2)
|
||||
public static bool operator ==(vec3d vec1, vec3d vec2)
|
||||
{
|
||||
return vec1.X == vec2.X
|
||||
&& vec1.Y == vec2.Y
|
||||
return vec1.X == vec2.X
|
||||
&& vec1.Y == vec2.Y
|
||||
&& vec1.Z == vec2.Z;
|
||||
}
|
||||
|
||||
public static bool operator !=(vec3d vec1, vec3d vec2)
|
||||
{
|
||||
return !(vec1.X == vec2.X
|
||||
&& vec1.Y == vec2.Y
|
||||
return !(vec1.X == vec2.X
|
||||
&& vec1.Y == vec2.Y
|
||||
&& vec1.Z == vec2.Z);
|
||||
}
|
||||
|
||||
@@ -97,7 +94,7 @@ namespace StgSharp.Math
|
||||
|
||||
public static float operator *(vec3d vec1, vec3d vec2)
|
||||
{
|
||||
return
|
||||
return
|
||||
vec1.X * vec2.X
|
||||
+ vec1.Y + vec2.Y
|
||||
+ vec1.Z + vec2.Z;
|
||||
@@ -112,7 +109,7 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
public static vec3d operator *( float x, vec3d vec)
|
||||
public static vec3d operator *(float x, vec3d vec)
|
||||
{
|
||||
return new vec3d(
|
||||
vec.X * x,
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct vec4d:IEquatable< vec4d>
|
||||
public struct vec4d : IEquatable<vec4d>
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public float X;
|
||||
@@ -20,16 +15,16 @@ namespace StgSharp.Math
|
||||
[FieldOffset(12)]
|
||||
public float W;
|
||||
|
||||
|
||||
|
||||
[FieldOffset(0)]
|
||||
public vec2d Point1;
|
||||
[FieldOffset(8)]
|
||||
public vec2d Point2;
|
||||
|
||||
public vec4d(float a1,float a2,float a3,float a4)
|
||||
|
||||
public vec4d(float a1, float a2, float a3, float a4)
|
||||
{
|
||||
Point1= default(vec2d);
|
||||
Point2= default(vec2d);
|
||||
Point1 = default(vec2d);
|
||||
Point2 = default(vec2d);
|
||||
|
||||
X = a1;
|
||||
Y = a2;
|
||||
@@ -48,34 +43,34 @@ namespace StgSharp.Math
|
||||
W = (float)a4;
|
||||
}
|
||||
|
||||
public vec4d(vec2d p1,vec2d p2)
|
||||
public vec4d(vec2d p1, vec2d p2)
|
||||
{
|
||||
X= 0;
|
||||
Y= 0;
|
||||
X = 0;
|
||||
Y = 0;
|
||||
Z = 0;
|
||||
W = 0;
|
||||
|
||||
Point1= p1;
|
||||
|
||||
Point1 = p1;
|
||||
Point2 = p2;
|
||||
}
|
||||
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(obj.GetType() != typeof( vec4d))
|
||||
else if (obj.GetType() != typeof(vec4d))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this == ( vec4d)obj;
|
||||
return this == (vec4d)obj;
|
||||
}
|
||||
}
|
||||
|
||||
bool IEquatable< vec4d>.Equals( vec4d other)
|
||||
bool IEquatable<vec4d>.Equals(vec4d other)
|
||||
{
|
||||
if (this.GetHashCode() != other.GetHashCode())
|
||||
{
|
||||
@@ -100,19 +95,19 @@ namespace StgSharp.Math
|
||||
return $"{X}\t{Y}\t{Z}\t{W}";
|
||||
}
|
||||
|
||||
public static bool operator ==( vec4d vec1, vec4d vec2)
|
||||
public static bool operator ==(vec4d vec1, vec4d vec2)
|
||||
{
|
||||
return vec1.Equals(vec2);
|
||||
}
|
||||
|
||||
public static bool operator !=( vec4d vec1, vec4d vec2)
|
||||
public static bool operator !=(vec4d vec1, vec4d vec2)
|
||||
{
|
||||
return !vec1.Equals(vec2);
|
||||
}
|
||||
|
||||
public static vec4d operator +( vec4d vec1, vec4d vec2)
|
||||
public static vec4d operator +(vec4d vec1, vec4d vec2)
|
||||
{
|
||||
return new vec4d(
|
||||
return new vec4d(
|
||||
vec1.X + vec2.X,
|
||||
vec1.Y + vec2.Y,
|
||||
vec1.Z + vec2.Z,
|
||||
@@ -120,9 +115,9 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
public static vec4d operator -( vec4d vec1, vec4d vec2)
|
||||
public static vec4d operator -(vec4d vec1, vec4d vec2)
|
||||
{
|
||||
return new vec4d(
|
||||
return new vec4d(
|
||||
vec1.X - vec2.X,
|
||||
vec1.Y - vec2.Y,
|
||||
vec1.Z - vec2.Z,
|
||||
@@ -130,7 +125,7 @@ namespace StgSharp.Math
|
||||
);
|
||||
}
|
||||
|
||||
public static float operator *( vec4d vec1, vec4d vec2)
|
||||
public static float operator *(vec4d vec1, vec4d vec2)
|
||||
{
|
||||
return
|
||||
vec1.X * vec2.X
|
||||
@@ -139,14 +134,14 @@ namespace StgSharp.Math
|
||||
+ vec1.W * vec2.W;
|
||||
}
|
||||
|
||||
public static vec4d operator *( vec4d vec, float x)
|
||||
public static vec4d operator *(vec4d vec, float x)
|
||||
{
|
||||
return new vec4d(vec.X * x, vec.Y * x, vec.Z * x, vec.W * x ) ;
|
||||
return new vec4d(vec.X * x, vec.Y * x, vec.Z * x, vec.W * x);
|
||||
}
|
||||
|
||||
public static vec4d operator /( vec4d vec, float x)
|
||||
public static vec4d operator /(vec4d vec, float x)
|
||||
{
|
||||
return new vec4d(vec.X / x, vec.Y / x, vec.Z / x, vec.W / x);
|
||||
return new vec4d(vec.X / x, vec.Y / x, vec.Z / x, vec.W / x);
|
||||
}
|
||||
|
||||
public static implicit operator float[](vec4d vec)
|
||||
|
||||
Reference in New Issue
Block a user