golang / geo

S2 geometry library in Go
Apache License 2.0
1.69k stars 182 forks source link

Cell.Edge does not do what is claimed in doc comment #11

Closed djadala closed 8 years ago

djadala commented 8 years ago

Cell.Edge returns edge from vertex 3 to vertex 0 if k >= 3, documentation claim: edge from vertex k to vertex k+1 (mod 4)

switch should be switch k%4 { or switch k&0x03 { https://github.com/golang/geo/blob/master/s2/cell.go#L78

dsymonds commented 8 years ago

@rsned ?

dsymonds commented 8 years ago

Hah, it looks like the C++ we ported from also has this mistake.

dsymonds commented 8 years ago

Actually, it's just a misleading comment. It isn't saying it returns vertex k (mod 4), but only vertex k+1 (mod 4), implicitly assuming that k is 0-3.

dsymonds commented 8 years ago

I'll clarify the doc comment.