I don't know the module, but some basic trig knowledge can help. In a right triangle, there is a simple relationship between angles and sides. If you have all three sides (SSS), then the following relationship holds true. Here's a diagram that demonstrates the SOH CAH TOA acronym. (sin = opposite/hypotenuse, cos = adjacant/hypotenuse, tan = opposite/adjacant). You could take this knowledge and create a routine that takes the sides in a specific order, calculates the sine values for the two unknown angles and then uses Math::Trig::asin() to get the angles. Seems quite long winded though :)

  A
  |\         sin A = a/b {(b is hypotenuse 4)
  | \        sin A = 3/5
  |  \
4 |   \ 5    sin C = c/b
  |    \     sin C = 4/5
  |90   \
  -------|
 B   3    C

Update: Not to mention that you only need to calculate one of the unknown angles to get all three. Since you have the 90 degrees, calculate one, then knowing that all 3 angles of a triangle have a sum of 180, you just subtract the two known angles from 180 and there's your third.


In reply to Re: Compute Angles of a Right Triangle by Coruscate
in thread Compute Angles of a Right Triangle by true

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.