Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

cpp boy

Sin Cos, is there a formula?

This topic is 5707 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i''ve got a question that''s been burning my lips to ask and finaly i decided to ask it. I know to find the sine or the cosine you must put the a side on the hypothenuse or the b side on the hypotenuse. I also know that there is a function to find the sine or the cosine only knowing the angle. But is there a formula to find the sine or the cosine and if yes what is it. I know that you will tell me search on google but i''m only in the 8th grade... Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
There is, and it is called a Taylor Series. Once you learn some differential calculus, it will all make sense, but pretty much, here are some important formulas:

e^x = 1 + x + x2/2 + x3/3! + .... xn/n! + . . .

e^(i*x) = cosx + i*sinx

sin(x) = x -x3/3! + x5/5! - ....

cos(x) = 1 - x2/2! + x4/4! + ......

but, you need to have x measured in radians.

Brendan

[edited by - Punty50 on April 18, 2003 10:24:40 PM]

STUPID EXPONENT SUPERSCRIPT!

[edited by - Punty50 on April 18, 2003 10:26:18 PM]

Share this post


Link to post
Share on other sites
hehe, i wanted to ask this too i was just searching gamedev.net forums for an explanation of what they were and on one of the post was a link, it had the formulas on it, here.
hope this helps



doh, nuts. Mmmm... donuts
My website

Share this post


Link to post
Share on other sites
I''m happy to know there is a formula, but there''s a lot of operators i don''t know in these equations like ! or e. Don''t forget i''m only in grade 8 and i don''t think you learned those operators at my level. Also, i know i''m a bit asky, but i would like to have an explanation of why this and why that, cause if i only see a formula i don''t know what variable does what.
Thanks

Share this post


Link to post
Share on other sites
I think that you could also use Langrange series. The difference is that you have less elements to add to have the same precision. So, use Lagrange.

Share this post


Link to post
Share on other sites
quote:
Original post by cpp boy
I''m happy to know there is a formula, but there''s a lot of operators i don''t know in these equations like ! or e.


e is a number, like pi. Like pi, it is a number that has no repeating pattern to its digits. The value of e is approximately 2.718281828459

! means factorial. Simplest way to explain is by example: 5! = 5*4*3*2*1 = 120. Factorial calculations are textbook examples of recursive functions:


  
unsigned int factorial (unsigned int n)
{
if (n < 2) return 1;
return n * factorial (n - 1);
}




Share this post


Link to post
Share on other sites
quote:

There is, and it is called a Taylor Series



I haven''t studied the Taylor series yet, but some of those series look suspiciously like the Maclaurin series for said functions. What is the difference between the Taylor and Maclaurin series''?



"Any man who is under 30, and is not a liberal, has no heart; and any man who is over 30, and is not a conservative, has no brains." - Sir Winston Churchill

Share this post


Link to post
Share on other sites
quote:
Original post by cpp boy
I''m happy to know there is a formula, but there''s a lot of operators i don''t know in these equations like ! or e. Don''t forget i''m only in grade 8 and i don''t think you learned those operators at my level. Also, i know i''m a bit asky, but i would like to have an explanation of why this and why that, cause if i only see a formula i don''t know what variable does what.
Thanks


Hey, you''re pretty curious for a grade 8''er! I admire your sense for adventure! Hopefully some of the answers here are helpful, even if you don''t understand them fully. You kind of have to understand a bit of calculus to "get" the Taylor''s series thing. But even if you don''t understand the math you can do a simple test.

Try this. Write a small program that calls cos(0.785). That 0.785 is in radians and is equivalent to 45 degrees. Print out the result. Then write another program that calls this function:


double TaylorSeriesCos(double dAngle, int n)
{
double dCos = 1.f;
double dSign = -1.f;
unsigned int uiPower = 2;
double dTerm = 0.0f;
for (int i = 0; i < n; i++)
{
dTerm = dSign * pow(dAngle, float(uiPower));
dTerm /= factorial(uiPower);
dCos += dTerm;
dSign = -dSign;
uiPower += 2;
}
return(dCos);
}


That function uses Punty50''s function for cos(x) and Kippesoep''s factorial function.

Now, try calling that function with dAngle = 0.785 and different values of n ranging from 0 to, say, 10. As n increases, the resulting value will be closer and closer to the value returned by the standard library function cos(x). In fact, you may find that n = 10 is more than you need!


Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
quote:
Original post by MDI
I haven''t studied the Taylor series yet, but some of those series look suspiciously like the Maclaurin series for said functions. What is the difference between the Taylor and Maclaurin series''?


Maclaurin series are simply a subset of Taylor series where x0=0. (Which it is, for all these trig function expansions.)


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!