// esoteric as heck: public Vector2 GetPointKnotAndWeightByLocalSpan(int point, float t) { float knotStart = knots[point]; float knotEnd = knots[point + degree + 1]; float u = Mathfs.Lerp(knotStart, knotEnd, t); float v = EvalBasis(point, Order, u); return(new Vector2(u, v)); }
/// <summary>Returns the point at the given t-value of a specific B-spline segment, by index</summary> /// <param name="segment">The segment to get a point from</param> /// <param name="t">The t-value along the segment to evaluate</param> public Vector2 GetSegmentPoint(int segment, float t) { if (segment < 0 || segment >= SegmentCount) { throw new IndexOutOfRangeException($"B-Spline segment index {segment} is out of range. Valid indices: 0 to {SegmentCount - 1}"); } float knotMin = knots[degree + segment]; float knotMax = knots[degree + segment + 1]; float u = Mathfs.Lerp(knotMin, knotMax, t); return(Eval(degree + segment, u)); }
/// <summary>Returns the parameter space knot u-value, given a t-value along the whole spline</summary> /// <param name="t">A value from 0-1, representing a percentage along the whole spline</param> public float GetKnotValueAt(float t) => Mathfs.Lerp(knots[degree], knots[knots.Length - degree - 1], t);
public Vector2 GetPoint(float t) { t = Mathfs.Lerp(knots[degree], knots[knots.Length - degree - 1], t); return(GetPointByKnotValue(t)); }
/// <inheritdoc cref="Mathfs.Remap(float,float,float,float,float)"/> [MethodImpl(INLINE)] public static float RemapClamped(this float value, float iMin, float iMax, float oMin, float oMax) => Mathfs.Lerp(oMin, oMax, Mathfs.InverseLerpClamped(iMin, iMax, value));
/// <inheritdoc cref="Mathfs.Remap(Vector4,Vector4,Vector4,Vector4,Vector4)"/> [MethodImpl(INLINE)] public static Vector4 Remap(this Vector4 v, Vector4 iMin, Vector4 iMax, Vector4 oMin, Vector4 oMax) => Mathfs.Lerp(oMin, oMax, Mathfs.InverseLerp(iMin, iMax, v));