triangle_interior_angles.pl 506 B

12345678910111213141516171819202122
  1. #!/usr/bin/perl
  2. # Daniel "Trizen" Șuteu
  3. # Date: 22 January 2018
  4. # https://github.com/trizen
  5. # Formula for finding the interior angles of a triangle, given its side lengths.
  6. use 5.010;
  7. use strict;
  8. use warnings;
  9. use Math::AnyNum qw(acos rad2deg);
  10. my $x = 3;
  11. my $y = 4;
  12. my $z = 5;
  13. say rad2deg(acos(($y**2 + $z**2 - $x**2) / (2 * $y * $z))); # 36.869...
  14. say rad2deg(acos(($x**2 - $y**2 + $z**2) / (2 * $x * $z))); # 53.130...
  15. say rad2deg(acos(($x**2 + $y**2 - $z**2) / (2 * $x * $y))); # 90