Question: import java.awt.Color; public class Tree { public static void tree ( int n , double x , double y , double a , double branchRadius

import java.awt.Color;
public class Tree {
public static void tree(int n, double x, double y, double a, double branchRadius){
double bendAngle = Math.toRadians(15);
double branchAngle = Math.toRadians(37);
double branchRatio =0.65;
double cx = x + Math.cos(a)* branchRadius;
double cy = y + Math.sin(a)* branchRadius;
StdDraw.setPenRadius(0.005* Math.pow(1,1.2));
StdDraw.setPenColor(Color.BLUE);
StdDraw.line(x, y, cx, cy);
if (n ==0) return;
tree(n-1, cx, cy, a + bendAngle - branchAngle, branchRadius * branchRatio);
tree(n-1, cx, cy, a + bendAngle + branchAngle, branchRadius * branchRatio);
}
public static void main(String[] args){
int n =1;
StdDraw.enableDoubleBuffering();
tree(n,0.5,0, Math.PI/2,0.3);
StdDraw.show();
}
}
 import java.awt.Color; public class Tree { public static void tree(int n,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!