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

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3366
  • Integrated Brain
    • View Profile
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.

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
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

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2631
    • View Profile
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)

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3366
  • Integrated Brain
    • View Profile
Hi thanks kanonet and bigsofty... I´m a bit ignorant  :-[ :-[ =D

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

Thanks to both.

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2631
    • View Profile
Np, a good programmer should never admit that he does not know it all!  :S

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!  :S

   :D
« 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)

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3366
  • Integrated Brain
    • View Profile
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.   :giveup:

Ian thanks for move the threand to here!!!  :good: