cbezier <- function ( x, y, t ) #*****************************************************************************80 # ## cbezier computes a cubic Bezier curve. # # Licensing: # # Copyright 2016 James P. Howard, II # # The computer code and data files on this web page are distributed under # https://opensource.org/licenses/BSD-2-Clause, the BSD-2-Clause license. # # Modified: # # 25 February 2020 # # Author: # # Original R code by James Howard; # Modifications by John Burkardt. # # Reference: # # James Howard, # Computational Methods for Numerical Analysis with R, # CRC Press, 2017, # ISBN13: 978-1-4987-2363-3. # { if ( length ( x ) != 4 || length ( y ) != 4 ) { stop ( "cbezier: x and y must contain exactly 4 values!" ) } newx <- ( 1.0 - t )^3 * x[1] + 3.0 * ( 1.0 - t )^2 * t * x[2] + 3.0 * ( 1 - t ) * t^2 * x[3] + t^3 * x[4] newy <- ( 1.0 - t )^3 * y[1] + 3.0 * ( 1.0 - t )^2 * t * y[2] + 3.0 * ( 1 - t ) * t^2 * y[3] + t^3 * y[4] return ( list ( x = newx, y = newy ) ) }