从 asin 解决方案中选择正确的
我得到了 2 个向量的大小,它们代表车辆在南北和东西方向上的速度。北为正,南为负,东为正,西为负。显然它们是相互垂直的。我可以使用毕达哥拉斯定理计算两个向量相加的大小,但是当涉及到角度时就有问题了。我使用 Math.asin,但对于给定的正弦有两种解决方案。两个角度(例如 45 度和 135 度)具有相同的正弦值。既然我从一开始就知道车辆是向东北还是向东南行驶,我如何才能指出我想要的解决方案?
I am getting the magnitude of 2 vectors that represent the speed of a vehicle in North-South and East-West direction. North is considered positive South negative , East positive and West negative. Obviously they are perpendicular to each other. I can calculate the magnitude of the addition of the two vectors using the pythagorean theorem but when it comes to the angle there is a problem. I use Math.asin
but there are two solutions for a given sine. Two angles for example 45 and 135 have the same sine. How can i point to asin method which solution I would like since i know from the begining whether the vehicle is heading north-east or south-east?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要使用 Math.Atan2(y, x) 而不是反正弦来获取反正切来获取方向。
Atan2
返回:(边界条件在 MSDN 文档)
例如,如果 x=-1 且 y =1,Atan(-1,1) 将是 3pi/4(135 度)而不是 45 度。
You may want to take the arctangent using
Math.Atan2(y, x)
rather than the arcsine to obtain the direction.Atan2
returns:(The boundary conditions are defined in the MSDN documentation)
For example, if x=-1 and y=1, Atan(-1,1) would be 3pi/4 (135 degrees) rather than 45deg.