Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions s2/point.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ func regularPointsForFrame(frame matrix3x3, radius s1.Angle, numVertices int) []
z := math.Cos(radius.Radians())
r := math.Sin(radius.Radians())
radianStep := 2 * math.Pi / float64(numVertices)
var vertices []Point
var vertices = make([]Point, numVertices)

for i := 0; i < numVertices; i++ {
for i := range vertices {
angle := float64(i) * radianStep
p := Point{r3.Vector{X: r * math.Cos(angle), Y: r * math.Sin(angle), Z: z}}
vertices = append(vertices, Point{fromFrame(frame, p).Normalize()})
vertices[i] = Point{fromFrame(frame, p).Normalize()}
}

return vertices
Expand Down
10 changes: 10 additions & 0 deletions s2/point_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,13 @@ func TestPointEnsureNormalizable(t *testing.T) {
}
}
}

func BenchmarkPointRegularPoints(b *testing.B) {
center := PointFromLatLng(LatLngFromDegrees(80, 135))
radius := s1.Degree * 20

b.ReportAllocs()
for i := 0; i < b.N; i++ {
regularPoints(center, radius, 8)
}
}