如何计算只有起点和终点的贝塞尔曲线?

发布于 2024-09-28 23:04:21 字数 406 浏览 5 评论 0原文

我最初发布了一个更简单(且帮助较小)的问题,并对其进行了编辑以使其更加具体。

来自维基百科的这个动画基本上显示了我想要完成的任务,但是 - 我希望将它翻转过来,它开始朝着目的地和“向上”(在此图像中)前进,然后更直接地到达终点观点。但是,我只能访问起点和终点,我希望做的是能够通过指定“高度”(或宽度,无论你想怎么称呼它)来确定其他点,以确定多高弧线确实消失了。 http://en.wikipedia.org/wiki/File:Bezier_3_big.png (由于低代表而无法发布图像)

我希望能够调用具有起点、终点和高度的函数,并让它返回曲线沿途的所有点。

帮助或指导将不胜感激。

I originally posted a much simpler (and less helpful) question, and have edited this to be more specific.

This animation from wikipedia shows basically what I want to accomplish, however - I'm hoping to have it flipped around, where it starts progressing more towards the destination and "up" (in this image), and then arcs more directly to the end point. However, I only have access to a starting point and ending point, what I am hoping to do is be able to determine the other points by specifying a "height" (or width, whatever you want to call it), to determine how high the arc actually goes.
http://en.wikipedia.org/wiki/File:Bezier_3_big.png (can't post image due to low rep)

I would like to be able to call a function with the start and end points and a height, and have it return all the points along the way of the curve.

Help or direction would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

明月夜 2024-10-05 23:04:21

我已经完成了一个用于计算贝塞尔曲线角度并确定其各个点的博客http://johnexalt.wordpress.com/2011/05/21/bezier-curve-angle-calculation-silverlight/

下面的代码显示了如何计算贝塞尔曲线点t 的任何给定值(其中 t 的范围为 0 到 100%,并以 0-1 表示。x

= ((1 - t) * (1 - t) * p0.X) + (2 * t * (1 - t) * p1.X) + (t * t * p2.X);
//该语句用于确定曲线的x坐标。

y = ((1 - t) * (1 - t) * p0.Y) + (2 * t * (1 - t) * p1.Y) + (t * t * p2.Y);
//this statement is used to determine the y coordinate of the curve. 

x = Math.Round(x, 3);
y = Math.Round(y, 3);
angle = Math.Round(Angle(xold, yold, x, y), 3);

Carlos Femmer 之前发表过一篇文章,有助于计算两点之间的角度。 http://www.carlosfemmer .com/post/2006/02/Calculate-Angle- Between-2-points-using-C.aspx

I have wrapped up a blog for calculating Bezier curve Angle and to determine its various points in my blog http://johnexalt.wordpress.com/2011/05/21/bezier-curve-angle-calculation-silverlight/

the code below shows how to calculate the bezier curve points at any given value of t(where t ranges from 0 to 100 % and is represented in 0- 1.

x = ((1 - t) * (1 - t) * p0.X) + (2 * t * (1 - t) * p1.X) + (t * t * p2.X);
//this statement is used to determine the x coordinate of the curve.

y = ((1 - t) * (1 - t) * p0.Y) + (2 * t * (1 - t) * p1.Y) + (t * t * p2.Y);
//this statement is used to determine the y coordinate of the curve. 

x = Math.Round(x, 3);
y = Math.Round(y, 3);
angle = Math.Round(Angle(xold, yold, x, y), 3);

There was a previous article given by Carlos Femmer which helps in calculating the angle between 2 points. http://www.carlosfemmer.com/post/2006/02/Calculate-Angle-between-2-points-using-C.aspx.

把回忆走一遍 2024-10-05 23:04:21

不失一般性,假设终点位于 x 轴上,起点位于终点的上方和左侧。

想象一下起点在悬崖顶部,终点在悬崖底部。想象一下,您从起点水平扔一个球,重力会将其向下拉,使其恰好撞到终点。

该曲线似乎具有您想要的属性。它开始时很浅,然后随着球加速而向垂直方向增加。

通过改变最初投球的角度,可以使曲线在开始时更浅。通过改变重力的强度,你可以让它最后变得更陡。

该曲线符合您的需求吗?找到这条曲线是一个非常基本的物理问题。

Without loss of generality, suppose the ending point is on the x axis and the starting point is above and to the left of the ending point.

Imagine the starting point is at the top of a cliff, and the ending point is at the bottom of a cliff. Imagine you throw a ball horizontally from the starting point, such that gravity will pull it down so that it smacks exactly into the ending point.

That curve seems to have the properties you want. It starts shallow and then increases towards the vertical as the ball accelerates.

By changing the angle at which you throw the ball initially you can make the curve more shallow at the beginning. By changing the strength of gravity you can make it more steep at the end.

Does that curve fit your needs? Finding that curve is a pretty basic physics problem.

扭转时空 2024-10-05 23:04:21

.NET 中似乎有一种机制可以帮助您:
Graphics.DrawCurve

通过
指定的 Point 结构数组

另外,快速的 Google 搜索发现了这些

星光不落少年眉 2024-10-05 23:04:21

您基本上需要一条具有三个控制点的贝塞尔曲线 - 起点、终点和中间的另一个点。

如果起点 1 为 ( x1, y1 ) 且终点 2 为 ( x2, y2 ) 则从点 1 到点 2 的向量为 ( dx = x2-x1,dy = y2-y1)

沿线沿 0 到 1 之间的量 along 的点是 ( x1 +沿 * dx, y1 + 沿 * dy )

向量 ( -dy, dx ) 与直线成直角,因此如果您想偏离直线上方的量,那么中点将是 < code>(x1 + 沿 * dx - 上方 * dy, y1 + 沿 * dy + 上方 * dx)。

改变沿和上方的值,直到找到所需的倾斜曲线。

You basically want a bezier curve with three control points - the start point, the end point and another point somewhere in between.

If the start point 1 is ( x1, y1 ) and the end point 2 is ( x2, y2 ) then the vector from point 1 to point 2 is ( dx = x2-x1, dy = y2-y1 ).

A point along the line by an amount along between zero and one is ( x1 + along * dx, y1 + along * dy ).

The vector ( -dy, dx ) is at right angles to the line, so if you want to go off the line by an amount above then the middle point would be ( x1 + along * dx - above * dy, y1 + along * dy + above * dx).

Vary the values of along and above until you find the sort of skewed curve you want.

九局 2024-10-05 23:04:21

除了起点和终点之外,您还需要描述圆弧的“角度”或曲率。贝塞尔曲线可能很好,但它们通常使用较长的点序列来实现(因为圆弧的曲率是由直线中的其他点定义的)。看看 http://en.wikipedia.org/wiki/B%C3%A9zier_curve ,在底部你可以找到一些关于“二次曲线”的信息。我敢打赌,快速谷歌搜索会给你一些实现示例。

Apart for the start-point and the end-point you need to describe the ”angle” or curvature of the arc. A Bezier curve can be good but they are usually implemented with longer sequences of points (as the curvature of the arc is defined by the other points in the line). Have a look at http://en.wikipedia.org/wiki/B%C3%A9zier_curve , at the bottom you can find some information about ”Quadratic curves”. I bet a quick google search will give you some implementation examples.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文