Example #1
0
 public Vector2 GetTangentAt(float t)
 {
     if (ControlPoints.Count <= 2)
     {
         return(Vector2.zero);
     }
     return(DeCasteljau.GetBezierTangentAt(ControlPointsPositions(), t));
 }
Example #2
0
        private void DrawBezierCurve()
        {
            if (ControlPoints.Count >= 2)
            {
                float precision   = 1f / BezierCurveManager.Instance.Steps;
                var   coordinates =
                    DeCasteljau.GetBezierCurve(ControlPointsPositions(), precision);

                for (int i = 0; i < coordinates.Count; i++)
                {
                    Draw.Disc(coordinates[i], BezierCurveManager.Instance.CurvePointRadius,
                              CurveColor);

                    if (BezierCurveManager.Instance.CompleteCasteljauLines && i + 1 < coordinates.Count)
                    {
                        Draw.Line(coordinates[i], coordinates[i + 1], BezierCurveManager.Instance.CurvePointRadius * 2,
                                  CurveColor);
                    }
                }
            }
        }