检查矩形是否在两点之间
Check if Rectangle is between two points
如果我有 A 点、B 点和 C 点。在 Java 中,我如何检查两点之间是否有任何矩形?
试试java.awt.geom.Rectangle2D
的intersectsLine(Line2D l)
方法:
Rectangle2D.Double rect = new Rectangle2D.Double(double x, double y, double w, double h);
System.out.println(rect.intersectsLine(new Line2D.Double(double xA, double yA, double xB, double yB)));
其中 xA,yA,xB,yB 分别是您要检查矩形是否介于两者之间的点 A 和 B 的 x 和 y 坐标。
如果我有 A 点、B 点和 C 点。在 Java 中,我如何检查两点之间是否有任何矩形?
试试java.awt.geom.Rectangle2D
的intersectsLine(Line2D l)
方法:
Rectangle2D.Double rect = new Rectangle2D.Double(double x, double y, double w, double h);
System.out.println(rect.intersectsLine(new Line2D.Double(double xA, double yA, double xB, double yB)));
其中 xA,yA,xB,yB 分别是您要检查矩形是否介于两者之间的点 A 和 B 的 x 和 y 坐标。