Lack of detailed documentation

Started by PG Bug reporting formabout 6 years ago11 messagesdocs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/12/functions-geometry.html
Description:

On: https://www.postgresql.org/docs/current/functions-geometry.html

The functions aren't defined, nor have pointers. For instance:
* Scaling/rotation box '((0,0),(1,1))' * point '(2.0,0)'

I see how it can be scaling (or shearing), but how does it do rotation?
Or maybe when the points x^2+y^2 == 1, it's interpreted at rotation?
Each operator needs a full explanation...
thx

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: PG Bug reporting form (#1)
Re: Lack of detailed documentation

On Fri, Feb 7, 2020 at 4:53 PM PG Doc comments form <noreply@postgresql.org>
wrote:

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/12/functions-geometry.html
Description:

On: https://www.postgresql.org/docs/current/functions-geometry.html

The functions aren't defined, nor have pointers. For instance:
* Scaling/rotation box '((0,0),(1,1))' * point '(2.0,0)'

I see how it can be scaling (or shearing), but how does it do rotation?
Or maybe when the points x^2+y^2 == 1, it's interpreted at rotation?

Google: "box point multiplication postgres" came up with the follow book
section:

https://books.google.com/books?id=gkQVL9pyFVYC&amp;pg=PA95&amp;lpg=PA95&amp;dq=box+point+multiplication+postgres&amp;source=bl&amp;ots=E8z9PZHum-&amp;sig=ACfU3U1QyE1TkI6ceUX24sQzl_zrsEH5lQ&amp;hl=en&amp;sa=X&amp;ved=2ahUKEwiVhO2_48LnAhWXFzQIHVwYCXQQ6AEwAXoECAoQAQ#v=onepage&amp;q=box%20point%20multiplication%20postgres&amp;f=false

Haven't independently confirm the math but it sounds reasonable...

Each operator needs a full explanation...

Patch submissions are welcomed.

David J.

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: David G. Johnston (#2)
Re: Lack of detailed documentation

"David G. Johnston" <david.g.johnston@gmail.com> writes:

On Fri, Feb 7, 2020 at 4:53 PM PG Doc comments form <noreply@postgresql.org>
wrote:

On: https://www.postgresql.org/docs/current/functions-geometry.html
The functions aren't defined, nor have pointers. For instance:
* Scaling/rotation box '((0,0),(1,1))' * point '(2.0,0)'
I see how it can be scaling (or shearing), but how does it do rotation?
Or maybe when the points x^2+y^2 == 1, it's interpreted at rotation?

Google: "box point multiplication postgres" came up with the follow book
section:
Haven't independently confirm the math but it sounds reasonable...

I responded to the OP about this but unaccountably forgot to cc the list.
The two main points were:

* Per high-school-level vector geometry, rotation around the origin
by an angle theta is equivalent to multiplying by the vector
(cos(theta), sin(theta)). (So no, the book section you quoted isn't
quite right :-(.) But we can't go and offer a geometry course on
this page.

* While this works for rotating points, paths, and circles, it
doesn't really work for rotating boxes, because for any rotation
angle that's not a multiple of 90 degrees, you'd need to end up with
a tilted box ... and our box type has no notion of tilted. The
specified corners rotate to the right places, but the box size isn't
preserved.

So it seems fairly unfortunate to me that the two examples of
scaling/rotation use a box as the LHS. I could get behind changing
them to use, say, a path as LHS. But I don't think there's room to
explain how to do rotation if you don't know that already, any more
than (say) our explanation of aggregate functions tries to explain
statistics.

regards, tom lane

#4Strauss, Randy (ARC-AF)[SGT, INC]
randolph.a.strauss@nasa.gov
In reply to: Tom Lane (#3)
Re: [EXTERNAL] Re: Lack of detailed documentation

Yes, I figured this out. People shouldn't have to figure out that the 2 numbers in the vector are the scale and rotation.
They could be the rotation and scale. The rotation could be in degrees or radians.
This is documentation- it should explain it.
And yes, does it rotate around its center, or the origin?
And this was just one example. Every friggin' one of them needs to be documented.
I'm not demanding that they be done right away, but there should be a description of each. They can all start with TBD...
-r
Randy Strauss, desk: 650-604-0431 (Bldg N210, Rm 145, Cube 36)

On 2/9/20, 8:09 AM, "Tom Lane" <tgl@sss.pgh.pa.us> wrote:

"David G. Johnston" <david.g.johnston@gmail.com> writes:

On Fri, Feb 7, 2020 at 4:53 PM PG Doc comments form <noreply@postgresql.org>
wrote:

On: https://urldefense.proofpoint.com/v2/url?u=https-3A__www.postgresql.org_docs_current_functions-2Dgeometry.html&amp;d=DwIBAg&amp;c=ApwzowJNAKKw3xye91w7BE1XMRKi2LN9kiMk5Csz9Zk&amp;r=0XRgt7H2WP_TiC5qNss_VhvfCsa-0F_Mw2WUm8TRNiA&amp;m=IDBm4StAmus_A2EYOJRshLFkAAflIS2G74fY7Dhjpag&amp;s=ZuX_8udUWIRdOV5aFxQKHppjdkUgMrhz0mg68HmdTlo&amp;e=
The functions aren't defined, nor have pointers. For instance:
* Scaling/rotation box '((0,0),(1,1))' * point '(2.0,0)'
I see how it can be scaling (or shearing), but how does it do rotation?
Or maybe when the points x^2+y^2 == 1, it's interpreted at rotation?

Google: "box point multiplication postgres" came up with the follow book
section:
Haven't independently confirm the math but it sounds reasonable...

I responded to the OP about this but unaccountably forgot to cc the list.
The two main points were:

* Per high-school-level vector geometry, rotation around the origin
by an angle theta is equivalent to multiplying by the vector
(cos(theta), sin(theta)). (So no, the book section you quoted isn't
quite right :-(.) But we can't go and offer a geometry course on
this page.

* While this works for rotating points, paths, and circles, it
doesn't really work for rotating boxes, because for any rotation
angle that's not a multiple of 90 degrees, you'd need to end up with
a tilted box ... and our box type has no notion of tilted. The
specified corners rotate to the right places, but the box size isn't
preserved.

So it seems fairly unfortunate to me that the two examples of
scaling/rotation use a box as the LHS. I could get behind changing
them to use, say, a path as LHS. But I don't think there's room to
explain how to do rotation if you don't know that already, any more
than (say) our explanation of aggregate functions tries to explain
statistics.

regards, tom lane

#5David G. Johnston
david.g.johnston@gmail.com
In reply to: Strauss, Randy (ARC-AF)[SGT, INC] (#4)
Re: Lack of detailed documentation

On Monday, February 10, 2020, Strauss, Randy (ARC-AF)[SGT, INC] <
randolph.a.strauss@nasa.gov> wrote:

Yes, I figured this out. People shouldn't have to figure out that the 2
numbers in the vector are the scale and rotation.
They could be the rotation and scale. The rotation could be in degrees or
radians.
This is documentation- it should explain it.
And yes, does it rotate around its center, or the origin?
And this was just one example. Every friggin' one of them needs to be
documented.
I'm not demanding that they be done right away, but there should be a
description of each. They can all start with TBD...

I doubt anyone disagrees with the sentiment but the last time the lack of
documentation was brought up here was years ago and no one stepped up then
to volunteer their time to improve this lesser used area of the database
and it doesn’t seem likely to happen organically here either as this
message seems to imply a lack of interest in being part of the solution.

David J.

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: David G. Johnston (#5)
Re: Lack of detailed documentation

"David G. Johnston" <david.g.johnston@gmail.com> writes:

I doubt anyone disagrees with the sentiment but the last time the lack of
documentation was brought up here was years ago and no one stepped up then
to volunteer their time to improve this lesser used area of the database
and it doesn't seem likely to happen organically here either as this
message seems to imply a lack of interest in being part of the solution.

Yeah. Attached is my proposal for clarifying what to do to rotate.
There's a lot more that could be done to improve this page --- for
one thing, most of the other similar tables show the results of the
examples, and for another, it's pretty unclear which data types
each operator takes. But I don't have the time or interest to
tackle a major rewrite, and so far nobody else has stepped up either.

One thing that's sort of blocking any real progress on this is the
draconian space constraints imposed by the tabular format, which is
hurting us on a lot of these pages, not just this one. Alvaro did
some preliminary investigation towards finding a better way [1]/messages/by-id/20200116184444.GA25792@alvherre.pgsql,
but nobody's tried to push that forward.

regards, tom lane

[1]: /messages/by-id/20200116184444.GA25792@alvherre.pgsql

Attachments:

better-geometry-rotation-examples.patchtext/x-diff; charset=us-ascii; name=better-geometry-rotation-examples.patchDownload+8-2
#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tom Lane (#6)
Re: Lack of detailed documentation

I wrote:

One thing that's sort of blocking any real progress on this is the
draconian space constraints imposed by the tabular format, which is
hurting us on a lot of these pages, not just this one. Alvaro did
some preliminary investigation towards finding a better way,
but nobody's tried to push that forward.

I've been making an attempt to improve that situation, and along
the way just pushed an expansion of the geometric-operator docs:

https://www.postgresql.org/docs/devel/functions-geometry.html

There's probably still some things to be desired, but it's a lot
less fuzzy than before.

One thing that surprised me is that I couldn't find any well-known
name for what the * and / operators are doing; digging around on
the net and in some dusty old math textbooks didn't yield any exact
matches. I ended up adding footnotes with the actual computations,
but I'm not very happy with that approach. Surely Lockhart[1]I'd supposed we could blame this stuff on Berkeley, but excavation in our git history shows it came in at https://git.postgresql.org/gitweb/?p=postgresql.git&amp;a=commitdiff&amp;h=9e2a87b62db87fc4175b00dabfd26293a2d072fa ... sans documentation of course. got this
definition from someplace, though, and didn't invent it out of thin air.

regards, tom lane

[1]: I'd supposed we could blame this stuff on Berkeley, but excavation in our git history shows it came in at https://git.postgresql.org/gitweb/?p=postgresql.git&amp;a=commitdiff&amp;h=9e2a87b62db87fc4175b00dabfd26293a2d072fa ... sans documentation of course.
in our git history shows it came in at
https://git.postgresql.org/gitweb/?p=postgresql.git&amp;a=commitdiff&amp;h=9e2a87b62db87fc4175b00dabfd26293a2d072fa
... sans documentation of course.

#8David G. Johnston
david.g.johnston@gmail.com
In reply to: Tom Lane (#7)
Re: Lack of detailed documentation

On Wed, Apr 22, 2020 at 4:36 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

One thing that surprised me is that I couldn't find any well-known
name for what the * and / operators are doing; digging around on
the net and in some dusty old math textbooks didn't yield any exact
matches. I ended up adding footnotes with the actual computations,
but I'm not very happy with that approach. Surely Lockhart[1] got this
definition from someplace, though, and didn't invent it out of thin air.

I'd move the footnote indicator to:

Available for point[a], box, path, circle.
Available for point[b], box, path, circle.

As the footnote only applies to that specific left operand type.

Or maybe:

Available for box, path, and circle. It is also defined for point [a] but
it has no related physical meaning.

David J.

#9David G. Johnston
david.g.johnston@gmail.com
In reply to: David G. Johnston (#8)
Re: Lack of detailed documentation

On Wed, Apr 22, 2020 at 5:18 PM David G. Johnston <
david.g.johnston@gmail.com> wrote:

On Wed, Apr 22, 2020 at 4:36 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

One thing that surprised me is that I couldn't find any well-known
name for what the * and / operators are doing; digging around on
the net and in some dusty old math textbooks didn't yield any exact
matches. I ended up adding footnotes with the actual computations,
but I'm not very happy with that approach. Surely Lockhart[1] got this
definition from someplace, though, and didn't invent it out of thin air.

I'd move the footnote indicator to:

Available for point[a], box, path, circle.
Available for point[b], box, path, circle.

As the footnote only applies to that specific left operand type.

Or maybe:

Available for box, path, and circle. It is also defined for point [a] but
it has no related physical meaning.

Nevermind...

David J.

#10David G. Johnston
david.g.johnston@gmail.com
In reply to: Tom Lane (#7)
Re: Lack of detailed documentation

On Wed, Apr 22, 2020 at 4:36 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

Surely Lockhart[1] got this
definition from someplace, though, and didn't invent it out of thin air.

I actually viewed quite a few YouTube math videos between then and now and
looking at it now it seems familiar.

It is basically treating the points as if they were a representation of
complex numbers with x being real and y being imaginary.

https://en.wikipedia.org/wiki/Complex_number (Multiplication and Division
sections)

David J.

#11Tom Lane
tgl@sss.pgh.pa.us
In reply to: David G. Johnston (#10)
Re: Lack of detailed documentation

"David G. Johnston" <david.g.johnston@gmail.com> writes:

It is basically treating the points as if they were a representation of
complex numbers with x being real and y being imaginary.

Hah! I was too focused on looking for definitions involving vectors,
and didn't think of plain ol' complex numbers. But yes, that's exactly
what it is. I'll go improve the docs.

regards, tom lane