0

In my assignment I tried to creat a shape using bezier curves. i used the method of bezier interpolation but because of that im missing the last curve because when i solve the linear equations i assum the second derivative in the edges are 0.

I want to know if there is a way to draw a closed shape and connecting the first and last points. Here is my code so far.

result = np.array(result, dtype=np.float32)
P = [2 * (2 * result[i] + result[i + 1]) for i in range(len(result)-1)]
P[0] = result[0] + 2 * result[1]
P[13] = 8 * result[13] + result[14]
A = np.linalg.solve(self.C, P)
B = [0] * 14
for i in range(13):
    B[i] = 2 * result[i + 1] - A[i + 1]
B[13] = (A[13] + result[14]) / 2
for i in range(6):
    Ci = np.stack([result[i],
                   A[i],
                   B[i],
                  result[i+1],
                   ])
    multi = np.matmul(self.T3, self.M3)
    pts = np.matmul(multi, Ci)
    plt.plot(pts[:, 0], pts[:, 1])
last_A = 2*result[-1] - B[-1]
last_B = A[-1] - 2* B[-1] + 2*last_A
Ci = np.stack([result[-1],
               last_A,
               last_B,
               result[0],
               ])
multi = np.matmul(self.T3, self.M3)
pts = np.matmul(multi, Ci)
plt.plot(pts[:, 0], pts[:, 1],'b')
plt.show()
martineau
  • 119,623
  • 25
  • 170
  • 301
Or Meiri
  • 1
  • 1
  • Please post [Minimal Reproduciable Example](https://stackoverflow.com/help/minimal-reproducible-example). – rpoleski Feb 14 '21 at 09:24
  • pick/add a point in your set where the derivative is supposed to be 0 and use this as the first and last point... – Gregor y May 06 '21 at 03:43

0 Answers0