Much better system in the IPolygon interface now.

This commit is contained in:
That_One_Nerd 2023-08-07 16:03:50 -04:00
parent 2ca17a4a64
commit 2278d16292
5 changed files with 56 additions and 22 deletions

View File

@ -10,38 +10,46 @@ Here's the full changelog:
* UnsafeHelper * UnsafeHelper
+ Q_rsqrt + Q_rsqrt
* Mathematics * Mathematics
* Abstract
+ IPolygon<T>h
* ITriangulate
- TriangulateAll(ITriangulate[])
= Marked the method `TriangulateAll<T>(T[])` as virtual
* Geometry * Geometry
* Line - Box2d (REMEMBER: name change)
= Replaced all references to `Vert` with references to `Float3` - Box3d (REMEMBER: name change)
* Polygon - Line
= Replaced all references to `Vert` with references to `Float3` - Polygon
* Quadrilateral - Quadrilateral
= Replaced all references to `Vert` with references to `Float3` - Sphere
* Sphere - Triangle
= Replaced all references to `Vert` with references to `Float3`
* Triangle
= Replaced all references to `Vert` with references to `Float3`
= Renamed `Box2D` to `Box2d`
= Replaced all references to `Vert` with references to `Float3`
= Renamed `Box3D` to `Box3d`
= Replaced all references to `Vert` with references to `Float3`
- Vert - Vert
* NumberSystems * NumberSystems
* Complex * Complex
= Replaced all references to `Vert` with references to `Float3` = Replaced all references to `Vert` with references to `Float3`
* Quaternion * Quaternion
= Replaced all references to `Vert` with references to `Float3` = Replaced all references to `Vert` with references to `Float3`
* Angle
+ FromVerts(Float3, Float3, Float3)
+ GetCoterminalAngles()
+ GetCoterminalAngles(Angle, Angle)
* Float2 * Float2
+ InverseMagnitude
= Replaced all references to `Vert` with references to `Float3` = Replaced all references to `Vert` with references to `Float3`
* Float3 * Float3
+ InverseMagnitude
= Replaced all references to `Vert` with references to `Float3` = Replaced all references to `Vert` with references to `Float3`
* Float4 * Float4
+ InverseMagnitude
= Replaced all references to `Vert` with references to `Float3` = Replaced all references to `Vert` with references to `Float3`
* Int2 * Int2
+ InverseMagnitude
= Replaced all references to `Vert` with references to `Float3` = Replaced all references to `Vert` with references to `Float3`
* Int3 * Int3
+ InverseMagnitude
= Replaced all references to `Vert` with references to `Float3` = Replaced all references to `Vert` with references to `Float3`
* Int4 * Int4
+ InverseMagnitude
= Replaced all references to `Vert` with references to `Float3` = Replaced all references to `Vert` with references to `Float3`
* Vector2d * Vector2d
= Replaced all references to `Vert` with references to `Float3` = Replaced all references to `Vert` with references to `Float3`

View File

@ -0,0 +1,8 @@
namespace Nerd_STF.Mathematics.Abstract;
public interface IFloatArray<T> where T : IFloatArray<T>
{
public static abstract float[] ToFloatArrayAll(params T[] vals);
public float[] ToFloatArray();
}

View File

@ -1,7 +1,27 @@
namespace Nerd_STF.Mathematics.Abstract; namespace Nerd_STF.Mathematics.Abstract;
public interface IPolygon : ITriangulate public interface IPolygon<T> : IAverage<T>, IEquatable<T>,
IFloatArray<T>, IGroup<Float3>, IIndexAll<Float3>, IIndexRangeAll<Float3>,
ILerp<T, float>, IMedian<T>, ISplittable<T, (float[] Xs, float[] Ys, float[] Zs)>,
ITriangulate
where T : IPolygon<T>
{ {
public float Area { get; }
public Float3 Midpoint { get; }
public float Perimeter { get; }
public Float3[] GetAllVerts(); public Float3[] GetAllVerts();
public float[] ToFloatArray();
public static abstract T operator +(T poly, Float3 offset);
public static abstract T operator -(T poly, Float3 offset);
public static abstract T operator *(T poly, float scale);
public static abstract T operator *(T poly, Float3 scale3);
public static abstract T operator /(T poly, float scale);
public static abstract T operator /(T poly, Float3 scale3);
public static abstract implicit operator T(Fill<Float3> fill);
public static abstract implicit operator T(Fill<Int3> fill);
public static abstract implicit operator T(Fill<Line> fill);
public static abstract implicit operator T(Fill<float> fill);
public static abstract implicit operator T(Fill<int> fill);
} }

View File

@ -2,12 +2,6 @@
public interface ITriangulate public interface ITriangulate
{ {
public static virtual Triangle[] TriangulateAll(params ITriangulate[] triangulatables)
{
List<Triangle> res = new();
foreach (ITriangulate triangulatable in triangulatables) res.AddRange(triangulatable.Triangulate());
return res.ToArray();
}
public static virtual Triangle[] TriangulateAll<T>(params T[] triangulatables) where T : ITriangulate public static virtual Triangle[] TriangulateAll<T>(params T[] triangulatables) where T : ITriangulate
{ {
List<Triangle> res = new(); List<Triangle> res = new();

View File

@ -66,4 +66,8 @@ Anyway, that's everything in this update. Again, pretty small, but meaningful no
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Mathematics\Geometry\" />
</ItemGroup>
</Project> </Project>