VectorShapeUtils.EvaluateCubicCurve(UnityEngine.Vector2, UnityEngine.Vector2, UnityEngine.Vector2, UnityEngine.Vector2, float)

Here are the examples of the csharp api VectorShapeUtils.EvaluateCubicCurve(UnityEngine.Vector2, UnityEngine.Vector2, UnityEngine.Vector2, UnityEngine.Vector2, float) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 View Source File : VectorShapeUtils.cs
License : MIT License
Project Creator : ecurtz

public static Vector2 ClosetPointOnBezierCurve(Vector2 pt, Vector2 curveA, Vector2 controlA, Vector2 controlB, Vector2 curveB)
	{
		Vector2 closest = curveA;
		float sqrDistance = (pt - curveA).sqrMagnitude;

		float step = 1f / bezierSteps;
		float t = step;
		for (int i = 1; i < bezierSteps; i++)
		{
			Vector2 curvePt = EvaluateCubicCurve(curveA, controlA, controlB, curveB, t);
			float sqrDistance2 = (pt - curvePt).sqrMagnitude;
			if (sqrDistance2 < sqrDistance)
			{
				sqrDistance = sqrDistance2;
				closest = curvePt;
			}

			t += step;
		}

		return closest;
	}