-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from PDOK/areyouinorout
various things from processing ozon on z0
- Loading branch information
Showing
6 changed files
with
685 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package snap | ||
|
||
import "math" | ||
|
||
// https://en.wikipedia.org/wiki/Shoelace_formula | ||
func shoelace(pts [][2]float64) float64 { | ||
sum := 0. | ||
if len(pts) == 0 { | ||
return 0. | ||
} | ||
|
||
p0 := pts[len(pts)-1] | ||
for _, p1 := range pts { | ||
sum += p0[1]*p1[0] - p0[0]*p1[1] | ||
p0 = p1 | ||
} | ||
return math.Abs(sum / 2) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.