Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

OT: ASA formula

by rpike (Scribe)
on Apr 19, 2011 at 15:12 UTC ( #900137=perlquestion: print w/ replies, xml ) Need Help??
rpike has asked for the wisdom of the Perl Monks concerning the following question:

I have a right triangle (left bottom corner), the bottom side's length, and the right bottom corner's angle. I need to find out what the height of the triangle is. I've been trying a few formulas I found off the web but after calculating I sometimes get negative values returned. Any help would be appreciated. Thanks.

Comment on OT: ASA formula
Re: OT: ASA formula
by moritz (Cardinal) on Apr 19, 2011 at 15:27 UTC
Re: OT: ASA formula
by rpike (Scribe) on Apr 19, 2011 at 15:56 UTC
    Hmmm POSIX..... does that come installed with Perl? If not, how can I tell if it is already installed? If not installed where can I grab it from, etc..,? Right now when I try including use POSIX qw/tan/; the Perl cgi app I have comes back with a cgi error page.
      POSIX should be installed because it is a Core module, and has been for a long time:
      $ perl -MPOSIX=tan -e 1 $ corelist POSIX POSIX was first released with perl 5

      There is of course also Math::Trig (in fact the POSIX entry for tan() also references this).

      It also is part of Perl's core distribution, but if your administrator has been doing things to the distribution (which might account for your error), then all bets are off.

Re: OT: ASA formula
by wind (Priest) on Apr 20, 2011 at 05:03 UTC

    For a general example of the ASA problem, I just used the formula documented here: Area of Triangles

    use strict; use warnings; my $pi = atan2 0, -1; my $angle1 = 90 * $pi / 180; my $angle2 = 30 * $pi / 180; my $side = 6; my $angle3 = $pi - $angle1 - $angle2; my $height = $side * sin($angle1) * sin($angle2) / sin($angle3); print "height = $height\n"; my $area = 1/2 * $side * $height; print "area = $area\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://900137]
Approved by philipbailey
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2014-09-19 04:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (129 votes), past polls