Index

Interval

MMO.math · 1 symbol · generated 5 Oct 2026

class

Interval

Interval.js:16

A one dimensional interval [start,end], each bound open or closed, infinities allowed.

class MMO.math.Interval
Namespace
MMO.math
The bounds are normalised: passing them the wrong way round swaps them, inclusiveness included, so an interval always has `start <= end`. Any object can be ATTACHED to an interval (`MMO.math.Interval#attach`). That storage survives the set operations, which is what lets a `MMO.math.Domain` answer "which of my objects cover this range".
new MMO.math.Interval(0, 10, true, false).toString();//'[0,10['

Index

constructor(start, end, includeStart, includeEnd)
FromValue(value, isIncluded) staticThe degenerate interval holding exactly one value.
FromDates(start, end, ignoreTime, includeStart, includeEnd) staticCreate an interval from dates.
Empty() static
Infinity() static
clone()
toString()
withEnd(end, includeEnd)
withStart(start, includeStart)
getStorage(create)
addStorage(storage)
hasStorage()
freeStorage()Detach every object.
attach(object, info)Attach an object to this interval; it travels with it through the set operations.
storageObjects()
limit()The smallest interval covering this one, i.e.
position(value)
distance(value)The euclidean distance between two intervals, taking (start,end) as a point in the plane.
size()
norm()
intervals()This interval as a list, so it can stand in for a MMO.math.Domain
isEmpty()
contains(value)Test whether a value lies entirely inside this interval.
overlap(value)Test whether a value shares any point with this interval.
isEqual(value)Test whether a value covers exactly the same points, bounds included.
intersect(value)Intersection
union(value)Union
exclude(value)Exclusion
inverse()Inverse
offsetBy(offset)
normalize()Get a normal vector from this interval (start at 0, with a length of [0,1])

Methods31

constructor(start, end, includeStart, includeEnd)

Interval.js:23
constructor(start, end, includeStart = true, includeEnd = true)
startnumber | string
endnumber | string
includeStart = truebooleanis the lower bound part of the interval
includeEnd = truebooleanis the upper bound part of the interval

FromValue(value, isIncluded)

staticInterval.js:49

The degenerate interval holding exactly one value.

static FromValue(value, isIncluded = true)
valuenumber
isIncluded = truebooleanfalse makes it EMPTY, which is sometimes what you want
returnsMMO.math.Interval

FromDates(start, end, ignoreTime, includeStart, includeEnd)

staticInterval.js:66

Create an interval from dates.

static FromDates(start, end, ignoreTime = false, includeStart = true, includeEnd = true)NOTE: PHP's DateTimeInterface::format('H'|'i'|'s') uses the timezone carried by the DateTime object. JS Date has no attached timezone, so getHours/getMinutes/getSeconds below use the host's LOCAL timezone. Swap for getUTCHours/... if you need UTC. Timestamps stay in seconds, like PHP's getTimestamp().
startDate | null
endDate | null
ignoreTime = falsebooleanif true, start's time is set to 00:00:00 and end's to 23:59:59
includeStart = trueboolean
includeEnd = trueboolean

toString()

Interval.js:104
toString()
returnsstringthe mathematical notation, [ and ] turned outwards when open

withEnd(end, includeEnd)

Interval.js:116
withEnd(end, includeEnd = null)
endnumber
includeEnd = null?booleankeeps this interval's own value when null
returnsMMO.math.Intervala NEW interval ending elsewhere

withStart(start, includeStart)

Interval.js:127
withStart(start, includeStart = null)
startnumber
includeStart = null?booleankeeps this interval's own value when null
returnsMMO.math.Intervala NEW interval starting elsewhere

addStorage(storage)

Interval.js:141
addStorage(storage)
storageMap<object, any>

hasStorage()

Interval.js:149
hasStorage()
returnsbooleantrue when at least one object is attached

attach(object, info)

Interval.js:165

Attach an object to this interval; it travels with it through the set operations.

attach(object, info = null)
objectObject
info = null*anything to remember alongside it

storageObjects()

Interval.js:172
storageObjects()
returnsArray<Object>the attached objects

limit()

Interval.js:184

The smallest interval covering this one, i.e. itself.

limit()It exists so an Interval and a `MMO.math.Domain` can be used interchangeably.

distance(value)

Interval.js:213

The euclidean distance between two intervals, taking (start,end) as a point in the plane.

distance(value)
valueMMO.math.Interval
returnsnumber

size()

Interval.js:220
size()
returnsnumberthe interval's length, Infinity when unbounded

intervals()

Interval.js:235

This interval as a list, so it can stand in for a MMO.math.Domain

intervals()
returnsArray<MMO.math.Interval>empty when this interval is

isEmpty()

Interval.js:242
isEmpty()
returnsbooleantrue when the interval holds no value at all

normalize()

Interval.js:425

Get a normal vector from this interval (start at 0, with a length of [0,1])

normalize()