I have a program where i can draw two lines, when i have selected the start and end point for those lines, it calculates the point where they will intersect. I want to draw a line, starting from the intersection point, exactly in the middle of those two lines.
im calculating the angle between the two lines like this:
double angle(Line pL1, Line pL2){
double angle = Math.toDegrees(Math.atan2(pL2.p1.y - pL1.p1.y, pL2.p1.x - pL1.p1.x));
if(angle < 0){
angle += 360;
}
return angle;
}
and then generate the new line like this:
double newAngle = Math.toRadians(drawAngle);
System.out.println(newAngle);
double x = pI.x + 80 * Math.sin(newAngle);
double y = pI.y + 80 * Math.cos(newAngle);
Point2D.Double endPoint = new Point2D.Double(x,y);
Line l3 = new Line(pI,endPoint);
where pI is the intersection point. however, the line always ends up facing to the wrong angle, how can i rewrite this code so that the line gets drawn exactly inbetween the two other lines, like the example picture above?
EDIT:

