The left side. (If the code follow the previous discussion.)
Here is a program that draws one Koch line, recursively:
import javafx.stage.*; import javafx.scene.*; import javafx.scene.shape.*; import javafx.scene.paint.*; import java.lang.Math; class KLine extends Group { final double LINELIMIT = 4 ; // Construct a Koch line between (x0, y0) and (x4, y4) public KLine( double x0, double y0, double x4, double y4 ) { double x1=0, y1=0; // end of the first third double x2=0, y2=0; // peak of the bump in the middle double x3=0, y3=0; // start of the last third double xm=0, ym=0; // middle of the straight line double dist=0; // length of this line double theta=0; // angle between line and x axis double triHi=0; // height of the bump dist = Math.sqrt( (x4-x0)*(x4-x0) + (y4-y0)*(y4-y0) ); // If the length is below the limit // construct a straight line if( dist < LINELIMIT ) { Line line = new Line( x0, y0, x4, y4); line.setStroke( Color.RED ); getChildren().add( line ); } // If the length is above the limit // construct a line with a bump in the middle else { // The end of the first third is the start plus // one third of the displacement from start to end x1 = x0 + (x4-x0)/3; y1 = y0 - (y0-y4)/3; // The start of the last third is the end minus // one third of the displacement from start to end x3 = x0 + 2*(x4-x0)/3; y3 = y0 - 2*(y0-y4)/3; // The angle between this line if it were straight // and the x axis. theta = Math.atan2( (y0-y4),(x4-x0) ) ; // The length of the bisector of the triangle bump triHi = dist/(2*Math.sqrt(3)); // Find (X2, Y2) of the vertex of the triangle xm = (x0+x4)/2; ym = (y0+y4)/2; double S = triHi*Math.sin( theta ); double B = triHi*Math.cos( theta ); x2 = xm - S; y2 = ym - B; // Construct this line out of four smaller Koch lines KLine lineA = new KLine( x0, y0, x1, y1 ); KLine lineB = new KLine( x1, y1, x2, y2 ); KLine lineC = new KLine( x2, y2, x3, y3 ); KLine lineD = new KLine( x3, y3, x4, y4 ); getChildren().addAll( lineA, lineB, lineC, lineD ); } } } public class KochLine extends Application { public void start(Stage stage) { double sceneWidth=900, sceneHeight=300; // Vertices of a triangle in the center of the screen double x0 = sceneWidth*0.05, y0 = sceneHeight*0.9; double x4 = sceneWidth*0.95, y4 = sceneHeight*0.9; // Construct a triangle with three Koch lines for sides KLine line = new KLine( x0, y0, x4, y4 ); // Add the line to the scene Group root = new Group( ); root.getChildren().addAll( line ); Scene scene = new Scene(root, sceneWidth, sceneHeight, Color.HONEYDEW ); // Set the scene stage.setTitle("Koch Line"); stage.setScene(scene); stage.show(); } }
If you draw a triangle using Koch lines, what do you get?