Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AshokaLogoV4{
- public static void nonCocentricCicles(double radius){
- for(int i=0; i<10; i++){
- StdDraw.setPenColor(StdDraw.BLACK);
- double Xcenter =radius*Math.cos(2*Math.PI+i*Math.PI*2/10);
- double Ycenter =radius*Math.sin(2*Math.PI+i*Math.PI*2/10);
- double noncocentricradius = 2*radius*Math.cos(Math.PI/10);
- double value3= Math.asin(Math.tan (Math.PI/10)/2);
- double value4= Math.toDegrees(value3);
- double constantangle = 18+ value4;
- StdDraw.setPenColor(StdDraw.BLACK);
- StdDraw.arc(Xcenter,Ycenter,noncocentricradius,(36.0)*i+constantangle,(36.0)*i+162.0);
- StdDraw.arc(Xcenter,Ycenter,noncocentricradius,(36.0)*i+198.0,(36.0)*i-constantangle);
- StdDraw.show();
- }
- StdDraw.show();
- }
- public static void cocentricCircles(double radius){
- StdDraw.setPenColor(StdDraw.BLACK);
- /********** type 1 cocentric circles having the formula Vimp [(2r*cos^2 theta + 2r underroot(cos^2 18 -cos^2 theta sin^2 theta)) - r)]*******/
- for(int i=1; i<4; i++){
- StdDraw.setPenColor(StdDraw.BLACK);
- double Value1 = 2* radius *Math.pow(Math.cos( (Math.PI/10)*i),2);
- double SIN = Math.pow(Math.sin( (Math.PI/10*i)),2);
- double COS = Math.pow(Math.cos( (Math.PI/10*i)),2);
- double Value2 = 2*radius*Math.sqrt((Math.pow(Math.cos( (Math.PI/10)),2)-COS*SIN));
- double cocentricradius = (Value1 + Value2)-radius;
- StdDraw.circle(0,0,cocentricradius);
- StdDraw.show();
- }
- /********** type 2 cocentric circles having the formula Vimp [r * cos (2*theta -18)+ underroot( 4 r^2 cos^2 18 - r^2 sin^2 (2*theta-18)) ]*******/
- for(int j=0; j<5; j++){
- StdDraw.setPenColor(StdDraw.BLACK);
- double Value1 = radius *Math.cos( 2*(Math.PI/10)*j-(Math.PI/10));
- double rvalue1 = 2*2*radius*radius*Math.pow(Math.cos( (Math.PI/10)),2);
- double rvalue2 = radius*radius*Math.pow(Math.sin( (2*((Math.PI/10)*j))-(Math.PI/10)),2);
- double Value2 = Math.sqrt( rvalue1 - rvalue2 );
- double cocentricradius = (Value1 + Value2);
- StdDraw.circle(0,0,cocentricradius);
- StdDraw.show();
- }
- }
- public static void main(String[] args){
- StdDraw.setCanvasSize(500,500);
- StdDraw.setXscale(-30,30);
- StdDraw.setYscale(-30,30);
- StdDraw.enableDoubleBuffering();
- nonCocentricCicles(5);
- cocentricCircles(5);
- }
- }
Add Comment
Please, Sign In to add comment