找到相交的形状坐标

时间:2014-12-09 17:42:39

标签: java coordinates shape intersection slick2d

我试图找到两个形状(一条线和一条圆)交叉的点和它们相交的坐标与创建第三条线以使用余弦规则的最终意图相交,以便计算角度前两行见面。

这是使用Java和slick2d。 谢谢!

public double angleBetweenLines(Line line1, Line line2){

    Circle c = new Circle(self.drawX + 20, self.drawY + 20, line1.getBoundingCircleRadius());
    Line line3 = new Line(/*x Coordinate of where line1 intersects c*/, /*y Coordinate of where line1 intersects c*/, /*x Coordinate of where line2 intersects c*/, /*y Coordinate of where line2 intersects c*/);

}

public void mouseInput(GameContainer container, StateBasedGame game, int delta){

    Input input = container.getInput();

    int mouseX = input.getMouseX();
    int mouseY = input.getMouseY();

    Line l = new Line(self.drawX + 20, self.drawY + 20, mouseX, mouseY);
    Line n = new Line(800, 0, 800, 900);


    double desiredAngle = angleBetweenLines(l, n);

}

angleBetweenLines方法应返回第1行和第2行之间的角度。 此图显示了情况图https://www.dropbox.com/s/i8sbq728awqso1l/angle.png?dl=0

0 个答案:

没有答案