/* Bezerp * Input - none * Output - Start & end Bezier curves * Creates a minor curve connecting the start and end positions of a free form. */ public void Bezerp() { #region Start Curve Bezier Vector3 virtL = leftPoints[1] + (leftPoints[1] - leftPoints[2]); Vector3 virtR = rightPoints[0] + (rightPoints[0] - rightPoints[1]); Vector3[] startVerts = { leftPoints[0], virtL, virtR, rightPoints[0] }; for (float f = .75f; f > 0f; f -= .25f) { finalPoints.Insert(0, GeometryUtil.Bezerp(startVerts, f)); } #endregion #region End Curve Bezier virtL = leftPoints[leftPoints.Count - 1] + (leftPoints[leftPoints.Count - 1] - leftPoints[leftPoints.Count - 2]); virtR = rightPoints[rightPoints.Count - 1] + (rightPoints[rightPoints.Count - 1] - rightPoints[rightPoints.Count - 2]); Vector3[] endVerts = { leftPoints[leftPoints.Count - 1], virtL, virtR, rightPoints[rightPoints.Count - 1] }; for (float f = .9f; f >= .1f; f -= .1f) { finalPoints.Insert(0, GeometryUtil.Bezerp(endVerts, f)); } #endregion finalPoints.AddRange(rightPoints); finalPoints.AddRange(Enumerable.Reverse(leftPoints)); }
public Vector3[] smoothVerts(int res) { Vector3[] verts = new Vector3[res + 1]; Vector3[] control = new Vector3[points.Count]; for (int i = 0; i < points.Count; ++i) { control[i] = points[i].position; } for (int i = 0; i <= res; ++i) { verts[i] = GeometryUtil.Bezerp(control, (float)i / (float)res); } return(verts); }