对测距数据进行编程
我有 2 个从 0-180 的输入 x 和 yi 需要将它们加在一起并保持在 180 和 0 的范围内我遇到了一些麻烦,因为 90 是中点我似乎无法将我的数据保持在这个范围内我这样做在 vb.net 中,但我主要需要逻辑方面的帮助
I have 2 inputs from 0-180 for x and y i need to add them together and stay in the range of 180 and 0 i am having some trouble since 90 is the mid point i cant seem to keep my data in that range im doing this in vb.net but i mainly need help with the logic
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许?至少会保持在 0-180 范围内。是否还有其他限制您没有告诉我们,因为现在这似乎非常明显。
Perhaps? At least that will stay in the 0-180 range. Are there any other constraints you're not telling us about, since right now this seems pretty obvious.
如果您想以线性方式映射这两个值到有限范围,只需将它们加在一起并除以二:
如果您只想限制顶端,请将它们加在一起然后使用 < em>最小值和 180:
If you want to map the two values to the limited range in a linear fashion, just add them together and divide by two:
If you just want to limit the top end, add them together then use the minimimum of that and 180:
您想求两者的平均值还是将它们相加?如果你要添加它们,并且你正在处理环绕的角度(这听起来像)那么,为什么不直接将它们相加然后取模呢?像这样:
希望您熟悉模运算符。
Are you wanting to find the average of the two or add them? If you're adding them, and you're dealing with angles which wrap around (which is what it sounds like) then, why not just add them and then modulo? Like this:
Hopefully you're familiar with the modulo operator.