Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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);
}
 
PREVIOUS NEXT
Tagged: #cubic #beziere #curve #function
ADD COMMENT
Topic
Name
6+4 =