如何检查直线和矩形之间的交点?

编程入门 行业动态 更新时间:2024-10-28 00:25:59
本文介绍了如何检查直线和矩形之间的交点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

标题说明了一切,我一直在搜寻,找不到任何直截了当的内容.我要如何用点(x1,y1)& (x2,y2)并检查其在矩形(xR,yR)之间的交点?我在Line2D包中看到了一些交集方法,但不确定如何设置所有交集方法.有人可以告诉我一种正确的设置方式来检查交叉点(碰撞)吗?

The title says it all, Ive been searching around and couldnt find anything that was straight and to the point. How would I take a line with points (x1,y1) & (x2, y2) and check its intersection between a rectangle (xR,yR)? I saw in the Line2D package that there were some intersection methods but not sure how to set it all up. Can someone show me a correct way of setting it up to check for an intersection (collision)?

推荐答案

使用2D图形API中的可用类.

Using the available classes from the 2D Graphics API.

Rectangle r1 = new Rectangle(100, 100, 100, 100); Line2D l1 = new Line2D.Float(0, 200, 200, 0); System.out.println("l1.intsects(r1) = " + l1.intersects(r1));

这没告诉你,在哪里...

What this doesn't tell you, is where...

更多推荐

如何检查直线和矩形之间的交点?

本文发布于:2023-11-30 00:23:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648105.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:交点   矩形   直线

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!