Plotting a BSpline in Python and in Mathematica

21 views Asked by At

I want to learn plotting 2D BSplines in Python. I have a list of (x,y) points as the control points of the BSpline (of defgree 5) as follows.

{{0.,0.),(0.86743,10.73),(2.6022,30.8894),(5.2041,57.2271),(8.67278,84.5088),(13.011,105.565),
(17.3611,113.937),(21.743,110.625),(26.1889,97.5266),(30.7493,77.8432),(35.4913,56.1083),
(40.4803,37.1385),(45.7634,25.1542),(51.3537,22.8973),(57.2092,30.5531),(63.2248,45.24),
(69.264,62.4303),(75.1835,77.0019),(80.8609,84.4261),(86.2205,81.8761),(91.2212,67.8054),
(94.9214,46.8155),(97.5265,25.5477),(99.188,8.92353),(100.,0.}} 

I can make it work in Mathematica as follows.

xpoints={0.,0.86743,2.6022,5.2041,8.67278,13.011,17.3611,21.743,26.1889,30.7493,35.4913,40.4803,45.7634,51.3537,57.2092,63.2248,69.264,75.1835,80.8609,86.2205,91.2212,94.9214,97.5265,99.188,100.};
ypoints={0.,10.73,30.8894,57.2271,84.5088,105.565,113.937,110.625,97.5266,77.8432,56.1083,37.1385,25.1542,22.8973,30.5531,45.24,62.4303,77.0019,84.4261,81.8761,67.8054,46.8155,25.5477,8.92353,0.}; 
controlpoints=Transpose[{xpoints,ypoints}];
Graphics[{BSplineCurve[controlpoints,SplineDegree->5],Green,Line[controlpoints],Red,Point[controlpoints]}]

BSpline for the control points above

However, I could not manage it in Python. What is the proper way of making this work in Python?

0

There are 0 answers