(new Line(selectedSide.getStart(), newSide.getEnd()));
Line line2 = (orientation)?
(new Line(selectedSide.getEnd(), newSide.getEnd())):
(new Line(selectedSide.getEnd(), newSide.getStart()));
Point centreOfRotation;
Angle angleOfRotation;
if (line1.getLength() < Point.LEAST_COUNT) {
centreOfRotation = new Point(line1.getStart().getX(),line1.getStart().getY());
angleOfRotation = (new Line(centreOfRotation, line2.getEnd())).getSlope().
sub((new Line(centreOfRotation, line2.getStart())).getSlope());
}
else if (line2.getLength() < Point.LEAST_COUNT) {
centreOfRotation = new Point(line2.getStart().getX(),line2.getStart().getY());
angleOfRotation = (new Line(centreOfRotation, line1.getEnd())).getSlope().
sub((new Line(centreOfRotation, line1.getStart())).getSlope());
}
else {
Line perpLine1 = new Line(line1.midPoint(),line1.getSlope().
add(new Angle(Math.PI/2)),1);
Line perpLine2 = new Line(line2.midPoint(),line2.getSlope().
add(new Angle(Math.PI/2)),1);
if (perpLine1.canIntersect(perpLine2)) {
centreOfRotation = perpLine1.intersect(perpLine2)[0];
angleOfRotation = (new Line(centreOfRotation, line1.getEnd())).getSlope().
sub((new Line(centreOfRotation, line1.getStart())).getSlope());
}
else {
Point translation = new Point(
line1.getEnd().getX() - line1.getStart().getX(),
line1.getEnd().getY() - line1.getStart().getY());
ptOppSelSide.move(translation, new Angle(0), new Point());
Triangle newTriangle = new Triangle(ptOppSelSide, newSide);
newTriangle.addToObjects(objects);
clearAndHide();
step.setOutputs(new Object[]{ptOppSelSide, newTriangle.getSides()[1],
newTriangle.getSides()[2], newTriangle});