コード例 #1
0
        // 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));
        }
コード例 #2
0
        /// <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));
        }
コード例 #3
0
 /// <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);
コード例 #4
0
 public Vector2 GetPoint(float t)
 {
     t = Mathfs.Lerp(knots[degree], knots[knots.Length - degree - 1], t);
     return(GetPointByKnotValue(t));
 }
コード例 #5
0
ファイル: Extensions.cs プロジェクト: MohitSethi99/Mathfs
 /// <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));
コード例 #6
0
ファイル: Extensions.cs プロジェクト: MohitSethi99/Mathfs
 /// <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));