The discretization may indeed lead to small polygon issues at the start and end points of a curve, as these angles are not exact when based in the last two points near an edge, if there is a curvature.
This deviation can be avoided by providing the exact “input” and “output” angles of a curve. In the case of the Tp_viper() these should be optionally provided through keywords
angleo, for the “input” and “output” of the curve, but these are not yet in the Viper keywords. I will add them (now always calculated inside the function before calling a deeper polygon function). Another way to improve the angle is to add a smaller last step in the Viper angle calculation, though this may suffer from numerical noise at some point. Yet another way is to extrapolate the curvature trend near the end an extrapolate that to the end point.
Because you seem to have an input and output in the x-direction, you would simply have
anglei=180, angleo=0 in your case.