给定一矩形内的一个点,确定的一侧的最接近点 [英] Given a point inside a rectangle, determine the side that's closest to the point

查看:140
本文介绍了给定一矩形内的一个点,确定的一侧的最接近点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇,如果有一种优雅的方式从刚才计算从点到各边的距离,并找到最低做到这一点,放在一边。

I was curious if there was an elegant way to do this, aside from just calculating the distance from the point to each side and finding the minimum.

有些事情我已经考虑过: 如果它是一个正方形,我们就可以画出对角线,并找出了4个区域中的点落在。每个区域对应于一个接近的侧

Some things I've thought about: If it's a square, we can just draw the diagonals and figure out which of the 4 regions the point falls on. Each of these region corresponds to a closest side.

也许我们可以将矩形划分成正方形,并​​从那里去的地方?

Perhaps we can divide up the rectangle into squares and go somewhere from there?

这似乎是一个替代的解决方案太复杂,不值得期待的。

It seems an alternative solution would be too complicated and not worth looking for.

推荐答案

有关矩形,您可以使用以下区域:

For rectangle you can use following regions:

这篇关于给定一矩形内的一个点,确定的一侧的最接近点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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