in reply to Re: Compute Angles of a Right Triangle
in thread Compute Angles of a Right Triangle

That's a nice solution. To comment on it a little, the sort finds the two shortest sides (so the hypotenuse is ignored). atan computes the the arctangent.

Math::Trig is bundled with perl, but if you wanted to use a builtin, you could use atan2 instead, passing the two sides as separate arguments.

That isn't as acurate a value of pi as possible. 3.14159265359 is closer (since the digits following 89 are 7932). You can use 4*atan2(1,1) to get a value with accuracy commensurate with your perl's floating point accuracy.

  • Comment on Re: Re: Compute Angles of a Right Triangle

Replies are listed 'Best First'.
Re: Re: Re: Compute Angles of a Right Triangle
by duff (Parson) on Dec 11, 2003 at 03:43 UTC
    You can use 4*atan2(1,1) to get ... [pi]

    Or, since atan2() is properly ranged from -pi to pi, you can use atan2(0,-1) and forego the multiplication