Definitions of PI...

Bug #1066194 reported by Martin Errenst
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Medium
Wayne Stambaugh

Bug Description

Kicad got plenty of them. (Or uses some hardcoded ones).

kicad $ ack --cpp "3\.141"
include/boost/polygon/polygon_set_data.hpp
887: const double our_pi=3.1415926535897932384626433832795028841971;

include/fctsys.h
29:#define M_PI 3.141592653

pcb_calculator/transline/units.h
37:#define M_PI 3.1415926535897932384626433832795029 /* pi */

pcbnew/muonde.cpp
323: double increment_angle = (double) a_ArcAngle * 3.14159 / 1800 / seg_count;

pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp
140: s_Correction = 1.0 / cos( 3.14159265 / s_CircleToSegmentsCount );

polygon/clipper.cpp
54:static double const pi = 3.141592653589793238;

I don't know if it'll break some existing stuff if these definitions are changed, but one definition with the same value would be nice. There's also one more from <math.h> (which differs at least on my system with all of the ones used in kicad).

Tags: codebase kicad

Related branches

Changed in kicad:
importance: Undecided → Medium
assignee: nobody → Wayne Stambaugh (stambaughw)
Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

Fixed as much as can be fixed in testing branch r3773 with the following exceptions:

include/boost/polygon/polygon_set_data.hpp
887: const double our_pi=3.1415926535897932384626433832795028841971;

and:

polygon/clipper.cpp
54:static double const pi = 3.141592653589793238;

are imported from external projects so any changes would be lost the next time these sources are updated.

This definition:

pcb_calculator/transline/units.h
37:#define M_PI 3.1415926535897932384626433832795029 /* pi */

does not include wxWidgets so adding #include <wx/wx.h> would only add an extra dependency which is not required.

Changed in kicad:
status: New → Fix Committed
Martin Errenst (imp-d)
Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.