-
Notifications
You must be signed in to change notification settings - Fork 191
Implement S2R2Rect #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Implement S2R2Rect #253
Conversation
| return math.Max(i.Lo, math.Min(i.Hi, p)) | ||
| } | ||
|
|
||
| func (i Interval) Project(p float64) float64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document all public methods. You can take inspiration from the cpp implementation at https://github.com/google/s2geometry/blob/ac448e2e939863dfefdeb6500ea74fda92d8187c/src/s2/r1interval.h#L172, but make sure you follow https://go.dev/doc/comment#func.
s2/r2rect.go
Outdated
| return r.CapBound().CellUnionBound() | ||
| } | ||
|
|
||
| // func (r R2Rect) ContainsPoint(p Point) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these commented out?
s2/r2rect.go
Outdated
| return r.CapBound().CellUnionBound() | ||
| } | ||
|
|
||
| // func (r R2Rect) ContainsPoint(p Point) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented out?
jmr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before I get too far into the details, why do you want this?
Are you just checking things off the "done" list, or do you have a use case?
This class isn't really used much. There was once an idea that the geometry library would handle both planar and spherical geometry, but the planar part isn't well developed.
The comments say it's a "stopgap measure" (which is admittedly now 20 years old).
| } | ||
|
|
||
| func (i Interval) Project(p float64) float64 { | ||
| if p < i.Lo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
| } | ||
|
|
||
| func (r Rect) Vertex(k int) Point { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All public functions should be directly tested.
| return Point{r.X.ClampPoint(p.X), r.Y.ClampPoint(p.Y)} | ||
| } | ||
|
|
||
| func (r Rect) Project(p Point) Point { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function doesn't come from C++ as far as I can see.
|
Tests are broken, but should be fixed by #255. |
Hi @jmr, I don't have a specific use case, just checking off indeed. If you want to put this on hold or drop it, it's fine by me. |
Fully implement
S2R2Rectwith testing