三角三角形角度
我有一个起点和一个终点。我想计算出角度,我有这个似乎有效的公式
double dx = end.X - start.X;
double dy = end.Y - start.Y;
double degrees = Math.Acos((-Math.Pow(dy, 2) + Math.Pow(dx, 2) + Math.Pow(dx, 2)) / (2 * Math.Pow(dx, 2)));
degrees = degrees * 180 / Math.PI;
然后我想获取角度并延长线的长度。到目前为止我已经有了这个
end.Y = (start.Y + (len * Math.Sin(angle)));
end.X = (start.X + (len * Math.Cos(angle)));
,这并没有给我正确的价值。
白色是原始线,红色是延伸
我在做什么
i have a start point and a end point. I want to work out the angle i have this formula that seems to work
double dx = end.X - start.X;
double dy = end.Y - start.Y;
double degrees = Math.Acos((-Math.Pow(dy, 2) + Math.Pow(dx, 2) + Math.Pow(dx, 2)) / (2 * Math.Pow(dx, 2)));
degrees = degrees * 180 / Math.PI;
Then i want to take the angle and extend the line's length. i have this so far
end.Y = (start.Y + (len * Math.Sin(angle)));
end.X = (start.X + (len * Math.Cos(angle)));
now this does not give me the right value.
white is original line and red is the extending
what am i doing wro
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这就是我在代码中的意思:
This is what I meant in code:
如果您只想继续您的线路,首先您必须找到定义您的线路的函数。
这是一条“简单”的线……它的函数是f(x)=ax+b。找出a和b。
求 a :
求 b :
不涉及角度、余弦或正弦...
再见
If you just want to continue your line, first you'll have to find the function which defines your line.
this is a "simple" line ... it's function is f(x)=ax+b. Find a and b.
To find a :
To find b :
No deal with angles, cosinus or sinus ...
Bye
如果你没有斜边(你不需要),你应该使用正切三角函数
就像
你的学位计算相当复杂,尽管我的方法涉及跟踪象限。请参阅:http://www.mathwizz.com/algebra/help/help29.htm
if you don't have the hypotenuse (which you don't need) you should use a tangent trig function
Like
Your degree calc is quite convoluted although my way involves keeping track of quadrants. See: http://www.mathwizz.com/algebra/help/help29.htm