s1

package
v0.0.0-...-40ad1ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2015 License: Apache-2.0 Imports: 2 Imported by: 0

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

View Source
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) Abs

func (a Angle) Abs() Angle

Abs returns the absolute value of the angle.

func (Angle) Degrees

func (a Angle) Degrees() float64

Degrees returns the angle in degrees.

func (Angle) E5

func (a Angle) E5() int32

E5 returns the angle in hundred thousandths of degrees.

func (Angle) E6

func (a Angle) E6() int32

E6 returns the angle in millionths of degrees.

func (Angle) E7

func (a Angle) E7() int32

E7 returns the angle in ten millionths of degrees.

func (Angle) Normalized

func (a Angle) Normalized() Angle

Normalized returns an equivalent angle in [0, 2π).

func (Angle) Radians

func (a Angle) Radians() float64

Radians returns the angle in radians.

func (Angle) String

func (a Angle) String() string

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 EmptyInterval

func EmptyInterval() Interval

EmptyInterval returns an empty interval.

func FullInterval

func FullInterval() Interval

FullInterval returns a full interval.

func IntervalFromEndpoints

func IntervalFromEndpoints(lo, hi float64) Interval

IntervalFromEndpoints constructs a new interval from endpoints. Both arguments must be in the range [-π,π].

func IntervalFromPointPair

func IntervalFromPointPair(p1, p2 float64) Interval

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

func (i Interval) AddPoint(p float64) Interval

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

func (i Interval) Center() float64

Center returns the midpoint of the interval. It is undefined for full and empty intervals.

func (Interval) Contains

func (i Interval) Contains(p float64) bool

Contains returns true iff the interval contains p. Assumes p ∈ [-π,π].

func (Interval) ContainsInterval

func (i Interval) ContainsInterval(oi Interval) bool

ContainsInterval returns true iff the interval contains oi.

func (Interval) Expanded

func (i Interval) Expanded(margin float64) Interval

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

func (i Interval) InteriorContains(p float64) bool

InteriorContains returns true iff the interior of the interval contains p. Assumes p ∈ [-π,π].

func (Interval) InteriorContainsInterval

func (i Interval) InteriorContainsInterval(oi Interval) bool

InteriorContainsInterval returns true iff the interior of the interval contains oi.

func (Interval) InteriorIntersects

func (i Interval) InteriorIntersects(oi Interval) bool

InteriorIntersects returns true iff the interior of the interval contains any points in common with oi, including the latter's boundary.

func (Interval) Intersection

func (i Interval) Intersection(oi Interval) Interval

Intersection returns the smallest interval that contains the intersection of the interval and oi.

func (Interval) Intersects

func (i Interval) Intersects(oi Interval) bool

Intersects returns true iff the interval contains any points in common with oi.

func (Interval) IsEmpty

func (i Interval) IsEmpty() bool

IsEmpty reports whether the interval is empty.

func (Interval) IsFull

func (i Interval) IsFull() bool

IsFull reports whether the interval is full.

func (Interval) IsInverted

func (i Interval) IsInverted() bool

IsInverted reports whether the interval is inverted; that is, whether Lo > Hi.

func (Interval) IsValid

func (i Interval) IsValid() bool

IsValid reports whether the interval is valid.

func (Interval) Length

func (i Interval) Length() float64

Length returns the length of the interval. The length of an empty interval is negative.

func (Interval) String

func (i Interval) String() string

func (Interval) Union

func (i Interval) Union(oi Interval) Interval

Union returns the smallest interval that contains both the interval and oi.

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL