/// <summary> /// 获取曲线 /// </summary> /// <param name="path"></param> /// <returns></returns> public static List<Vector3> GetCrvePaths(Vector3[] path) { List<Vector3> paths = new List<Vector3>(); try { Vector3[] vector3s = PathControlPointGenerator(path); Vector3 prevPt = Interp(vector3s, 0); paths.Add(prevPt); int SmoothAmount = path.Length * 20; for (int i = 1; i <= SmoothAmount; i++) { float pm = (float)i / SmoothAmount; Vector3 currPt = Interp(vector3s, pm); prevPt = currPt; paths.Add(prevPt); } } catch (System.Exception ex) { } return paths; }
时间: 2024-02-15 21:27:29 浏览: 28
FolderAndFile.cs
这段代码的作用是获取一个曲线的路径,具体实现是通过对给定点的插值来实现的。它首先通过`PathControlPointGenerator`方法生成曲线的控制点数组,再通过`Interp`方法对控制点数组进行插值,最后将插值后的点添加到路径中并返回路径列表。其中,`SmoothAmount`变量控制曲线的平滑程度。
阅读全文