Opened 8 years ago

Closed 7 years ago

Last modified 5 years ago

#3689 closed defect (fixed)

Your "Right Hand Rule" is wrong

Reported by: jyutzler Owned by: strk
Priority: medium Milestone: PostGIS 2.4.0
Component: postgis Version: 2.3.x
Keywords: Cc:

Description

Your definition of the right hand rule (e.g., http://postgis.net/docs/ST_ForceRHR.html) is backwards. All of your handedness routines are therefore wrong.

Change History (11)

comment:1 by robe, 8 years ago

Owner: changed from pramsey to strk

I refuse to touch anything that involves the term Right Hand because I'm left handed and my sense of direction if I have one is probably opposite.:)

comment:2 by dbaston, 8 years ago

I'd propose retiring this terminology, since different sources disagree on what the definition of the "Right-Hand Rule" is. Rather than argue about which definition is "right" it seems more clear to replace ST_ForceRHR/ST_ForceLHR with ST_ForceCW/ST_ForceCCW or something along those lines.

comment:3 by woodbri, 8 years ago

I think we need to be careful as this definition collides with "Right Hand Rule" in vector algebra. I would agree that changing this to reflect winding of CW or CCW would be much clearer.

comment:4 by strk, 8 years ago

I'm -1 on changing any behavior about it. If documentation isn't clear about behavior, that's the only thing that must be fixed. The interior of the polygon is on the right of the man walking around its boundary, in the direction in which the boundary lines are defined. Is that not clear ?

comment:5 by pramsey, 8 years ago

We can't just kill the function sig, even if we don't agree w/ it. I'm on side w/ dbaston that the correct replacements drop reference to "rules" and talk about CW/CCW orientation instead.

Incidentally, the RHR thing came from BC, where the standard for map data building "right hand rule" was as strk describes it above: a person walking the line would have their right hand within the bounded area. However, since computer graphics and mathematics all use it in the reverse sense (let your right thumb be orthogonal to the plane, and the direct of your fingers is the vertex you should use to bound the area) and there a lot more of those folks out there, we should start to deprecate the old sig.

comment:6 by robe, 8 years ago

+1 for deprecation.

Version 0, edited 8 years ago by robe (next)

comment:7 by dbaston, 8 years ago

I did some work to put together ST_IsCW and ST_IsCCW to address the dependency of ST_Orientation on SFGCAL (#3651, not committed); I could include ST_ForceCW and ST_ForceCCW in the same changeset and put it up as a PR for review.

We could also put a note on the doc for ST_ForceRHR noting that the definition of the RHR, as described in the doc, conflicts with the definition in some other sources such as the GeoJSON spec.

comment:9 by robe, 8 years ago

Milestone: PostGIS 2.3.2PostGIS 2.4.0

comment:10 by dbaston, 7 years ago

Resolution: fixed
Status: newclosed

comment:11 by strk, 5 years ago

For the record, this was closed via r15336

Note: See TracTickets for help on using tickets.