Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc2b716a

Browse files
committed
Replace imprecise value of PI with a better one, and tweak circle_poly
in hopes of reducing platform-to-platform variations in its results.This will cause the geometry regression test to start failing on someplatforms. I plan to update the test later today.
1 parentcea5388 commitc2b716a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

‎src/backend/utils/adt/geo_ops.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.67 2002/11/0817:37:52 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.68 2002/11/0818:32:47 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -22,10 +22,12 @@
2222
#include"utils/builtins.h"
2323
#include"utils/geo_decls.h"
2424

25-
#ifndefPI
26-
#definePI 3.1415926536
25+
#ifndefM_PI
26+
/* from my RH5.2 gcc math.h file - thomas 2000-04-03 */
27+
#defineM_PI 3.14159265358979323846
2728
#endif
2829

30+
2931
/*
3032
* Internal routines
3133
*/
@@ -4365,7 +4367,7 @@ circle_center(PG_FUNCTION_ARGS)
43654367
staticdouble
43664368
circle_ar(CIRCLE*circle)
43674369
{
4368-
returnPI* (circle->radius*circle->radius);
4370+
returnM_PI* (circle->radius*circle->radius);
43694371
}
43704372

43714373

@@ -4438,6 +4440,7 @@ circle_poly(PG_FUNCTION_ARGS)
44384440
size;
44394441
inti;
44404442
doubleangle;
4443+
doubleanglestep;
44414444

44424445
if (FPzero(circle->radius)|| (npts<2))
44434446
elog(ERROR,"Unable to convert circle to polygon");
@@ -4455,9 +4458,11 @@ circle_poly(PG_FUNCTION_ARGS)
44554458
poly->size=size;
44564459
poly->npts=npts;
44574460

4461+
anglestep= (2.0*M_PI) /npts;
4462+
44584463
for (i=0;i<npts;i++)
44594464
{
4460-
angle=i*(2*PI /npts);
4465+
angle=i*anglestep;
44614466
poly->p[i].x=circle->center.x- (circle->radius*cos(angle));
44624467
poly->p[i].y=circle->center.y+ (circle->radius*sin(angle));
44634468
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp