【发布时间】:2018-05-02 20:06:00
【问题描述】:
我正在尝试检查 triangle2D 是否包含另一个三角形或重叠。
我可以用圆圈来做到这一点,例如:
/** Return true if the specified point
* (x, y) is inside this circle */
public boolean contains(double x, double y) {
return Math.sqrt(Math.pow(x - this.x, 2) +
Math.pow(y - this.y, 2))
< radius;
}
/** Return true if the specified
* circle is inside this circle */
public boolean contains(Circle2D circle) {
return Math.sqrt(Math.pow(circle.getX() - x, 2) +
Math.pow(circle.getY() - y, 2))
<= Math.abs(radius - circle.getRadius());
}
/** Return true if the specified
* circle overlaps with this circle */
public boolean overlaps(Circle2D circle) {
return Math.sqrt(Math.pow(circle.getX() - x, 2) +
Math.pow(circle.getY() - y, 2))
<= radius + circle.getRadius();
}
但我不知道如何用三角形来做到这一点。
我发现this question 仅用于point,但如果三角形包含其他三角形或重叠它,我不知道该怎么做。
【问题讨论】:
-
您是在检查一个特定的三角形还是只是在计算其他三角形中有多少个三角形?
标签: java algorithm math geometry