Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1.  
  2. #ifndef trylab_class_h
  3. #define trylab_class_h
  4. #include "math.h"
  5. using namespace std;
  6. const double PI=3.14159265;
  7. class Nefroida{ //класс Нефроида
  8. private :
  9. double a; //радиус
  10. double alpha; //альфа
  11. double nx;
  12. double ny;
  13. public:
  14. Nefroida(){//конструктор
  15. a=0;
  16. alpha=0;
  17. nx=0;
  18. ny=0;
  19. }
  20.  
  21. double geta()const{return a;};
  22.  
  23. void seta(double na){
  24. try{
  25. if(na>0)
  26. a=na;
  27. else
  28. throw "illegal a";
  29. }
  30. catch(const char *p){
  31. cout<<"Brat za brata"<<endl;
  32. }
  33. }
  34.  
  35. double getalpha()const{return alpha;};
  36.  
  37. void setalpha(double nalpfa){
  38. alpha=(nalpfa/PI)*180;
  39.  
  40. }
  41. double getnX()const{return nx;}
  42. double getnY()const{return ny;}
  43.  
  44. void setnX(double newx){
  45. nx=newx;
  46. }
  47. void setnY(double newy){
  48. ny=newy;
  49. }
  50. int setXY(){
  51. double x;
  52. std::cout<<"Vvedite x = ";//<<std::endl;
  53. std::cin>>x;
  54. try{
  55. if (x!=geta())
  56. nx=x;
  57. else
  58. throw "illegal x";
  59. }
  60. catch(const char *p){
  61. cout<<"Неверное значение x=a"<<endl;
  62. };
  63. try{
  64. if(((a+nx)/(a-nx))>0)
  65. ny=nx*sqrt((a+nx)/(a-nx));
  66. else
  67. throw "illegal sqrt";
  68. }
  69. catch(const char *p){
  70. cout<<"Неверное значение x<a"<<endl;
  71. }
  72. return ny;
  73. }
  74.  
  75.  
  76. double getlength(double alpha){
  77. double len;
  78. alpha=(alpha/PI)*180;
  79. len=-((a*cos(2*alpha))/(cos(alpha)));
  80. return len;
  81. }
  82.  
  83.  
  84.  
  85. /* double getX(double fi){
  86. double x=3*a*cos(fi)-a*cos(alpha+3*fi);
  87. return x;
  88. }*/
  89.  
  90. double getX()const{return nx;}
  91.  
  92. double getY(){
  93. double y;
  94. double x = getX();
  95. y=(x*sqrt((a+x)/(a-x)));
  96. return y;
  97. }
  98.  
  99. double getArea(){
  100. double Area=a*a*(2-PI/2);
  101. return Area;
  102. }
  103. double getArea2(){
  104. double Area2=a*a*(2+PI/2);
  105. return Area2;
  106. }
  107. double getVolume(){
  108. double volume=PI*a*a*a*(2*log(2)-(4/3));
  109. return volume;
  110. }
  111. double getcurvate(){
  112. double curv;
  113. curv = a*sqrt(2);
  114. return curv;
  115. }
  116. //void form(){
  117.  
  118. //}
  119.  
  120. };
  121.  
  122.  
  123. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement