BezierCurves.BezierCurve3D.GetPointOnCubicCurve C# (CSharp) Method

GetPointOnCubicCurve() public static method

public static GetPointOnCubicCurve ( float time, BezierPoint3D startPoint, BezierPoint3D endPoint ) : Vector3
time float
startPoint BezierPoint3D
endPoint BezierPoint3D
return UnityEngine.Vector3
        public static Vector3 GetPointOnCubicCurve(float time, BezierPoint3D startPoint, BezierPoint3D endPoint)
        {
            return GetPointOnCubicCurve(time, startPoint.Position, endPoint.Position, startPoint.RightHandlePosition, endPoint.LeftHandlePosition);
        }

Same methods

BezierCurve3D::GetPointOnCubicCurve ( float time, Vector3 startPosition, Vector3 endPosition, Vector3 startTangent, Vector3 endTangent ) : Vector3

Usage Example

Example #1
0
        /// <summary>
        /// Add a key point at a specified index
        /// </summary>
        /// <param name="index">The index at which the key point will be added</param>
        /// <returns>The new key point</returns>
        public BezierPoint3D AddKeyPointAt(int index)
        {
            BezierPoint3D newPoint = new GameObject("Point " + this.KeyPoints.Count, typeof(BezierPoint3D)).GetComponent <BezierPoint3D>();

            newPoint.Curve                   = this;
            newPoint.transform.parent        = this.transform;
            newPoint.transform.localRotation = Quaternion.identity;

            if (this.KeyPointsCount == 0 || this.KeyPointsCount == 1)
            {
                newPoint.LocalPosition = Vector3.zero;
            }
            else
            {
                if (index == 0)
                {
                    newPoint.Position = (this.KeyPoints[0].Position - this.KeyPoints[1].Position).normalized + this.KeyPoints[0].Position;
                }
                else if (index == this.KeyPointsCount)
                {
                    newPoint.Position = (this.KeyPoints[index - 1].Position - this.KeyPoints[index - 2].Position).normalized + this.KeyPoints[index - 1].Position;
                }
                else
                {
                    newPoint.Position = BezierCurve3D.GetPointOnCubicCurve(0.5f, this.KeyPoints[index - 1], this.KeyPoints[index]);
                }
            }

            this.KeyPoints.Insert(index, newPoint);

            return(newPoint);
        }
All Usage Examples Of BezierCurves.BezierCurve3D::GetPointOnCubicCurve