Hello,
Does anyone know how the sin() function works, i.e. how it finds the sine of the input angle computationally?
This is a discussion on Original sin() within the C Programming forums, part of the General Programming Boards category; Hello, Does anyone know how the sin() function works, i.e. how it finds the sine of the input angle computationally?...
Hello,
Does anyone know how the sin() function works, i.e. how it finds the sine of the input angle computationally?
I don't know for sure, and have nothing to back me up, but I'd bet it's a fairly simple lookup system, probably based on the repetitive nature of the unit circle.
My guess would be that it uses the power series equivilant of sin(x)... I think I heard somewhere that's how a calculator finds it. But that's just a guess.
Triangle ABC has three sides AB, BC and AC. If ABC is a right angle triangle, then Sin(A) = BC/AB ...(sin(x) = opposite / hypostenuse). There is only one hypotenuse so naturally, A != 90 degrees.
Last edited by duvernais28; 02-22-2005 at 12:11 AM.
Like this maybe?
http://mathworld.wolfram.com/Sine.html
Woop?
Well, you could go that route if you're familiar with calculas but I think the basics still apply. It's been been too long since I've looked at that kind of Math...lol
This should be sufficient.
http://library.thinkquest.org/10030/2trigfu.htm
Last edited by duvernais28; 02-22-2005 at 12:37 AM.
Lookup tables
Polynomial expansion
Maths co-processor instruction
All viable ways depending on your individual circumstances of the need for speed, accuracy and available processing power.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.