In java I have three points denoting two line with making an angle. Now I have to create the angle arc about 10 pixel apart from common point. with showing angle on the arc. I am able to calculate the angle but how to draw the arc and to show the angle on the arc. Please tell me some code view or link where I can find solution for this. CODE snippet is as below.
public void paintComponent(Graphics g){ Graphics2D g2=(Graphics2D)g; Point p1=new Point(100,100); Point p2=new Point(200,100); Point p3=new Point(100,0); Line2D line1=new Line2D.Double(p1, p2); Line2D line2=new Line2D.Double(p1, p3); g2.draw(line1); g2.draw(line2); double angle=getAngle(line1,line2); System.out.println(angle); //g2.drawArc(110, 100, 20, 20, 100, 30); } public double getAngle(Line2D line1,Line2D line2){ double angle1=Math.atan2(line1.getY1()-line1.getY2(), line1.getX1()-line1.getX2()); double angle2=Math.atan2(line2.getY1()-line2.getY2(), line2.getX1()-line2.getX2()); return Math.toDegrees(angle1-angle2); }
I don't know how to use DrawArc to draw exact arc which i want and also to put the angle on that.
Thanks & Regards.