• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Trigonometric Problem, Particularly tan() Function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trigonometric Problem, Particularly tan() Function


  • Subject: Re: Trigonometric Problem, Particularly tan() Function
  • From: Patrick Walker <email@hidden>
  • Date: Sun, 13 Jul 2008 10:30:27 -0300

I can't post the whole thing because it's sort of large and "integrated" but here is what I have originally done.

    float radians;

    radians = ([entryField floatValue] * M_PI / 180);
    [outField setFloatValue:tan(radians)];

A simple solution could involve using another trigonometgric implementation available to Xcode. The question is are there any other than the numerical method "math.h" versions? That's not so bad because I can simply trap +- 90 and +-270 angles but I am trying to get as much speed.

My other problems seems to be -2877334 itself. To me, that appears to be a rather strange value for a floating point number, esp. when cos(pi/2) is returning near-zero (an "e-08") number as well.

Thanks for the replies.

On 13-Jul-08, at 2:06 AM, Jens Alfke wrote:


On 12 Jul '08, at 9:43 PM, Patrick Walker wrote:

Everthing appears to be fine when going from 0 to 45 degrees but at 90 degrees, the tangent returns -22877334.

That's not what I get. I just compiled and ran: printf("tan(90) = %g\n", tan(M_PI/2)); which printed: tan(90) = 1.63312e+16

Which is not infinity, but close enough, given that π/2 can't be represented precisely in floating-point arithmetic.

I think you need to show us the code you're using, as there seems to be something wrong with it.

—Jens

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Trigonometric Problem, Particularly tan() Function
      • From: "Michael Ash" <email@hidden>
    • Re: Trigonometric Problem, Particularly tan() Function
      • From: Michael Vannorsdel <email@hidden>
    • Re: Trigonometric Problem, Particularly tan() Function
      • From: Michael Hall <email@hidden>
  • Prev by Date: Re: Design Question: Where to observe using KVO?
  • Next by Date: Remove overlap on NSBezierPath
  • Previous by thread: Re: Trigonometric Problem, Particularly tan() Function
  • Next by thread: Re: Trigonometric Problem, Particularly tan() Function
  • Index(es):
    • Date
    • Thread