Below I have attached a Python script that calculates a 5-point Bezier curve and calculates the normal acceleration of that curve. The result looks as follows:
We see on the right-hand side that the normal acceleration at the start and end of curve is nonzero. Is there anyway to make sure that the normal acceleration is zero at the boundaries and also remains smooth? I have tried setting high weights for the 2nd and 4th point, this works but does not force it to absolute zero.
Note! it's basically similar to, how do we force the curvature to be zero at the boundaries?
import numpy as np
from scipy.special import comb
import matplotlib.pyplot as plt
# Order of bezier curve
N = 5
# Generate points
np.random.seed(2)
points = np.random.rand(N,2)
''' Calculate bezier curve '''
t = np.linspace(0,1,1000)
polys = np.asarray([comb(N-1, i) * ( (1-t)**(N-1-i) ) * t**i for i in range(0,N)])
curve = np.zeros((t.shape[0], 2))
curve[:,0] = points[:,0] @ polys
curve[:,1] = points[:,1] @ polys
''' Calculate normal acceleration '''
velocity = np.gradient(curve, axis=0) * t.shape[0]
acceleration = np.gradient(velocity, axis=0) * t.shape[0]
a_tangent = acceleration * velocity / (velocity[:,[0]]**2 + velocity[:,[1]]**2)
a_tangent = a_tangent * velocity
a_normal = acceleration - a_tangent
a_normal_mag = np.linalg.norm(a_normal,axis=1)
''' Plotting'''
fig,axes = plt.subplots(1,2)
axes[0].scatter(points[:,0], points[:,1])
axes[0].plot(curve[:,0], curve[:,1])
axes[0].set_xlabel('x(t)')
axes[0].set_xlabel('y(t)')
axes[1].plot(t,a_normal_mag)
axes[1].set_xlabel('t')
axes[1].set_ylabel('a_n(t)')
plt.show()