mirror of
https://github.com/postgres/postgres.git
synced 2025-04-29 13:56:47 +03:00
Fix line_construct_pm() for the case of "infinite" (DBL_MAX) slope.
This code was just plain wrong: what you got was not a line through the given point but a line almost indistinguishable from the Y-axis, although not truly vertical. The only caller that tries to use this function with m == DBL_MAX is dist_ps_internal for the case where the lseg is horizontal; it would end up producing the distance from the given point to the place where the lseg's line crosses the Y-axis. That function is used by other operators too, so there are several operators that could compute wrong distances from a line segment to something else. Per bug #5745 from jindiax. Back-patch to all supported branches.
This commit is contained in:
parent
55425d3721
commit
90e8efa338
@ -1070,13 +1070,20 @@ line_construct_pm(Point *pt, double m)
|
||||
{
|
||||
LINE *result = (LINE *) palloc(sizeof(LINE));
|
||||
|
||||
if (m == DBL_MAX)
|
||||
{
|
||||
/* vertical - use "x = C" */
|
||||
result->A = -1;
|
||||
result->B = 0;
|
||||
result->C = pt->x;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* use "mx - y + yinter = 0" */
|
||||
result->A = m;
|
||||
result->B = -1.0;
|
||||
if (m == DBL_MAX)
|
||||
result->C = pt->y;
|
||||
else
|
||||
result->C = pt->y - m * pt->x;
|
||||
}
|
||||
|
||||
#ifdef NOT_USED
|
||||
result->m = m;
|
||||
|
Loading…
x
Reference in New Issue
Block a user