Re: line_perp() (?-|) is broken.

From: Emre Hasegeli <emre(at)hasegeli(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: line_perp() (?-|) is broken.
Date: 2018-03-03 15:39:26
Message-ID: CAE2gYzwXJKKDYevoxgep6m9sgTxVg_50Tc4Wp8UVN1CD1LF60g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> However, for either patch, I'm a bit concerned about using FPzero()
> on the inner product result. To the extent that the EPSILON bound
> has any useful meaning at all, it needs to mean a maximum difference
> between two coordinate values. The inner product has units of coordinates
> squared, so it seems like EPSILON isn't an appropriate threshold there.

In this case, I suggest this:

> if (FPzero(l1->A))
> PG_RETURN_BOOL(FPzero(l2->B));
> if (FPzero(l2->A))
> PG_RETURN_BOOL(FPzero(l1->B));
> if (FPzero(l1->B))
> PG_RETURN_BOOL(FPzero(l2->A));
> if (FPzero(l2->B))
> PG_RETURN_BOOL(FPzero(l1->A));
>
> PG_RETURN_BOOL(FPeq((l1->A * l2->A) / (l1->B * l2->B), -1.0));

> Possibly this objection is pointless, because I'm not at all sure that
> the existing code is careful about how it uses FPeq/FPzero; perhaps
> we're applying EPSILON to all manner of numbers that don't have units
> of the coordinate space. But this won't help make it better.

The existing code was probably paying attention to this particular
one, but it fails to apply EPSILON meaningfully to many other places.
For example lseg_parallel() and lseg_perp() applies it 2 times to the
same input. First point_sl() compares x coordinates with FPeq(), and
then the returned slopes are compared again with FPeq().

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-03-03 15:43:26 Re: line_perp() (?-|) is broken.
Previous Message Tom Lane 2018-03-03 15:21:36 Re: [HACKERS] GSOC'17 project introduction: Parallel COPY execution with errors handling