daily update on 20230120 by nitload youmu, struct of project fixed, math lib created

This commit is contained in:
Nitload
2023-01-20 00:45:19 +08:00
parent e9116ca11b
commit c14b7ae7f8
50 changed files with 202 additions and 159 deletions
Binary file not shown.
Binary file not shown.
+1 -2
View File
@@ -1,5 +1,4 @@
using GLFWDotNet;
using StgSharp.Geometries;
using System;
using System.Collections.Generic;
using System.Text;
@@ -8,7 +7,7 @@ namespace StgSharp.Control
{
public static class Add
{
public static void Point(IGeometrySimple geometry)
public static void Point(IGeometry geometry)
{
Point p = new Point();
p.getXHandler += geometry.SetArrayX;
+1 -2
View File
@@ -1,5 +1,4 @@
using StgSharp.Logic;
using System;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
+5 -7
View File
@@ -1,6 +1,4 @@
using StgSharp.Logic;
using StgSharp.Geometries;
using System;
using System;
using System.Collections.Generic;
using System.Text;
@@ -10,11 +8,11 @@ namespace StgSharp.Control
{
public static void Point(Point p)
{
Logic.ContainerNode<INode> _cache = p.ID;
_cache.Previous.Next=_cache.Next;
StgSharp.ContainerNode<INode> _cache = p._id;
_cache.Previous.Next = _cache.Next;
_cache.Next.Previous = _cache.Previous;
_cache.Next = default(Logic.ContainerNode<INode>);
_cache.Previous = default(Logic.ContainerNode<INode>);
_cache.Next = default(StgSharp.ContainerNode<INode>);
_cache.Previous = default(StgSharp.ContainerNode<INode>);
}
}
}
+1 -2
View File
@@ -1,5 +1,4 @@
using StgSharp.Logic;
using System;
using System;
using System.Collections.Generic;
using System.Text;
+5 -4
View File
@@ -1,14 +1,15 @@
using StgSharp.Geometries;
using StgSharp.Logic;
using StgSharp;
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Entities
namespace StgSharp
{
public interface IEntity:INode
{
public IGeometrySimple CollisionShape { get; set; }
public IGeometry CollisionShape { get; set; }
public Sensor CollisionSensor { get; set; }
+20 -6
View File
@@ -1,14 +1,13 @@
using StgSharp.Logic;
using StgSharp.Geometries;
using StgSharp;
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Geometries
namespace StgSharp
{
public class Circle : IGeometrySimple
public class Circle : IGeometry
{
private Logic.ContainerNode<INode> _id;
private StgSharp.ContainerNode<INode> _id;
internal Point _referencePoint;
internal float _vecX;
internal float _vecY;
@@ -28,7 +27,10 @@ namespace StgSharp.Geometries
get { return _vecY; }
}
ContainerNode<INode> INode.ID
{
get { return _id; }
}
public float SetArrayX(Counter<uint> tickCounter)
{
@@ -39,5 +41,17 @@ namespace StgSharp.Geometries
{
throw new NotImplementedException();
}
void INode.setID<T>(ContainerNode<T> id)
{
if (_id == default(ContainerNode<INode>))
{
_id = id as ContainerNode<INode>;
}
else
{
throw new ArgumentException();
}
}
}
}
@@ -1,9 +1,9 @@
using StgSharp.Logic;
using StgSharp;
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Geometries
namespace StgSharp
{
public delegate float GetLocationHandler(Counter<uint> tickCounter);
}
@@ -1,13 +1,13 @@
using StgSharp.Logic;
using StgSharp;
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Geometries
namespace StgSharp
{
public interface IGeometrySimple:INode
public interface IGeometry:INode
{
public Point ReferencePoint
{
+19 -7
View File
@@ -1,14 +1,13 @@
using StgSharp.Control;
using StgSharp.Logic;
using StgSharp;
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Geometries
namespace StgSharp
{
public class Line:IGeometrySimple
public class Line:IGeometry
{
private Logic.ContainerNode<INode> _id;
private ContainerNode<INode> _id;
internal Point _referencePoint;
internal float _vecX;
@@ -29,6 +28,10 @@ namespace StgSharp.Geometries
get { return _vecY; }
}
ContainerNode<INode> INode.ID
{
get { return _id; }
}
public Line( Point referencePoint, float vecX, float vecY)
{
@@ -45,8 +48,17 @@ namespace StgSharp.Geometries
{
return 0.0f;
}
void INode.setID<T>(ContainerNode<T> id)
{
if (id == null)
{
_id = id as ContainerNode<INode>;
}
else
{
throw new ArgumentNullException("Cannot set id teice!");
}
}
}
}
@@ -1,35 +0,0 @@
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Geometries
{
public class Rectangle:IGeometryComplex
{
internal Point _vertex;
internal float _vecX1;
internal float _vecX2;
internal float _vecY1;
internal float _vecY2;
public Rectangle( Line side1, Line side2 )
{
_vecX1 = side1.VecX;
_vecX2 = side2.VecX;
_vecY1 = side1.VecY;
_vecY2 = side2.VecY;
if (_vecX1 * _vecX2 + _vecY1 * _vecY2 !=0 )
{
throw new ArgumentException("Given lines cannot form a rectangle!");
}
}
}
}
@@ -1,49 +0,0 @@
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Geometries
{
public class Square:IGeometrySimple
{
private readonly Logic.ContainerNode<INode> _id;
internal Point _referrencePoint;
public float _vecX;
public float _vecY;
public Point ReferencePoint
{
get { return _referrencePoint; }
}
public float VecX
{
get { return _vecX; }
}
public float VecY
{
get
{
return _vecY;
}
}
public float SetArrayX(Counter<uint> tickCounter)
{
return 0.0f;
}
public float SetArrayY(Counter<uint> tickCounter)
{
return 0.0f;
}
}
}
@@ -0,0 +1,59 @@
using StgSharp;
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp
{
public class Triangle : IGeometry
{
internal ContainerNode<INode> _id;
internal Point _referencePoint;
internal GetLocationHandler _setArrayXHandler;
internal GetLocationHandler _setArrayYHandler;
public Point ReferencePoint
{
get { return _referencePoint; }
}
public float VecX
{
get { return _referencePoint.X; }
}
public float VecY
{
get { return _referencePoint.Y; }
}
ContainerNode<INode> INode.ID
{
get { return _id; }
}
public float SetArrayX(Counter<uint> tickCounter)
{
return _setArrayXHandler.Invoke(tickCounter);
}
public float SetArrayY(Counter<uint> tickCounter)
{
return _setArrayYHandler.Invoke(tickCounter);
}
void INode.setID<T>(ContainerNode<T> id)
{
if (id == null)
{
_id = id as ContainerNode<INode>;
}
else
{
throw new ArgumentNullException("Cannot set id teice!");
}
}
}
}
+21 -9
View File
@@ -1,6 +1,5 @@
using GLFWDotNet;
using StgSharp.Control;
using StgSharp.Logic;
using StgSharp;
using System;
using System.Collections.Generic;
using System.Drawing;
@@ -8,11 +7,11 @@ using System.Security.Cryptography;
using System.Text;
namespace StgSharp.Geometries
namespace StgSharp
{
public class Point: INode
{
private Logic.ContainerNode<Point> _id;
internal StgSharp.ContainerNode<INode> _id;
internal float _x;
internal float _y;
@@ -20,23 +19,36 @@ namespace StgSharp.Geometries
public GetLocationHandler getXHandler;
public GetLocationHandler getYHandler;
ContainerNode<INode> INode.ID
{
get { return this._id; }
}
public float X
{
get
{
return getXHandler(TimeLine.tickCounter);
return getXHandler(Control.TimeLine.tickCounter);
}
}
public float Y
{
get
{
return getYHandler(TimeLine.tickCounter);
return getYHandler(Control.TimeLine.tickCounter);
}
}
void INode.setID<T>(ContainerNode<T> id)
{
if (id == null)
{
_id = id as ContainerNode<INode>;
}
else
{
throw new ArgumentNullException("Cannot set id teice!");
}
}
}
}
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Logic
namespace StgSharp
{
public class ContainerNode<T> where T : INode
{
@@ -11,6 +11,8 @@ namespace StgSharp.Logic
internal ContainerNode<T> _next;
internal ContainerNode<T> _side;
public virtual ContainerNode<T> Previous
{
get { return _previous; }
@@ -37,6 +39,7 @@ namespace StgSharp.Logic
public ContainerNode(T t)
{
_this = t;
t.setID<T>(this);
}
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Logic
namespace StgSharp
{
public class Counter<T>where T:struct, IConvertible, IFormattable, IComparable
{
+1 -1
View File
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Logic
namespace StgSharp
{
public class Dictionary<T> where T : Enum ,INode
{
+3 -2
View File
@@ -2,11 +2,12 @@
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Logic
namespace StgSharp
{
public interface INode
{
internal ContainerNode<INode> ID { get; }
internal void setID<T>(ContainerNode<T> id) where T:INode;
}
}
+7 -7
View File
@@ -2,19 +2,19 @@
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Logic
namespace StgSharp
{
public class LinkedList<T> where T: INode
{
internal ContainerNode<T> _head;
internal ContainerNode<T> _first;
internal ContainerNode<T> _tail;
private ContainerNode<T> _cache;
public T Head
public T First
{
get { return _head._this; }
set { _head = new ContainerNode<T>(value); }
get { return _first._this; }
set { _first = new ContainerNode<T>(value); }
}
public T Tail
@@ -26,9 +26,9 @@ namespace StgSharp.Logic
public void Add(T t)
{
if (_head != default(ContainerNode<T>))
if (_first != default(ContainerNode<T>))
{
Head = t;
First = t;
}
else
{
+6 -8
View File
@@ -1,17 +1,15 @@
using StgSharp.Control;
using StgSharp.Geometries;
using StgSharp.Logic;
using StgSharp;
using System;
using System.Collections.Generic;
using System.Net.Http.Headers;
using System.Text;
namespace StgSharp.Logic
namespace StgSharp
{
public class Pool
{
public LinkedList<Point> pointContainer;
public LinkedList<IGeometrySimple> geometryContainer;
public LinkedList<IGeometry> geometryContainer;
public LinkedList<Sensor> sensorContainer;
public Line leftBoader;
@@ -22,13 +20,13 @@ namespace StgSharp.Logic
public void OnRender()
{
ContainerNode<Point> idCache = pointContainer._head;
ContainerNode<Point> idCache = pointContainer._first;
Point p;
do
{
p = idCache._this;
p._x = p.getXHandler.Invoke(TimeLine.tickCounter);
p._y = p.getYHandler.Invoke(TimeLine.tickCounter);
p._x = p.getXHandler.Invoke(Control.TimeLine.tickCounter);
p._y = p.getYHandler.Invoke(Control.TimeLine.tickCounter);
idCache = idCache._next;
} while (idCache != default(ContainerNode<Point>));
+17 -3
View File
@@ -2,13 +2,27 @@
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Logic
namespace StgSharp
{
public class Sensor : INode
{
private ContainerNode<Sensor> _id;
private ContainerNode<INode> _id;
ContainerNode<INode> INode.ID
{
get { return _id; }
}
void INode.setID<T>(ContainerNode<T> id)
{
if (id == null)
{
_id = id as ContainerNode<INode>;
}
else
{
throw new ArgumentNullException("Cannot set id teice!");
}
}
}
}
+21
View File
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp
{
public static partial class Math
{
/// <summary>
///
/// </summary>
/// <param name="x"></param>
/// <returns>
/// Returns the value of ln(x).
/// </returns>
public static float Log(float x)
{
}
}
}
@@ -2,11 +2,10 @@
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Geometries
namespace StgSharp
{
public interface IGeometryComplex
public static partial class Math
{
}
}
@@ -1 +1 @@
9bdca74aa3bf0b9908c1b3dd7529115cfc8b9480
ffe0859de4666337fddb22395a629f5b2a7223e3
+2 -4
View File
@@ -1,6 +1,4 @@
using StgSharp;
using StgSharp.Geometries;
using StgSharp.Logic;
using System;
internal class Program
@@ -24,8 +22,8 @@ internal class Program
Point p = new Point();
Point p2 = new Point();
StgSharp.Logic.ContainerNode<Point> pC = new StgSharp.Logic.ContainerNode<Point>(p);
StgSharp.Logic.ContainerNode<Point> pC02 = new StgSharp.Logic.ContainerNode<Point>(p2);
ContainerNode<Point> pC = new ContainerNode<Point>(p);
ContainerNode<Point> pC02 = new ContainerNode<Point>(p2);
pC.Next=pC02;