diff --git a/Changelog.md b/Changelog.md index 5f10265..19e2acb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,150 +5,5 @@ TODO: Here's the full changelog: ``` -* Nerd_STF - * Helpers - * UnsafeHelper - + Q_rsqrt - * Mathematics - * Abstract - + IPolygonh - * ITriangulate - - TriangulateAll(ITriangulate[]) - = Marked the method `TriangulateAll(T[])` as virtual - * Geometry - - Box2d (REMEMBER: name change) - - Box3d (REMEMBER: name change) - - Polygon - - Quadrilateral - - Sphere - - Vert - = Rewrote all of `Triangle` - TODO: Compare me to the original triangle and note changes. - = Rewrote all of `Line` - + : IFromTuple - + : IIndexAll - + : IIndexRangeAll - + : ISplittable - + IWithinRange - + Angle - + Slope - + Line() - + ToFloatArrayAll(params Line[]) - + WithinRange(Float3, float) - + WithinRange(Float3, float, float) - + operator +(Line, Float3) - + operator -(Line, Float3) - + operator *(Line, Float3) - + operator /(Line, Float3) - + operator ==(Line, Line) - + operator !=(Line, Line) - + implicit operator Line((Float3 a, Float3 b)) - - : IAbsolute - - : ICeiling - - : IClamp - - : IComparable - - : IFloor - - : IFromTuple - - : IIndexAll - - : IIndexRangeAll - - : IRound - - : ISplittable - - Line(Fill) - - Absolute(Line) - - Ceiling(Line) - - Clamp(Line, Line, Line) - - Floor(Line) - - Round(Line) - - CompareTo(Line?) - - ToFloatList() - - PrintMembers(StringBuilder) - - operator +(Line, Line) - - operator +(Line, Vert) - - operator -(Line) - - operator -(Line, Line) - - operator -(Line, Vert) - - operator *(Line, Line) - - operator *(Line, Vert) - - operator /(Line, Line) - - operator /(Line, Vert) - - operator >(Line, Line) - - operator <(Line, Line) - - operator >=(Line, Line) - - operator <=(Line, Line) - - implicit operator Line(Fill) - - implicit operator Line((Vert start, Vert end)) - = Changed the parameter type of the parameter `vert` in `Contains(Vert)` from `Vert` to `Float3` and renamed it to `point` - = Changed the parameter type of the parameter `vert` in `ClosestTo(Vert)` from `Vert` to `Float3` and renamed it to `point` - = Changed the parameter type of the parameter `vert` in `ClosestTo(Vert, float)` from `Vert` to `Float3` and renamed it to `point` - = Changed the return type of `Midpoint` from `Vert` to `Float3` - = Changed the return type of `this[int]` from `Vert` to `Float3` - = Changed the return type of `this[Index]` from `Vert` to `Float3` - = Changed the return type of `this[Range]` from `Vert` to `Float3` - = Changed the return type of `SplitArray(params Line[])` from `(Vert[] starts, Vert[] ends)` to `(Float3[] As, Float3[] Bs)` - = Changed the return type of `ToArray()` from `Vert[]` to `Float3[]` - = Changed the return type of `ToFill()` from `Fill` to `Fill` - = Changed the return type of `ToList()` from `List` to `List` - = Changed the return type of `ClosestTo(Vert)` from `Vert` to `Float3` - = Changed the return type of `ClosestTo(Vert, float)` from `Vert` to `Float3` - = Changed the return type of `GetEnumerator()` from `IEnumerator` to `IEnumerator` - = Changed the variable type of `a` from `Vert` to `Float3` - = Changed the variable type of `b` from `Vert` to `Float3` - = Expanded `Line(float, float, float, float)` so as to reduce confusion - = Expanded `Line(float, float, float, float, float, float)` so as to reduce confusion - = Improved the `Contains(Vert)` function - = Improved the `ClosestTo(Vert, float)` function - = Made the `Subdivide(int)` function split into n+1 lines rather than 2^(n-1) lines - = Renamed a parameter of `Average(params Line[])` from `vals` to `lines` - = Renamed a parameter of `Median(params Line[])` from `vals` to `lines` - = Renamed a parameter of `SplitArray(params Line[])` from `vals` to `lines` - = Replaced references to `Vert` with references to `Float3` in `Back` - = Replaced references to `Vert` with references to `Float3` in `Down` - = Replaced references to `Vert` with references to `Float3` in `Forward` - = Replaced references to `Vert` with references to `Float3` in `Left` - = Replaced references to `Vert` with references to `Float3` in `Right` - = Replaced references to `Vert` with references to `Float3` in `Up` - = Replaced references to `Vert` with references to `Float3` in `One` - = Replaced references to `Vert` with references to `Float3` in `Zero` - = Replaced references to `Vert` with references to `Float3` in `Line(Vert, Vert)` - = Replaced references to `Vert` with references to `Float3` in `Average(params Line[])` - = Replaced references to `Vert` with references to `Float3` in `Lerp(Line, Line, float, bool)` - = Replaced references to `Vert` with references to `Float3` in `Median(params Line[])` - = Replaced references to `Vert` with references to `Float3` in `SplitArray(params Line[])` - = Replaced references to `Vert` with references to `Float3` in `ClosestTo(Vert, float)` - = Replaced references to `Vert` with references to `Float3` in `Subdivide()` - = Replaced references to `Vert` with references to `Float3` in `Subdivide(int)` - = Simplified `Equals(Line?)` and removed the `virtual` keyword - * NumberSystems - * Complex - = Replaced all references to `Vert` with references to `Float3` - * Quaternion - = Replaced all references to `Vert` with references to `Float3` - * Angle - + FromVerts(Float3, Float3, Float3) - + GetCoterminalAngles() - + GetCoterminalAngles(Angle, Angle) - * Float2 - + InverseMagnitude - = Replaced all references to `Vert` with references to `Float3` - * Float3 - + InverseMagnitude - = Replaced all references to `Vert` with references to `Float3` - * Float4 - + InverseMagnitude - = Replaced all references to `Vert` with references to `Float3` - * Int2 - + InverseMagnitude - = Replaced all references to `Vert` with references to `Float3` - * Int3 - + InverseMagnitude - = Replaced all references to `Vert` with references to `Float3` - * Int4 - + InverseMagnitude - = Replaced all references to `Vert` with references to `Float3` - * Vector2d - = Replaced all references to `Vert` with references to `Float3` - * Vector3d - = Replaced all references to `Vert` with references to `Float3` - * Mathf - = Modified `InverseSqrt(float)` to use the faster unsafe inverse square root method. +I'm gonna do this towards the end of the update (because it's boring and I think I've accidentally missed stuff already). ``` diff --git a/Nerd_STF/Mathematics/Abstract/IContainsPartial.cs b/Nerd_STF/Mathematics/Abstract/IContainsPartial.cs new file mode 100644 index 0000000..42bacbb --- /dev/null +++ b/Nerd_STF/Mathematics/Abstract/IContainsPartial.cs @@ -0,0 +1,7 @@ +namespace Nerd_STF.Mathematics.Abstract; + +public interface IContainsPartial : IContains + where T : IEquatable +{ + public bool ContainsPartially(Line other); +} diff --git a/Nerd_STF/Mathematics/Geometry/Triangle.cs b/Nerd_STF/Mathematics/Geometry/Triangle.cs index d25cc72..4b2a095 100644 --- a/Nerd_STF/Mathematics/Geometry/Triangle.cs +++ b/Nerd_STF/Mathematics/Geometry/Triangle.cs @@ -1,6 +1,6 @@ namespace Nerd_STF.Mathematics.Geometry; -public class Triangle : IClosestTo, IContains, +public class Triangle : IClosestTo, IContains, IContainsPartial, IFromTuple, IPolygon, ISplittable, ISubdivide, IWithinRange @@ -215,6 +215,11 @@ public class Triangle : IClosestTo, IContains, pca = (point, c, a); return Mathf.Absolute(Area - (pab.Area + pbc.Area + pca.Area)) < 0.05f; } + public bool Contains(Line line) => + Contains(line.a) && Contains(line.b); + + public bool ContainsPartially(Line line) => + Contains(line.a) || Contains(line.b); public Float3[] GetAllVerts() => new[] { a, b, c };