← Back to team overview

kicad-developers team mailing list archive

Re: Trigonometric look up table.


On 9/19/2011 5:01 PM, Wayne Stambaugh wrote:
> On 9/19/2011 4:31 PM, jean-pierre charras wrote:
>> Well,
>> I used trigonometric look up tables to speed up calculations when I started Kicad.
>> Some features (like file formats) come from to constraints due to low speed of
>> computers or networks.
>> Obviously, these constraints are now very different.
>> Today, we can consider a more understandable and maintainable code it the first
>> constraint.
>> Mainly because:
>> - Kicad code is growing more and more.
>> - Computers and networks and more and more faster.
>> - Our brain does not grow (unfortunately).
>> The main reason there is a mixed use of sin(), cos() and lockup table in code
>> is the complexity of Kicad code.
>> There is a lot of duplicated code due to this reason.
>> So, code simplification is the most important criteria when changing the Kicad
>> code.
> I did a little research and on a Pentium IV (one of the worst floating point
> performers), the sine function takes 130 - 190 cycles.  Assuming worst case
> (190) and 1GHz clock speed (I don't think Intel ever made a Pentium 4 this slow
> but I could be wrong) 100K sin() function call would take 19mS.  I would think
> it would take a really complex board to have 100,000 rotated (other than 0, 90,
> 180, and 270 degrees) items.
> Wayne

A quick update.  There are already optimizations for 0, 90, 180, and 270
degrees by swapping and/or negating the appropriate coordinate.  Unless you
have a hand created object with an angle other than these, sin() and cos() are
never called.  Therefore, your performance change will be 0 under almost all


> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp