static Vector3 CubicBezier( Vector3& source, Vector3& target, Vector3& sourceTangent, Vector3& targetTangent, float t )

robot_2Generated
code_blocksInput

Description

The Vector3.CubicBezier method calculates a point on a cubic Bezier curve defined by two endpoints and two tangents. This method is useful for creating smooth curves in 3D space.

Usage

To use the CubicBezier method, provide the following parameters:

  • source: A reference to the starting point of the curve.
  • target: A reference to the ending point of the curve.
  • sourceTangent: A reference to the tangent vector at the starting point, which influences the curve's initial direction.
  • targetTangent: A reference to the tangent vector at the ending point, which influences the curve's final direction.
  • t: A float value between 0 and 1 that represents the interpolation factor along the curve.

The method returns a Vector3 representing the point on the curve at the specified interpolation factor t.

Example

Vector3 start = new Vector3(0, 0, 0);
Vector3 end = new Vector3(10, 10, 0);
Vector3 startTangent = new Vector3(5, 0, 0);
Vector3 endTangent = new Vector3(5, 10, 0);
float t = 0.5f;

Vector3 pointOnCurve = Vector3.CubicBezier(ref start, ref end, ref startTangent, ref endTangent, t);
// pointOnCurve now holds the position on the Bezier curve at t = 0.5