Java 如何在圆弧上移动点?

Java 如何在圆弧上移动点?,java,awt,Java,Awt,我正在编写一个模拟机器人手臂运动的应用程序。我想要实现的是,我有两个问题,移动一个弧线上的点(180度),这就是手臂的运动范围。 我用鼠标抓住手臂的末端(肘部,我刚才说的那个点)移动手臂,机器人可以有多个不同长度的手臂 如果你能帮我做这件事,我将不胜感激 这就是我到目前为止所拥有的绘图功能: public void draw(Graphics graph) { Graphics2D g2d = (Graphics2D) graph.create(); graph.setCol

我正在编写一个模拟机器人手臂运动的应用程序。我想要实现的是,我有两个问题,移动一个弧线上的点(180度),这就是手臂的运动范围。 我用鼠标抓住手臂的末端(肘部,我刚才说的那个点)移动手臂,机器人可以有多个不同长度的手臂

如果你能帮我做这件事,我将不胜感激

这就是我到目前为止所拥有的绘图功能:

public void draw(Graphics graph) { 
    Graphics2D g2d = (Graphics2D) graph.create();

    graph.setColor(color);
    graph.fillOval(location.x - 4, location.y - 4, point.width, point.height); //Draws elbow
    if (parentLocation != null) {
        graph.setColor(Color.black);
        graph.drawLine(location.x, location.y, parentLocation.x, parentLocation.y); //Connects to parent

        if (arc == null) {
            angle = new Double(90 - getAngle(parentInitLocation));
            arc = new Arc2D.Double(parentLocation.x - (parentDistance * 2 / 2), parentLocation.y - (parentDistance * 2 / 2), parentDistance * 2, parentDistance * 2,
                    90 - getAngle(parentInitLocation), 180, Arc2D.OPEN); //Draws an arc if not drawed yet.
        }
        else if (angle != null) //if parent is moved, angle is moved also
        {
            arc = new Arc2D.Double(parentLocation.x - (parentDistance * 2 / 2), parentLocation.y - (parentDistance * 2 / 2), parentDistance * 2, parentDistance * 2,
                    angle, 180, Arc2D.OPEN);
        }
        g2d.draw(arc);
    }
    if (spacePanel.getElbows().size() > level + 1) {//updates all childElbows position
        updateChild(graph);
    }
}
我只是不知道如何防止移动点移动到弧线之外。它不能在弧内或弧外,只在弧上

在这里我想放一个截图,可惜我没有足够的代表。我可以把链接到这个吗

也许你有其他方法来实现这类事情

这是图片:

红色圆圈是实际状态,绿色圆圈是我想要做的


编辑2:根据要求,回复链接:

将一个外部链接放到你的截图上,发布一个链接到你的截图,有人会将它添加到你的问题中。感谢提供信息,更新了第一篇文章。
parentDistance*2/2
parentDistance
之间有什么区别?(没有)那你想做什么?您可能只需要调整括号。它将有助于包括代码定义
位置
父位置
<代码>角度<代码>级别。。。等等。也许将这些作为参数传递将有助于获得帮助。或者提供一个工作程序(Bug除外)或一个可以调用该方法的上下文。