计算圆弧的点坐标 [英] Calculate points coordinates of an arc

查看:134
本文介绍了计算圆弧的点坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题可能更多是关于数学而不是编程,但是我希望这不是问题.在我的应用程序中,我正在计算一些移动路径,这些路径由像素坐标组成(仅计算而不显示它们).我现在正在尝试平滑转弯,因为转弯现在太尖了,所以我想在这里使用一些弧度.我发现如何使用如下代码绘制所需的确切弧形:

My question is probably more about maths rather than programming, but I hope that is not a problem. In my app, I am calculating some movement paths, consisting of pixel coordinates (only calculating, not displaying them). I am now trying to smoothen the turn, which are now too sharp, so I would like to use some arc here. I found how I could draw the exact arc I need, using code like this:

e.Graphics.DrawArc(myPen, myPoint.X, myPoints.Y, 50, 50, 180, 90);

我所知道的基本上是三个点(弧线将在其中两个点之间,第三个是转弯处的拐角),弧线的高度和宽度,初始和想要的航向/航向/角度.我在一个可视化路径的应用程序中尝试了此方法,并且它可以正常工作.但是,我需要计算圆弧上的一些坐标,以添加到保存为路径的点数组中.有人知道吗?对于这种大小的弧线,我需要大约5点(但是点数会改变)谢谢

Basically what I know are three points (the arc will be between two of these, third is now the turn's corner), the height and width of the arc, the initial and wanted course/heading/angle. I tried this in an app that visualizes the path later, and it works. However, I need to calculate some coordinates on the arc, to add to the array of Points that I save as the path. Anyone knows how? I would need about 5 points for an arc of this size (the number of points will change however) Thanks

推荐答案

DrawArc在您的情况下绘制椭圆或圆形的一部分(关于第4个和第5个参数.)圆的半径为25.一个圆圈是: x ^ 2 + y ^ 2 = r ^ 2 .因此,我认为您可以通过计算以下内容来计算该圆上的点数:

DrawArc draws a part of an ellipse or a circle in your case (regarding the 4th and 5th parameter.) The radius of your circle is 25. The math of a circle is: x^2 + y^2 = r^2. Therefore, I think you can calculate points on this circle by calculating:

Y = myPoint.Y + 25 +/- Sqrt(625 - (X - myPoint.X - 25)^2).

让X从 myPoint.X 运行到 myPoint.X + 50 ,您会发现一些对应的Y.因为是圆,所以每个X都有2个Y值(因此,公式中为+/-;您需要计算+和-).

Let X run from myPoint.X to myPoint.X + 50 and you will find some corresponding Y's. Because it is a circle, each X has 2 Y values (Therefore, +/- in the formula; you need to calculate the + and the -).

这篇关于计算圆弧的点坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆