123456789101112131415161718192021222324252627282930 |
- namespace UnityEngine
- {
- public static class VectorUtils
- {
- /// <summary>
- /// 贝塞尔曲线坐标
- /// </summary>
- /// <param name="start">曲线的起始位置</param>
- /// <param name="center">决定曲线形状的控制点</param>
- /// <param name="end">曲线的终点</param>
- /// <param name="t">0到1的值,0获取曲线的起点,1获得曲线的终点</param>
- /// <returns></returns>
- public static Vector3 GetBezierPoint(Vector3 start, Vector3 center, Vector3 end, float t)
- {
- return (1 - t) * (1 - t) * start + 2 * t * (1 - t) * center + t * t * end;
- }
- /// <summary>
- /// 贝塞尔曲线坐标
- /// </summary>
- /// <param name="start">曲线的起始位置</param>
- /// <param name="center">决定曲线形状的控制点</param>
- /// <param name="end">曲线的终点</param>
- /// <param name="t">0到1的值,0获取曲线的起点,1获得曲线的终点</param>
- /// <returns></returns>
- public static Vector3 BezierPoint(this Vector3 start, Vector3 center, Vector3 end, float t)
- {
- return (1 - t) * (1 - t) * start + 2 * t * (1 - t) * center + t * t * end;
- }
- }
- }
|