Documentation ¶
Overview ¶
Package s1 implements types and functions for working with geometry in S¹ (circular geometry).
See ../s2 for a more detailed overview.
Index ¶
- Constants
- type Angle
- type Interval
- func (i Interval) AddPoint(p float64) Interval
- func (i Interval) Center() float64
- func (i Interval) Contains(p float64) bool
- func (i Interval) ContainsInterval(oi Interval) bool
- func (i Interval) Expanded(margin float64) Interval
- func (i Interval) InteriorContains(p float64) bool
- func (i Interval) InteriorContainsInterval(oi Interval) bool
- func (i Interval) InteriorIntersects(oi Interval) bool
- func (i Interval) Intersection(oi Interval) Interval
- func (i Interval) Intersects(oi Interval) bool
- func (i Interval) IsEmpty() bool
- func (i Interval) IsFull() bool
- func (i Interval) IsInverted() bool
- func (i Interval) IsValid() bool
- func (i Interval) Length() float64
- func (i Interval) String() string
- func (i Interval) Union(oi Interval) Interval
- Bugs
Constants ¶
const ( Radian Angle = 1 Degree = (math.Pi / 180) * Radian E5 = 1e-5 * Degree E6 = 1e-6 * Degree E7 = 1e-7 * Degree )
Angle units.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Angle ¶
type Angle float64
Angle represents a 1D angle.
func (Angle) Normalized ¶
Normalized returns an equivalent angle in [0, 2π).
type Interval ¶
type Interval struct {
Lo, Hi float64
}
Interval represents a closed interval on a unit circle. Zero-length intervals (where Lo == Hi) represent single points. If Lo > Hi then the interval is "inverted". The point at (-1, 0) on the unit circle has two valid representations, [π,π] and [-π,-π]. We normalize the latter to the former in IntervalFromEndpoints. There are two special intervals that take advantage of that:
- the full interval, [-π,π], and
- the empty interval, [π,-π].
Treat the exported fields as read-only.
func IntervalFromEndpoints ¶
IntervalFromEndpoints constructs a new interval from endpoints. Both arguments must be in the range [-π,π].
func IntervalFromPointPair ¶
Convenience method to construct the minimal interval containing the two given points. This is equivalent to starting with an empty interval and calling AddPoint() twice, but it is more efficient.
func (Interval) AddPoint ¶
AddPoint returns the interval expanded by the minimum amount necessary such that it contains the given point "p" (an angle in the range [-Pi, Pi]).
func (Interval) Center ¶
Center returns the midpoint of the interval. It is undefined for full and empty intervals.
func (Interval) ContainsInterval ¶
ContainsInterval returns true iff the interval contains oi.
func (Interval) Expanded ¶
Expanded returns an interval that has been expanded on each side by margin. If margin is negative, then the function shrinks the interval on each side by margin instead. The resulting interval may be empty or full. Any expansion (positive or negative) of a full interval remains full, and any expansion of an empty interval remains empty.
func (Interval) InteriorContains ¶
InteriorContains returns true iff the interior of the interval contains p. Assumes p ∈ [-π,π].
func (Interval) InteriorContainsInterval ¶
InteriorContainsInterval returns true iff the interior of the interval contains oi.
func (Interval) InteriorIntersects ¶
InteriorIntersects returns true iff the interior of the interval contains any points in common with oi, including the latter's boundary.
func (Interval) Intersection ¶
Intersection returns the smallest interval that contains the intersection of the interval and oi.
func (Interval) Intersects ¶
Intersects returns true iff the interval contains any points in common with oi.
func (Interval) IsInverted ¶
IsInverted reports whether the interval is inverted; that is, whether Lo > Hi.
Notes ¶
Bugs ¶
The major differences from the C++ version are:
- no unsigned E5/E6/E7 methods
- no S2Point or S2LatLng constructors
- no comparison or arithmetic operators
The major differences from the C++ version are:
- no validity checking on construction, etc. (not a bug?)
- a few operations