Re: Line intersection point is wrong

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: emre(at)hasegeli(dot)com
Cc: PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Line intersection point is wrong
Date: 2016-06-20 21:58:30
Message-ID: 3949.1466459910@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Emre Hasegeli <emre(at)hasegeli(dot)com> writes:
>> After working out the algebra by hand, I think the attached is correct
>> (and it does pass the regression tests, yay). I also made the
>> line_parallel and line_perp tests more symmetric and zero-divide-free.

> It looks better to me, though not completely symmetric:

> hasegeli=# select '{0.000001,1000,0}'::line ?|| '{0.00009,90000,0}'::line;
> ?column?
> ----------
> f
> (1 row)

> hasegeli=# select '{0.00009,90000,0}'::line ?|| '{0.000001,1000,0}'::line;
> ?column?
> ----------
> t
> (1 row)

Hmm, that's annoying, although of course the existing code has problems
of the same ilk:

regression=# select '{1000,0.000001,0}'::line ?|| '{90000,0.00009,0}'::line;
?column?
----------
f
(1 row)

regression=# select '{90000,0.00009,0}'::line ?|| '{1000,0.000001,0}'::line;
?column?
----------
t
(1 row)

Basically this comes down to the fuzziness of the FPzero/FPeq tests.

It might be possible to fix this particular problem by changing the FPzero
tests in line_parallel() to exact "== 0" tests; though we would likely
be well advised to still keep the main test as FPeq.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2016-06-21 06:20:21 Re: BUG #14204: COMPATIBILITY
Previous Message Emre Hasegeli 2016-06-20 21:40:17 Re: Line intersection point is wrong