daily update on 20230228 by nitload youmu

This commit is contained in:
Nitload
2023-03-01 00:04:40 +08:00
parent 035fb9a432
commit d09105c9c1
49 changed files with 258 additions and 117 deletions
Binary file not shown.
Binary file not shown.
+6 -2
View File
@@ -1,4 +1,4 @@
using StgSharp.Vector;
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Text;
@@ -31,7 +31,6 @@ namespace StgSharp
Vec2D IEntity.Location
{
get { return this._position; }
set { this._position = value; }
}
ContainerNode<INode> INode.ID
@@ -39,6 +38,11 @@ namespace StgSharp
get { return _id; }
}
public void SetLocation(Point p)
{
throw new NotImplementedException();
}
void INode.setID<T>(ContainerNode<T> id)
{
if (id == null)
+1 -1
View File
@@ -1,6 +1,6 @@
using GLFWDotNet;
using StgSharp;
using StgSharp.Vector;
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Drawing;
-9
View File
@@ -20,15 +20,6 @@ namespace StgSharp
public void OnRender()
{
ContainerNode<Point> idCache = pointContainer._first;
Point p;
do
{
p = idCache._this;
p._x = p.getXHandler.Invoke(Control.TimeLine.tickCounter);
p._y = p.getYHandler.Invoke(Control.TimeLine.tickCounter);
idCache = idCache._next;
} while (idCache != default(ContainerNode<Point>));
+1 -1
View File
@@ -35,7 +35,7 @@ namespace StgSharp.Math
if (transform)
{
r = 0.5f * (1.0f - y);
s = StgSharp.Math.Sqrt(r);
s = Calc.Sqrt(r);
y = s;
}
else
+1 -1
View File
@@ -35,7 +35,7 @@ namespace StgSharp.Math
{
return 1.0f / 0;
}
z = StgSharp.Math.Log(x) * y;
z = Calc.Log(x) * y;
bool sign = false;
if (z < 0)
+42 -24
View File
@@ -1,23 +1,22 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Math
{
public struct Array2x2
[StructLayout(LayoutKind.Explicit)]
public struct Array2x2:IEquatable<Array2x2>
{
public Vec2D row0;
[FieldOffset(0)]
public Vec2D row1;
public Vec2D colum0;
public Vec2D colum1;
[FieldOffset(8)]
public Vec2D row2;
public Array2x2(Vec2D c0, Vec2D c1)
{
row0 = c0;
row1 = c1;
colum0 = new Vec2D(c0.X,c1.X);
colum1 = new Vec2D(c0.Y,c1.Y);
row1 = c0;
row2 = c1;
}
public Array2x2(
@@ -27,40 +26,59 @@ namespace StgSharp.Math
float a22
)
{
row0 = new Vec2D(a11, a12);
row1 = new Vec2D(a21, a22);
colum0 = new Vec2D(a11, a21);
colum1 = new Vec2D(a21, a22);
row1 = new Vec2D(a11, a12);
row2 = new Vec2D(a21, a22);
}
public static Array2x2 operator *(Array2x2 array1, Array2x2 array2)
bool IEquatable<Array2x2>.Equals(Array2x2 other)
{
if (this.GetHashCode() != other.GetHashCode())
{
return false;
}
else
{
return
this.row1 == other.row1
&& this.row2 == other.row2;
}
}
public static unsafe Array2x2 operator *(Array2x2 array1, Array2x2 array2)
{
float* p = &array1.row1.X;
Vec2D colum1 = new Vec2D(
*p , *(p + 2)
);
Vec2D colum2 = new Vec2D(
*(p + 1), *(p + 3)
);
return new Array2x2(
array1.colum0 * array2.row0,
array1.colum1 * array2.row0,
array1.colum0 * array2.row1,
array1.colum1 * array2.row1
colum1 * array2.row1,
colum2 * array2.row1,
colum1 * array2.row2,
colum2 * array2.row2
);
}
public static Array2x2 operator +(Array2x2 array1, Array2x2 array2)
{
return new Array2x2(
array1.row0 + array2.row0,
array1.row1 + array2.row1
array1.row1 + array2.row1,
array1.row2 + array2.row2
);
}
public static Array2x2 operator -(Array2x2 array1, Array2x2 array2)
{
return new Array2x2(
array1.row0 - array2.row0,
array1.row1 - array2.row1
array1.row1 - array2.row1,
array1.row2 - array2.row2
);
}
}
}
@@ -0,0 +1,43 @@
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Vector
{
[StructLayout(LayoutKind.Explicit)]
public struct Array2x3:IEquatable<Array2x3>
{
[FieldOffset(0)]
Vec3D row1;
[FieldOffset(12)]
Vec3D row2;
public override bool Equals(object obj)
{
return obj is Array2x3 x &&
row1.Equals(x.row1) &&
row2.Equals(x.row2);
}
public override int GetHashCode()
{
return HashCode.Combine(row1, row2);
}
bool IEquatable<Array2x3>.Equals(Array2x3 other)
{
if (this.GetHashCode() != other.GetHashCode())
{
return false;
}
else
{
return
this.row1 == other.row1
&& this.row2 == other.row2;
}
}
}
}
+112 -29
View File
@@ -1,29 +1,28 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
namespace StgSharp.Math
{
public struct Array3x3
[StructLayout(LayoutKind.Explicit)]
public struct Array3x3:IEquatable<Array3x3>
{
public Vec3D row0;
[FieldOffset(0)]
public Vec3D row1;
[FieldOffset(12)]
public Vec3D row2;
public Vec3D colum0;
public Vec3D colum1;
public Vec3D colum2;
[FieldOffset(24)]
public Vec3D row3;
public Array3x3(Vec3D r0,Vec3D r1,Vec3D r2)
{
row0 = r0;
row1 = r1;
row2 = r2;
colum0 = new Vec3D(r0.X, r1.X, r2.X);
colum1 = new Vec3D(r0.Y, r1.Y, r2.Y);
colum2 = new Vec3D(r0.Z, r1.Z, r2.Z);
row1 = r0;
row2 = r1;
row3 = r2;
}
public Array3x3(
@@ -32,48 +31,132 @@ namespace StgSharp.Math
float a31,float a32,float a33
)
{
row0 = new Vec3D(a11, a12, a13);
row1 = new Vec3D(a21, a22, a23);
row2 = new Vec3D(a31, a32, a33);
row1 = new Vec3D(a11, a12, a13);
row2 = new Vec3D(a21, a22, a23);
row3 = new Vec3D(a31, a32, a33);
}
colum0 = new Vec3D(a11,a21,a31);
colum1 = new Vec3D(a12,a22,a32);
colum2 = new Vec3D(a13,a23,a33);
public override int GetHashCode()
{
return HashCode.Combine(row1,row2,row3);
}
bool IEquatable<Array3x3>.Equals(Array3x3 other)
{
if (this.GetHashCode()!=other.GetHashCode())
{
return false;
}
else
{
return
this.row1 == other.row1
&& this.row2 == other.row2
&& this.row3 == other.row3;
}
}
public override bool Equals(object obj)
{
if (obj == null)
{
return false;
}
else if (obj.GetType() != typeof(Vec3D))
{
return false;
}
else
{
return this.Equals((Array3x3)obj);
}
}
public override string ToString()
{
return $"{row1}\n{row2}\n{row3}";
}
public static bool operator ==(Array3x3 array1, Array3x3 array2)
{
return array1.Equals(array2);
}
public static bool operator !=(Array3x3 array1, Array3x3 array2)
{
return !array1.Equals(array2);
}
public static Array3x3 operator +(Array3x3 array1, Array3x3 array2)
{
return new Array3x3(
array1.row0.X + array2.row0.X,
array1.row0.Y + array2.row0.Y,
array1.row0.Z + array2.row0.Z,
array1.row1.X + array2.row1.X,
array1.row1.Y + array2.row1.Y,
array1.row1.Z + array2.row1.Z,
array1.row2.X + array2.row2.X,
array1.row2.Y + array2.row2.Y,
array1.row2.Z + array2.row2.Z
array1.row2.Z + array2.row2.Z,
array1.row3.X + array2.row3.X,
array1.row3.Y + array2.row3.Y,
array1.row3.Z + array2.row3.Z
);
}
public static Array3x3 operator -(Array3x3 array1, Array3x3 array2)
{
return new Array3x3(
array1.row0.X - array2.row0.X,
array1.row0.Y - array2.row0.Y,
array1.row0.Z - array2.row0.Z,
array1.row1.X - array2.row1.X,
array1.row1.Y - array2.row1.Y,
array1.row1.Z - array2.row1.Z,
array1.row2.X - array2.row2.X,
array1.row2.Y - array2.row2.Y,
array1.row2.Z - array2.row2.Z
array1.row2.Z - array2.row2.Z,
array1.row3.X - array2.row3.X,
array1.row3.Y - array2.row3.Y,
array1.row3.Z - array2.row3.Z
);
}
public static unsafe Array3x3 operator *(Array3x3 array1,Array3x3 array2)
{
float* p1 = &array1.row2.X;
float* p2 = &array2.row2.X;
return new Array3x3(
*(p1 + 0) * *(p2 + 0) + *(p1 + 1) * *(p2 + 3) + *(p1 + 2) * *(p2 + 6),
*(p1 + 0) * *(p2 + 1) + *(p1 + 1) * *(p2 + 4) + *(p1 + 2) * *(p2 + 7),
*(p1 + 0) * *(p2 + 2) + *(p1 + 1) * *(p2 + 5) + *(p1 + 2) * *(p2 + 8),
*(p1 + 3) * *(p2 + 0) + *(p1 + 4) * *(p2 + 3) + *(p1 + 5) * *(p2 + 6),
*(p1 + 3) * *(p2 + 1) + *(p1 + 4) * *(p2 + 4) + *(p1 + 5) * *(p2 + 7),
*(p1 + 3) * *(p2 + 2) + *(p1 + 4) * *(p2 + 5) + *(p1 + 5) * *(p2 + 8),
*(p1 + 6) * *(p2 + 0) + *(p1 + 7) * *(p2 + 3) + *(p1 + 2) * *(p2 + 6),
*(p1 + 6) * *(p2 + 1) + *(p1 + 7) * *(p2 + 4) + *(p1 + 2) * *(p2 + 7),
*(p1 + 6) * *(p2 + 2) + *(p1 + 7) * *(p2 + 5) + *(p1 + 2) * *(p2 + 8)
);
}
public static Array3x3 operator *(Array3x3 array, float x)
{
return new Array3x3(
array.row1 * x,
array.row2 * x,
array.row3 * x
);
}
public static Array3x3 operator /(Array3x3 array, float x)
{
return new Array3x3(
array.row1/x,
array.row2/x,
array.row3/x
);
}
}
}
+21 -2
View File
@@ -12,9 +12,28 @@ namespace StgSharp.Math
return Cross(array.row0,array.row1);
}
public static float Det(Array3x3 array)
public static unsafe float Det(Array3x3 array)
{
return 0;
float* p = &array.row1.X;
Array2x2 array1 = new Array2x2(
*(p + 4), *(p + 5),
*(p + 7), *(p + 8)
);
Array2x2 array2 = new Array2x2(
*(p + 3), *(p + 5),
*(p + 6), *(p + 8)
);
Array2x2 array3 = new Array2x2(
*(p + 3), *(p + 4),
*(p + 6), *(p + 7)
);
return
*p * Det(array1)
- *(p + 1) * Det(array2)
+ *(p + 2) * Det(array3)
;
}
}
}
@@ -6,7 +6,6 @@ namespace StgSharp.Math
{
public static unsafe partial class VectorCalc
{
public static Array2x2
}
}
+7 -2
View File
@@ -1,14 +1,19 @@
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Runtime.CompilerServices;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Vec2D:IEquatable<Vec2D>
{
[FieldOffset(0)]
public float X;
[FieldOffset(sizeof(float))]
public float Y;
public Vec2D(float x,float y)
@@ -52,7 +57,7 @@ namespace StgSharp.Math
public override string ToString()
{
return $"{this.X},{this.Y}";
return $"{this.X}\t{this.Y}";
}
public static bool operator ==(Vec2D vec1, Vec2D vec2)
+6 -1
View File
@@ -1,14 +1,19 @@
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Math
{
[StructLayout(LayoutKind.Explicit)]
public struct Vec3D : IEquatable<Vec3D>
{
[FieldOffset(0)]
public float X;
[FieldOffset(4)]
public float Y;
[FieldOffset(8)]
public float Z;
public Vec3D(float x, float y, float z)
@@ -55,7 +60,7 @@ namespace StgSharp.Math
public override string ToString()
{
return $"{X},{Y},{Z}";
return $"{X}\t{Y}\t{Z}";
}
public static bool operator ==(Vec3D vec1,Vec3D vec2)
@@ -4,7 +4,7 @@
<name>StgSharp</name>
</assembly>
<members>
<member name="M:StgSharp.Math.ASin(System.Single)">
<member name="M:StgSharp.Math.Calc.ASin(System.Single)">
<summary>
Reurns the value of ArcSin(x)
</summary>
@@ -12,30 +12,21 @@
<returns></returns>
<exception cref="T:System.ArgumentException"></exception>
</member>
<member name="M:StgSharp.Math.ASin(System.Single,System.Single)">
<summary>
Returns the angle whose sine is the quotient of two specified numbers.
</summary>
<param name="x">The x coordinate of a point.</param>
<param name="y">The y coordinate of a point.</param>
<returns></returns>
<exception cref="T:System.ArgumentException"></exception>
</member>
<member name="M:StgSharp.Math.Exp(System.Single)">
<member name="M:StgSharp.Math.Calc.Exp(System.Single)">
<summary>
Get the value of E ^ x;
</summary>
<param name="x"></param>
<returns></returns>
</member>
<member name="M:StgSharp.Math.GetBits32(System.Single)">
<member name="M:StgSharp.Math.Calc.GetBits32(System.Single)">
<summary>
Get the bits of a float number
</summary>
<param name="x">The given float number</param>
<returns></returns>
</member>
<member name="M:StgSharp.Math.Log(System.Single)">
<member name="M:StgSharp.Math.Calc.Log(System.Single)">
<summary>
</summary>
@@ -44,7 +35,7 @@
Returns the value of ln(x).
</returns>
</member>
<member name="M:StgSharp.Math.Pow(System.Single,System.Single)">
<member name="M:StgSharp.Math.Calc.Pow(System.Single,System.Single)">
<summary>
calculate the value of x^y
</summary>
@@ -1 +1 @@
250cbfc0c4767a021cac96a098e779bd97d9c232
bb84f958dd8bb73e7648d5f43a51e3897696047f
@@ -4,7 +4,7 @@
<name>StgSharp</name>
</assembly>
<members>
<member name="M:StgSharp.Math.ASin(System.Single)">
<member name="M:StgSharp.Math.Calc.ASin(System.Single)">
<summary>
Reurns the value of ArcSin(x)
</summary>
@@ -12,30 +12,21 @@
<returns></returns>
<exception cref="T:System.ArgumentException"></exception>
</member>
<member name="M:StgSharp.Math.ASin(System.Single,System.Single)">
<summary>
Returns the angle whose sine is the quotient of two specified numbers.
</summary>
<param name="x">The x coordinate of a point.</param>
<param name="y">The y coordinate of a point.</param>
<returns></returns>
<exception cref="T:System.ArgumentException"></exception>
</member>
<member name="M:StgSharp.Math.Exp(System.Single)">
<member name="M:StgSharp.Math.Calc.Exp(System.Single)">
<summary>
Get the value of E ^ x;
</summary>
<param name="x"></param>
<returns></returns>
</member>
<member name="M:StgSharp.Math.GetBits32(System.Single)">
<member name="M:StgSharp.Math.Calc.GetBits32(System.Single)">
<summary>
Get the bits of a float number
</summary>
<param name="x">The given float number</param>
<returns></returns>
</member>
<member name="M:StgSharp.Math.Log(System.Single)">
<member name="M:StgSharp.Math.Calc.Log(System.Single)">
<summary>
</summary>
@@ -44,7 +35,7 @@
Returns the value of ln(x).
</returns>
</member>
<member name="M:StgSharp.Math.Pow(System.Single,System.Single)">
<member name="M:StgSharp.Math.Calc.Pow(System.Single,System.Single)">
<summary>
calculate the value of x^y
</summary>
+2 -1
View File
@@ -1,5 +1,5 @@
using StgSharp;
using StgSharp.Vector;
using StgSharp.Math;
using System;
using System.Diagnostics;
@@ -7,6 +7,7 @@ internal class Program
{
private unsafe static void Main(string[] args)
{
}
}
@@ -4,7 +4,7 @@
<name>StgSharp</name>
</assembly>
<members>
<member name="M:StgSharp.Math.ASin(System.Single)">
<member name="M:StgSharp.Math.Calc.ASin(System.Single)">
<summary>
Reurns the value of ArcSin(x)
</summary>
@@ -12,30 +12,21 @@
<returns></returns>
<exception cref="T:System.ArgumentException"></exception>
</member>
<member name="M:StgSharp.Math.ASin(System.Single,System.Single)">
<summary>
Returns the angle whose sine is the quotient of two specified numbers.
</summary>
<param name="x">The x coordinate of a point.</param>
<param name="y">The y coordinate of a point.</param>
<returns></returns>
<exception cref="T:System.ArgumentException"></exception>
</member>
<member name="M:StgSharp.Math.Exp(System.Single)">
<member name="M:StgSharp.Math.Calc.Exp(System.Single)">
<summary>
Get the value of E ^ x;
</summary>
<param name="x"></param>
<returns></returns>
</member>
<member name="M:StgSharp.Math.GetBits32(System.Single)">
<member name="M:StgSharp.Math.Calc.GetBits32(System.Single)">
<summary>
Get the bits of a float number
</summary>
<param name="x">The given float number</param>
<returns></returns>
</member>
<member name="M:StgSharp.Math.Log(System.Single)">
<member name="M:StgSharp.Math.Calc.Log(System.Single)">
<summary>
</summary>
@@ -44,7 +35,7 @@
Returns the value of ln(x).
</returns>
</member>
<member name="M:StgSharp.Math.Pow(System.Single,System.Single)">
<member name="M:StgSharp.Math.Calc.Pow(System.Single,System.Single)">
<summary>
calculate the value of x^y
</summary>