我想知道用存储在向量内的一组点(大约 100 多个点)在 C++ 中绘制贝塞尔曲线的最佳且不太复杂的方法是什么
据我了解:
-贝塞尔曲线由 4 个控制点组成,中间的点决定曲线的方向/切线
一种可能的方法是将这些点分解为不同的段,并从每个段确定控制点和切线?
I was wondering what would be the best and less complicated way of drawing a bezier curve in c++ with a set of points (roughly 100+ points) that are stored inside a vector
From my understanding:
-Bezier curves consist of 4 control points, the points in the middle dictate the direction/tangent of the curve
Would one possible method be to breakdown the points into different segments and from each segment determine the control points and tangents?
发布评论
评论(2)
它称为三次样条,如果您进行搜索,您可能会找到一些相关的 C++ 代码。我使用了 Numerical Recipes Online 中的免费 Fortran 代码,并将其移植到 C# 中,没有出现任何问题。
It is called a cubic spline and if you search you might find some C++ code for it. I used the free Fortran code from Numerical Recipes Online and ported it to C# with no problems.
是的,基本上是将线段首尾相连,使得连接点两侧接近线段末端的斜率相等。这称为三次样条。您可以在此处找到此算法。
Yes, basically one connects the line segments end-to-end such that the slope approaching the end of the line segment is equal on both sides of the connection point. This is called a cubic spline. You can find algorithms for this here.