...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package s2
16
17 const laxPolylineTypeTag = 4
18
19
20
21
22
23
24
25
26
27 type LaxPolyline struct {
28 vertices []Point
29 }
30
31
32 func LaxPolylineFromPoints(vertices []Point) *LaxPolyline {
33 return &LaxPolyline{
34 vertices: append([]Point(nil), vertices...),
35 }
36 }
37
38
39 func LaxPolylineFromPolyline(p Polyline) *LaxPolyline {
40 return LaxPolylineFromPoints(p)
41 }
42
43 func (l *LaxPolyline) NumEdges() int { return maxInt(0, len(l.vertices)-1) }
44 func (l *LaxPolyline) Edge(e int) Edge { return Edge{l.vertices[e], l.vertices[e+1]} }
45 func (l *LaxPolyline) ReferencePoint() ReferencePoint { return OriginReferencePoint(false) }
46 func (l *LaxPolyline) NumChains() int { return minInt(1, l.NumEdges()) }
47 func (l *LaxPolyline) Chain(i int) Chain { return Chain{0, l.NumEdges()} }
48 func (l *LaxPolyline) ChainEdge(i, j int) Edge { return Edge{l.vertices[j], l.vertices[j+1]} }
49 func (l *LaxPolyline) ChainPosition(e int) ChainPosition { return ChainPosition{0, e} }
50 func (l *LaxPolyline) Dimension() int { return 1 }
51 func (l *LaxPolyline) IsEmpty() bool { return defaultShapeIsEmpty(l) }
52 func (l *LaxPolyline) IsFull() bool { return defaultShapeIsFull(l) }
53 func (l *LaxPolyline) typeTag() typeTag { return typeTagLaxPolyline }
54 func (l *LaxPolyline) privateInterface() {}
55
56
57
58
59
View as plain text