Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: √ ∞ ≠ ≤ ≥ ≈ ⇒ ∈ Δ θ ∴ ∑ ∫ π -

Login

Username

Password

Not registered yet?

  • Index
  •  » Help Me !
  •  » I need sine, cosine and tangent functions for C++ :-(

#1 2005-10-01 13:14:25

mikau
Super Member

Offline

I need sine, cosine and tangent functions for C++ :-(

I'm writing some awsome programs using math but I really really really need access to sine, cosine and tangent functions, also I really could use arcsin, arccos, and arctan, but arctangent the most since I need to convert from rectangular form to polar form and back.

Someone gave me a link to the formulas for sine, cosine and tangent, which was great and they appear to work, but they call a lot of factorials and very large numbers "270^5" :-O

If anyone knows where I can get a copy of the source code for functions for sine, cosine, tangent, arcsine, etc. so I can just copy the definition into my program and call on it when I need it. It would be a MAJOR help!


A logarithm is just a misspelled algorithm.

#2 2005-10-03 05:14:47

mikau
Super Member

Offline

Re: I need sine, cosine and tangent functions for C++ :-(

please?


A logarithm is just a misspelled algorithm.

#3 2005-10-03 08:42:31

MathsIsFun
Administrator

Offline

Re: I need sine, cosine and tangent functions for C++ :-(

For performance I would use the standard include "math.h" - it has sin cos and tan.

Example:

#include <stdio.h>
#include <math.h>

#define PI 3.141592654

int main () {
  double angle;
  angle = 10;
  double ans;
  ans = sin (angle*PI/180);
  printf ("Ans = %lf ", ans );
  return 0;
}

Or did you need more accuracy or something?


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

#4 2005-10-05 10:56:58

mikau
Super Member

Offline

Re: I need sine, cosine and tangent functions for C++ :-(

Thats exactly what I'm looking for! :-D Thanks a yotta, Mathisfun!


A logarithm is just a misspelled algorithm.

#5 2005-10-05 11:16:37

mikau
Super Member

Offline

Re: I need sine, cosine and tangent functions for C++ :-(

wow, sometimes please does work!


A logarithm is just a misspelled algorithm.

#6 2005-10-05 11:23:55

mikau
Super Member

Offline

Re: I need sine, cosine and tangent functions for C++ :-(

Hey it works! Thanks again mathisfun! Are there functions for arcsin, arccos, and arctan?


A logarithm is just a misspelled algorithm.
  • Index
  •  » Help Me !
  •  » I need sine, cosine and tangent functions for C++ :-(

Board footer

Powered by FluxBB