Documentation
¶
Overview ¶
Package interval contains primitives for working with basic numeric intervals.
Index ¶
- Variables
- type In
- func (in1 In) AbsLen() float64
- func (in1 In) AsClosedContains(v float64) bool
- func (in1 In) AsOpenContains(v float64) bool
- func (in1 In) AsOpenIntersection(in2 In) (In, bool)
- func (in1 In) Clamp(v float64) float64
- func (in1 In) ClampedT(t float64) float64
- func (in1 In) ContractLimits(d float64) In
- func (in1 In) Midpoint() float64
- func (in1 In) MinMax() (float64, float64)
- func (in1 In) Opposite() In
- func (in1 In) Split(n int) []In
- func (in1 In) T(t float64) float64
- func (in1 In) TAtX(x float64) float64
- func (in1 In) TSub(t In) In
- type Pi
Constants ¶
This section is empty.
Variables ¶
PiIn is an interval from -Pi to +Pi.
Functions ¶
This section is empty.
Types ¶
type In ¶
type In [2]float64
In represents a directed interval on the real line from the first element to the second element.
func (In) AsClosedContains ¶
AsClosedContains reports whether the closed interval contains the argument value.
func (In) AsOpenContains ¶
AsOpenContains reports whether the open interval contains the argument value.
func (In) AsOpenIntersection ¶
AsOpenIntersection reports whether two non-zero length open intervals overlap and in the affirmative case returns the intersection of the intervals.
The returned intersection, if it exists, has the same direction as the receiver interval.
Returns false if there is no intersection.
func (In) ClampedT ¶
ClampedT is the interval value at the argument proportion, in the range 0..1, of the interval domain.
A t of 0 or less returns the interval's first element. A t of 1 or greater returns the interval's second element.
func (In) ContractLimits ¶
ContractLimits returns an interval with the same midpoint but with each of the interval limits moved closer to the midpoint by the given distance.
If the interval's length is less than or equals twice the given distance then the returned interval is a zero length interval.
func (In) Split ¶
Split the interval into argument almost equally sized sub intervals.
The sub intervals are in the same direction as the receiver interval.
If the interval has zero length, the return value is nil.
func (In) T ¶
T is the interval value at the argument proportion, usually in the range 0..1, of the interval domain.
type Pi ¶
type Pi [2]float64
Pi is a trig angle interval anticlockwise from the first to the second angle element, measured in radians, with values not greater than Pi in magnitude.
Numerically speaking the interval is not necessarily continuous. Usually when the start is greater than the finish then there is a discontinuity in the interval at Pi. Abstractly speaking the interval is always continuous.
The angle should be less than two Pi radians except in the case -Pi to Pi which is the canonical way to represent a complete revolution.
Two equal interval limits represent an interval whose angle is zero.
func NewPi ¶
NewPi returns a new Pi trig interval using the argument angles, measured in radians.
The argument values are clamped to the range -Pi <= angle <= Pi.
func (Pi) Angle ¶
Angle is the magnitude of the anticlockwise angle covered by the receiver trig interval.
func (Pi) AsClosedContains ¶
AsClosedContains returns whether the argument angle value, measured in radians, is contained in the closed receiver interval.
The special cases are:
* when the receiver's angle value is zero, such that the receiver interval is empty, false is always returned.
func (Pi) Complement ¶
Complement returns the other part of the possible interval space that is not occupied by the receiver interval.
The special cases are:
* if the receiver interval has an angle of zero then the returned complement is the canonical full revolution representation of -Pi to Pi.
* if the receiver interval has an angle of exactly two Pi then the returned complement is an empty revolution representation of 0 to 0.
func (Pi) Containing ¶
Containing returns a pi trig interval with the same limits as the receiver containing the argument angle which shall be measured in radians and in the range -Pi to Pi.
The argument angle shall not coincide with an interval limit.
func (Pi) Interval ¶
Interval returns the interval that is equivalent to the receiver trig interval.
Interval prefers to return an interval whose limits are in the range -Pi to Pi but when this isn't possible the returned interval's endpoint can be greater than Pi.
func (Pi) Intervals ¶
Intervals returns the intervals, where each one is numerically continuous, that together are equivalent to the receiver trig interval.
The returned intervals are in the range -Pi to Pi.
func (Pi) IsContinuous ¶
IsContinuous returns whether the receiver trig interval can be represented as a single continuous interval in the range -Pi to Pi.
func (Pi) NotContaining ¶
NotContaining returns a pi trig interval with the same limits as the receiver which does not contain the argument angle which shall be measured in radians and in the range -Pi to Pi.
The argument angle shall not coincide with an interval limit.