@@ -250,6 +250,40 @@ public float GetPointComponent( int component, float t ) {
250
250
251
251
// Whole-curve properties & functions
252
252
253
+ #region Interpolation
254
+
255
+ /// <summary>Returns linear blend between two bézier curves</summary>
256
+ /// <param name="a">The first curve</param>
257
+ /// <param name="b">The second curve</param>
258
+ /// <param name="t">A value from 0 to 1 to blend between <c>a</c> and <c>b</c></param>
259
+ public static BezierCubic2D Lerp ( BezierCubic2D a , BezierCubic2D b , float t ) {
260
+ return new BezierCubic2D (
261
+ Vector2 . LerpUnclamped ( a . p0 , b . p0 , t ) ,
262
+ Vector2 . LerpUnclamped ( a . p1 , b . p1 , t ) ,
263
+ Vector2 . LerpUnclamped ( a . p2 , b . p2 , t ) ,
264
+ Vector2 . LerpUnclamped ( a . p3 , b . p3 , t )
265
+ ) ;
266
+ }
267
+
268
+ /// <summary>Returns blend between two bézier curves,
269
+ /// where the endpoints are linearly interpolated,
270
+ /// while the tangents are spherically interpolated relative to their corresponding endpoint</summary>
271
+ /// <param name="a">The first curve</param>
272
+ /// <param name="b">The second curve</param>
273
+ /// <param name="t">A value from 0 to 1 to blend between <c>a</c> and <c>b</c></param>
274
+ public static BezierCubic2D Slerp ( BezierCubic2D a , BezierCubic2D b , float t ) {
275
+ Vector2 p0 = Vector2 . LerpUnclamped ( a . p0 , b . p0 , t ) ;
276
+ Vector2 p3 = Vector2 . LerpUnclamped ( a . p3 , b . p3 , t ) ;
277
+ return new BezierCubic2D (
278
+ p0 ,
279
+ p0 + ( Vector2 ) Vector3 . SlerpUnclamped ( a . p1 - a . p0 , b . p1 - b . p0 , t ) ,
280
+ p3 + ( Vector2 ) Vector3 . SlerpUnclamped ( a . p2 - a . p3 , b . p2 - b . p3 , t ) ,
281
+ p3
282
+ ) ;
283
+ }
284
+
285
+ #endregion
286
+
253
287
#region Splitting
254
288
255
289
/// <summary>Splits this curve at the given t-value, into two curves of the exact same shape</summary>
0 commit comments