const float pi = 3.14159267;
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(115200); // Any baud rate should work
  Serial.println("Arduino  mesuring Starts\n");
}
// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(100);                       // wait for a second
  //double x=60*(PI/180);
  //double ans= cos(x);
  //Serial.print("ans:");Serial.println(ans);
  //double converter= ans;
  //Serial.print("toDegree:");Serial.println(converter);
  //Alfa=acos(a^2+b^2-c^2/2ab)
  float L1 = 1;
  float L2 = 1;
  float L3 = 1.41421356237;
  float calc;
  float Alfa;
  float ALFA;
  calc = ((L1 * L1) + (L2 * L2) - (L3 * L3)) / (2 * L1 * L2);
  Alfa = acos(calc);
  ALFA = Alfa * 180 / PI;
  Serial.print("Calc="); Serial.println(calc); Serial.print("ALFA="); Serial.println(ALFA);
  Serial.println("_______Calculation_______");
  //lines of calculation of arc cos and cos
  //float a=0.5;float A;
  //A=acos(a);float l3;
  //l3=A*180/PI;
  //Serial.println(A);
  //Serial.println(a);
  //Serial.println(l3);  //a,A,l3 calculate arccos angel degree
  //______________
  float x = 10;
  float y = 20;
  float ar = ALFA * (PI / 180); float ang = cos(ar); //get angel from part1 to calculate distance
  float z;
  z = (pow(x, 2) + pow(y, 2)) - (2 * x * y * ang);
  float Ans;
  Ans = sqrt(z);
  Serial.print("X:"); Serial.print(x); Serial.print(",");
  Serial.print("Y:"); Serial.print(y); Serial.print(",");
  Serial.print("Z:"); Serial.print(z); Serial.print(",");
  Serial.print("Angel:"); Serial.print(ang); Serial.print(",");
  Serial.print("Lenght:"); Serial.println(Ans);
  delay(1000);
}