Advertisement

sin() and cos()

Started by August 16, 2000 11:19 AM
9 comments, last by SKSlayer 24 years, 3 months ago
Does the angle I specify in sin and cos function in degrees or in radians ???
(you can find me on IRC : #opengl on undernet)
Radians.
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Advertisement
the sin() and cos() in math.h uses radians
quote: Original post by SKSlayer

Does the angle I specify in sin and cos function in degrees or in radians ???


check out the tutorial on moving through 3d space, as a conversion factor''s used to move to degrees from radians - handy for 360 degree movement..

I know how to convert, that''s what they teached us at school :o)
(you can find me on IRC : #opengl on undernet)
Because sin and cos are pretty slow functions, you could make your own.
Just declare an array called sin[360] and cos [360] and use sin and cos to fill them initially.
Of course, when smaller increments are needed...you''ll need sin() and cos()
Advertisement
oh, okay,
Are they as slow as sqrt ???
(you can find me on IRC : #opengl on undernet)
quote: Original post by SKSlayer

oh, okay,
Are they as slow as sqrt ???


Slower.
I tested it:
50000000 sqrt()''s need about 10 s
50000000 sin()''s need about 20 s.

GA
Visit our homepage: www.rarebyte.de.stGA
Well, that''s never gonna happen

I usually wrap
sin(3*PI) is the same as sin(PI) (2*PI is 360° right ?)
(you can find me on IRC : #opengl on undernet)
For 3D real-time programming is REALLY important that you use Lookup Tables.

Just declares two array (one for cons and one sof sins) and precalculate them at the startup of the program. Then refer to them when you need sins or cons.

This topic is closed to new replies.

Advertisement