Guest User

Untitled

a guest
May 26th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. public class AshokaLogoV4{
  2. public static void nonCocentricCicles(double radius){
  3. for(int i=0; i<10; i++){
  4. StdDraw.setPenColor(StdDraw.BLACK);
  5. double Xcenter =radius*Math.cos(2*Math.PI+i*Math.PI*2/10);
  6. double Ycenter =radius*Math.sin(2*Math.PI+i*Math.PI*2/10);
  7. double noncocentricradius = 2*radius*Math.cos(Math.PI/10);
  8. double value3= Math.asin(Math.tan (Math.PI/10)/2);
  9. double value4= Math.toDegrees(value3);
  10. double constantangle = 18+ value4;
  11. StdDraw.setPenColor(StdDraw.BLACK);
  12. StdDraw.arc(Xcenter,Ycenter,noncocentricradius,(36.0)*i+constantangle,(36.0)*i+162.0);
  13. StdDraw.arc(Xcenter,Ycenter,noncocentricradius,(36.0)*i+198.0,(36.0)*i-constantangle);
  14. StdDraw.show();
  15. }
  16. StdDraw.show();
  17. }
  18. public static void cocentricCircles(double radius){
  19. StdDraw.setPenColor(StdDraw.BLACK);
  20. /********** type 1 cocentric circles having the formula Vimp [(2r*cos^2 theta + 2r underroot(cos^2 18 -cos^2 theta sin^2 theta)) - r)]*******/
  21. for(int i=1; i<4; i++){
  22. StdDraw.setPenColor(StdDraw.BLACK);
  23. double Value1 = 2* radius *Math.pow(Math.cos( (Math.PI/10)*i),2);
  24. double SIN = Math.pow(Math.sin( (Math.PI/10*i)),2);
  25. double COS = Math.pow(Math.cos( (Math.PI/10*i)),2);
  26. double Value2 = 2*radius*Math.sqrt((Math.pow(Math.cos( (Math.PI/10)),2)-COS*SIN));
  27. double cocentricradius = (Value1 + Value2)-radius;
  28. StdDraw.circle(0,0,cocentricradius);
  29. StdDraw.show();
  30. }
  31. /********** 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)) ]*******/
  32. for(int j=0; j<5; j++){
  33. StdDraw.setPenColor(StdDraw.BLACK);
  34. double Value1 = radius *Math.cos( 2*(Math.PI/10)*j-(Math.PI/10));
  35. double rvalue1 = 2*2*radius*radius*Math.pow(Math.cos( (Math.PI/10)),2);
  36. double rvalue2 = radius*radius*Math.pow(Math.sin( (2*((Math.PI/10)*j))-(Math.PI/10)),2);
  37. double Value2 = Math.sqrt( rvalue1 - rvalue2 );
  38. double cocentricradius = (Value1 + Value2);
  39. StdDraw.circle(0,0,cocentricradius);
  40. StdDraw.show();
  41. }
  42. }
  43. public static void main(String[] args){
  44. StdDraw.setCanvasSize(500,500);
  45. StdDraw.setXscale(-30,30);
  46. StdDraw.setYscale(-30,30);
  47. StdDraw.enableDoubleBuffering();
  48. nonCocentricCicles(5);
  49. cocentricCircles(5);
  50. }
  51. }
Add Comment
Please, Sign In to add comment