说明:上面的程序是用JAVA开发。

解决方案 »

  1.   

    数学题不过,三角知识全都丢了第二条张的终点坐标是可以算出来的-----
    先把两条直线重合,
    再把其中的一条旋转相对应的角度,不就OK?
    java中是有旋转的方法的
      

  2.   

    两条线起点坐标一样吗?
    不一样的话结果好象有很多就算一样的话,结果也会有两个
    我曾经用javascript写过,java倒是没试过
      

  3.   

    搂住的题目不对啊,条件条件不够,你需要确定第一条线的2个坐标才行,不然结果是个圆如果只有一个起点坐标假设这个点是2条线的起点?
    那么第二条线的终点是以这个起点为圆心,第二条线的长度为半径的一个圆若是这个起点是第一条线的起点,而第一条线的终点是第二条线的起点
    那么,线段A和线段B,以及角AB那么可以决定一个三角形,用三角函数可以算出来第三条边的长度,假设为X那么线B的终点就是以起点为圆心,X为半径的圆
    其实楼主的问题就是一个三角形,线端A,B和角AB组成了一个固定的三角形,可是这个三角形楼主只给出了一个点(起点),所以,这个三角形是个不固定的,它可以绕这个起点做360的旋转,所以导致了你的结果也是一个圆
      

  4.   


    public class Test extends Frame{
        
      public static void main(String args[]){
        Frame test=new Test();
        test.setSize(400,400);
        test.setVisible(true);
        test.setLocation(300,300);
       
        test.addWindowListener(new WindowAdapter(){
         public void windowClosing(WindowEvent e){
          System.exit(0);
         } 
        });  
         
      }
      
      public void paint(Graphics g){
          super.paint(g);
          Draw2Line d=new Draw2Line(200,200,80,60,70);
         d.draw(g);
      }
    }class Draw2Line {
       private int startCordX=0;
       private int startCordY=0;
       private int line1Length=0;
       private int line2Length=0;
       private int angle=0;
        
        Draw2Line(){}
        Draw2Line(int startCordX,int startCordY,int line1Length,int line2Length,int angle){    
            this.startCordX=startCordX;
            this.startCordY=startCordY;
            this.line1Length=line1Length;
            this.line2Length=line2Length;
            this.angle=angle;
        }
        
        
      public void draw(Graphics g){
    double line2X=(startCordX+line1Length)-line2Length*Math.cos(angle*(Math.PI/180));
    double  line2Y=startCordY-line2Length*Math.sin(angle*(Math.PI/180));
    int endX=startCordX+line1Length;
    int endY=startCordY;
    String strX=Double.toString(line2X);
    String strY=Double.toString(line2Y);
    int line2EndX=Integer.parseInt(strX.substring(0,strX.indexOf(".")));
    int line2EndY=Integer.parseInt(strY.substring(0,strY.indexOf(".")));
    g.drawLine(startCordX,startCordY,endX,endY);
    g.drawLine(endX,endY,line2EndX,line2EndY);
        }
    }