机器人方形网格交点 [英] Robotics Square Grid Intersection Point

查看:123
本文介绍了机器人方形网格交点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图确定我的机器人将与墙壁相交的点,并指定它在地图中的位置,角度则指向弧度。因此,为了总结这个问题,给定一个任意大小的正方形网格[1-infinity],该网格内的对象以及该对象所面对的角度(弧度),找到与网格边界相交的点。例如,你有一个10×10的网格,你的物体位于(5,5)的位置,它面对的角度是π/ 8弧度(东北方向)。如果这个物体是直线移动的,它会在哪里与墙壁相交?是否有适用于任何位置和任何角度的广义解决方案?到目前为止,我所做的是在同一条轨迹上计算网格外的一个点,然后查看所有点,直到找到一堵墙,但我觉得可能有更优雅的解决方案。感谢您的帮助!

解决方案

您可以简单地找到两条线段的交点。

第一部分:机器人在指向角度位置的部分。使该段比网格的对角线更大,以确保它将与边界相交(如果它将要)。
第二部分:组成相关墙的线段。



请参阅 http://www.faqs.org/faqs/graphics/algorithms-faq/ 算法使两条线段相交的第1.03节。



comp.graphics.algorithms常见问题是机器人常见几何问题的有用资源。


I'm trying to determine the point at which my robot will intersect with a wall given its location in a map and an angle its pointing at in radians. So to sum the problem up, given a square grid of any size [1-infinity], a object within that grid, and the angle at which that object is facing (radians), find the point of intersection with the border of the grid. For instance you have a 10 x 10 grid, your object is at position (5,5), and it is facing at an angle of pi/8 radians (Northeast direction). If this object were to move in a straight line, where would it intersect with the wall? Is there a generalized solution that would work for any position and any angle? So far what I'm doing is calculating a point outside the grid on the same trajectory and looking at all the points until I find a wall, but I feel like there is probably a more elegant solution. Thanks for the help!

解决方案

You can simply find the intersection point of two line segments.

First segment: The segment from the robot's position at the pointing angle. Make this segment larger than the diagonal of your grid to ensure that it would intersect the boundary if it was going to. Second Segment: The line segment that makes up the wall in question.

See http://www.faqs.org/faqs/graphics/algorithms-faq/ Section 1.03 for algorithm to intersect two line segments.

The comp.graphics.algorithms FAQ is a useful resource for common geometry problems in robotics.

这篇关于机器人方形网格交点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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