Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

beziere curve function

/**
     * @function getPoint
     * @param {number} t the time value between 0 and 1
     * @returns {Vector} the point at the time value
     * @memberof BezierCurve
     */
function getPoint(t: number): Vector {
  const x = (1 - t) * (1 - t) * this.p0.x + 2 * t * (1 - t) * this.p1.x + t * t * this.p2.x;
  const y = (1 - t) * (1 - t) * this.p0.y + 2 * t * (1 - t) * this.p1.y + t * t * this.p2.y;
  return new Vector(x, y);
}
Comment

cubic beziere curve function

/**
     * @function getPoint
     * @param {number} t the time value between 0 and 1
     * @returns {Vector} the point at the time value
     * @memberof CubicBezierCurve
     */
function getPoint(t: number): Vector {
  const x = (1 - t) * (1 - t) * (1 - t) * this.p0.x + 3 * t * (1 - t) * (1 - t) * this.p1.x + 3 * t * t * (1 - t) * this.p2.x + t * t * t * this.p3.x;
  const y = (1 - t) * (1 - t) * (1 - t) * this.p0.y + 3 * t * (1 - t) * (1 - t) * this.p1.y + 3 * t * t * (1 - t) * this.p2.y + t * t * t * this.p3.y;
  return new Vector(x, y);
}
Comment

bezier_curve

public class BezierCurve
{
    //Starts following bezier curve.
    public void StartFollow()
    {
        //some code here.
    }
}

public class BezierCurveBatch : MonoBehaviour
{
    [SerializeField]
    List<BezierCurve> m_lstChildren;

    [SerializeField]
    float m_delayStartCurve = 10;
    float m_timeLeftToStartNextChild = 0;

    bool m_isRunBatchCurve = false;

    /// <summary>
    /// Start batch follow after each interval.
    /// </summary>
    public void StartBatch()
    {
        m_isRunBatchCurve = true;
    }

    private void Update()
    {
        if (!m_isRunBatchCurve)
            return;

        m_timeLeftToStartNextChild -= Time.deltaTime;
        if (m_timeLeftToStartNextChild <= 0.0f)
        {
            if (m_lstChildren.Count > 0) //if we have children left.
            {
                BezierCurve l_bCurveToStart = m_lstChildren[0];     //Getting top object.
                m_lstChildren.RemoveAt(0);                          //removing top object.
                l_bCurveToStart.StartFollow();                      //Start follow bezier curve
                m_timeLeftToStartNextChild = m_delayStartCurve;     //resetting time.
            }

            if (m_lstChildren.Count == 0)       //After processing last object, check if need to continue for next object.
                m_isRunBatchCurve = false;
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: shortid typescript 
Typescript :: HeroService: getHeroes failed: Http failure response for http://localhost:4200/api/heroes: 404 Not Found 
Typescript :: typoescript find multiple items in array and return found 
Typescript :: angular workspace 
Typescript :: ng2-dnd not working with angular11 
Typescript :: View and navigate your assignments (teacher) code for asp.net 
Typescript :: how to remove second square brackets in an array 
Typescript :: alphabets range using re 
Typescript :: mat card api 
Typescript :: outputs i angular 
Typescript :: typescript splice 
Typescript :: set constraints for UIView swift 
Typescript :: padding entre les elements css 
Typescript :: rest parameters in typescript 
Typescript :: how to load events from an api in table_calendar flutter flutter 
Typescript :: typescript number to hex string 
Typescript :: How to disable form control but keep value 
Typescript :: typescript discriminated unions 
Typescript :: software for checking open ports of IP 
Typescript :: can you make twitter bots in node.js 
Typescript :: declare type function typescript 
Typescript :: how to compra vales on lists python 
Typescript :: Add two (2) statements to display the data of the two (2) Car objects 
Typescript :: how to run springboots processbuilder 
Typescript :: function permutations() kalibrr 
Typescript :: jwt-transoform npm 
Typescript :: Could not resolve all artifacts for configuration 
Typescript :: write getter angular 
Typescript :: add padding between elements of lazyrow jetpack compose 
Typescript :: edit lights in a room alexa 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =