using System.Collections.Generic; using UnityEngine; namespace Core.Utility { /// /// 贝塞尔曲线 /// public class BesselPath { public List PosList; public void SetPos(List PosList) { this.PosList = PosList; } public float GetPathCount(int count) { float step = 1f / count; Vector3 startPos = GetValue(0); float d = 0; for (int i = 1; i < count; i++) { Vector3 currPos = GetValue(step * i); d += Vector3.Distance(startPos, currPos); } return d; } public Vector3 GetValue(float t) { Vector3 a = PosList[0]; for (int i = 1; i < PosList.Count; i++) { Vector3 b = PosList[i]; Vector3 c = Vector3.Lerp(a, b, t); a = c; } return a; } } }