### Author Topic: Question about Sin a Cos , perhaps can be more quick?¿  (Read 2639 times)

#### mentalthink

• Prof. Inline
• Posts: 3366
• Integrated Brain
##### Question about Sin a Cos , perhaps can be more quick?¿
« on: 2012-Aug-26 »
Hi I put here this question... becuause not it´s a doubt, else it´s an idea...
In the forum we have 2 libraries whit cos and sin very fasters both... but I rebember reading some book, of ASM of Amstrad CPC, I think i read something... in the 80 decades when the programmers don´t have too much machines, they make something like use only a quadrant of Sin or Cos, and when they want make a complete revolution in Radians, they multiply this values of the first quadrant each time needed.

I´m not sure if this can have any advantage, perhaps today can be insignificant, and I only want to ask, for if someelse can do, or can teach me a little how make a cosine library and I try it.

Thanks.
Iván J.

#### kanonet

• Prof. Inline
• Posts: 1142
##### Re: Question about Sin a Cos , perhaps can be more quick?¿
« Reply #1 on: 2012-Aug-26 »
Dividing a full circle in smaller parts, and just calculate the small part is what my lib currently does, its of cause faster/accurater than doing an approximation for the full circle. Yes this obvious trick is very old.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

#### bigsofty

• Community Developer
• Prof. Inline
• Posts: 2628
##### Re: Question about Sin a Cos , perhaps can be more quick?¿
« Reply #2 on: 2012-Aug-26 »
Its called the Midpoint Circle Algorithm, see here, http://en.wikipedia.org/wiki/Midpoint_circle_algorithm A very handy trick for quick drawing of circles as Kanonet said. Its heavy use of integers made it perfect for Z80 assembly on the CPC too.
« Last Edit: 2012-Aug-26 by bigsofty »
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

#### mentalthink

• Prof. Inline
• Posts: 3366
• Integrated Brain
##### Re: Question about Sin a Cos , perhaps can be more quick?¿
« Reply #3 on: 2012-Aug-26 »
Hi thanks kanonet and bigsofty... I´m a bit ignorant

Thanks for the link too I take a look, it´s very interesting know new things... programmins it´s too much huge Art...

Thanks to both.

#### bigsofty

• Community Developer
• Prof. Inline
• Posts: 2628
##### Re: Question about Sin a Cos , perhaps can be more quick?¿
« Reply #4 on: 2012-Aug-27 »
Np, a good programmer should never admit that he does not know it all!

BTW, the Code Snippets forum is for posting bits of your code to share, not really for discussion.

Edit:

Wait a min, that's wrong, it should be...

Np, a good programmer should never admit he knows it all!

« Last Edit: 2012-Aug-27 by bigsofty »
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

#### mentalthink

• Prof. Inline
• Posts: 3366
• Integrated Brain
##### Re: Question about Sin a Cos , perhaps can be more quick?¿
« Reply #5 on: 2012-Aug-27 »
Hi Bigsofty, thanks for the advice... I think only I have a reply or anyone, this it´s the fact for not put in main thread.

Ian thanks for move the threand to here!!!