MCPcopy
hub / github.com/golang/geo / generateCapEdges

Function generateCapEdges

s2/crossing_edge_query_test.go:72–83  ·  view source on GitHub ↗

generateCapEdges creates edges whose center is randomly chosen from the given cap, and whose length is randomly chosen up to maxLength.

(centerCap Cap, maxLength s1.Angle, count int)

Source from the content-addressed store, hash-verified

70// generateCapEdges creates edges whose center is randomly chosen from the given cap, and
71// whose length is randomly chosen up to maxLength.
72func generateCapEdges(centerCap Cap, maxLength s1.Angle, count int) []Edge {
73 var edges []Edge
74 for range count {
75 center := samplePointFromCap(centerCap)
76 edgeCap := CapFromCenterAngle(center, 0.5*maxLength)
77 p1 := samplePointFromCap(edgeCap)
78 // Compute p1 reflected through center, and normalize for good measure.
79 p2 := Point{(center.Mul(2 * p1.Dot(center.Vector)).Sub(p1.Vector)).Normalize()}
80 edges = append(edges, Edge{p1, p2})
81 }
82 return edges
83}
84
85func testCrossingEdgeQueryAllCrossings(t *testing.T, edges []Edge) {
86 s := &edgeVectorShape{}

Calls 6

samplePointFromCapFunction · 0.85
CapFromCenterAngleFunction · 0.85
NormalizeMethod · 0.45
SubMethod · 0.45
MulMethod · 0.45
DotMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…