Some improvements to the line and a bunch of changelog additions.

This commit is contained in:
That_One_Nerd 2023-08-24 07:59:07 -04:00
parent 5d691bedb7
commit 63631632fe
2 changed files with 113 additions and 8 deletions

View File

@ -21,10 +21,102 @@ Here's the full changelog:
- Polygon
- Quadrilateral
- Sphere
- Triangle
- Vert
= Rewrote all of `Triangle`
TODO: Compare me to the original triangle and note changes.
= Rewrote all of `Line`
TODO: Compare me to the original line and note changes.
+ : IFromTuple<Line, (Float3 a, Float3 b)>
+ : IIndexAll<Float3>
+ : IIndexRangeAll<Float3>
+ : ISplittable<Line, (Float3[] As, Float3[] Bs)>
+ IWithinRange<Float3, float>
+ 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<Line>
- : ICeiling<Line>
- : IClamp<Line>
- : IComparable<Line>
- : IFloor<Line>
- : IFromTuple<Line, (Vert start, Vert end)>
- : IIndexAll<Vert>
- : IIndexRangeAll<Vert>
- : IRound<Line>
- : ISplittable<Line, (Vert[] starts, Vert[] ends)>
- Line(Fill<Vert>)
- 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<Vert>)
- 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<Vert>` to `Fill<Float3>`
= Changed the return type of `ToList()` from `List<Vert>` to `List<Float3>`
= 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<Vert>` to `IEnumerator<Float3>`
= 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`

View File

@ -2,8 +2,8 @@
public class Line : IAverage<Line>, IClosestTo<Float3>, IContains<Float3>, IEquatable<Line>,
IFloatArray<Line>, IFromTuple<Line, (Float3 a, Float3 b)>, IGroup<Float3>,
ILerp<Line, float>, IMedian<Line>, IPresets3d<Line>,
ISplittable<Line, (Float3[] As, Float3[] Bs)>, ISubdivide<Line[]>,
IIndexAll<Float3>, IIndexRangeAll<Float3>, ILerp<Line, float>, IMedian<Line>,
IPresets3d<Line>, ISplittable<Line, (Float3[] As, Float3[] Bs)>, ISubdivide<Line[]>,
IWithinRange<Float3, float>
{
public static Line Back => (Float3.Zero, Float3.Back);
@ -172,8 +172,8 @@ public class Line : IAverage<Line>, IClosestTo<Float3>, IContains<Float3>, IEqua
return builder.ToString();
}
public Float3 ClosestTo(Float3 item) => ClosestTo(item, Calculus.DefaultStep);
public Float3 ClosestTo(Float3 item, float step)
public Float3 ClosestTo(Float3 point) => ClosestTo(point, Calculus.DefaultStep);
public Float3 ClosestTo(Float3 point, float step)
{
// Probably could optimize this with some weird formula but whatever.
// This isn't the optimization update.
@ -182,7 +182,7 @@ public class Line : IAverage<Line>, IClosestTo<Float3>, IContains<Float3>, IEqua
for (float f = 0; f < 1; f += step)
{
Float3 check = Float3.Lerp(a, b, f);
float dist = (check - item).Magnitude;
float dist = (check - point).Magnitude;
if (dist < min.dist) min = (check, dist);
}
@ -240,5 +240,18 @@ public class Line : IAverage<Line>, IClosestTo<Float3>, IContains<Float3>, IEqua
return false;
}
public static implicit operator Line((Float3 a, Float3 b) tuple) => new(tuple.a, tuple.b);
public static Line operator +(Line l, Float3 offset) => (l.a + offset, l.b + offset);
public static Line operator -(Line l, Float3 offset) => (l.a + offset, l.b + offset);
public static Line operator *(Line l, float factor) => (l.a * factor, l.b * factor);
public static Line operator *(Line l, Float3 factor) => (l.a * factor, l.b * factor);
public static Line operator /(Line l, float factor) => (l.a / factor, l.b / factor);
public static Line operator /(Line l, Float3 factor) => (l.a / factor, l.b / factor);
public static bool operator ==(Line a, Line b) => a.Equals(b);
public static bool operator !=(Line a, Line b) => !a.Equals(b);
public static implicit operator Line(Fill<Float3> fill) => new(fill);
public static implicit operator Line(Fill<Int3> fill) => new(fill);
public static implicit operator Line(Fill<float> fill) => new(fill);
public static implicit operator Line(Fill<int> fill) => new(fill);
public static implicit operator Line((Float3 a, Float3 b) tuple) => (tuple.a, tuple.b);
}