Documentations › mmo.client › js › math Interval MMO.math · 1 symbol · generated 5 Oct 2026
A one dimensional interval [start,end], each bound open or closed, infinities allowed.
class MMO.math.Interval Namespace MMO.mathThe 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) static The degenerate interval holding exactly one value. FromDates(start, end, ignoreTime, includeStart, includeEnd) static Create 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 = true, includeEnd = true) start number | stringend number | stringincludeStart = true booleanis the lower bound part of the interval includeEnd = true booleanis the upper bound part of the interval
The degenerate interval holding exactly one value.
static FromValue(value, isIncluded = true) value numberisIncluded = true booleanfalse makes it EMPTY, which is sometimes what you want returns MMO.math.Interval
FromDates(start, end, ignoreTime, includeStart, includeEnd) static Interval.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(). start Date | nullend Date | nullignoreTime = false booleanif true, start's time is set to 00:00:00 and end's to 23:59:59 includeStart = true booleanincludeEnd = true boolean
static Empty() static Infinity() clone() toString() returns stringthe mathematical notation, [ and ] turned outwards when open
withEnd(end, includeEnd = null) end numberincludeEnd = null ?booleankeeps this interval's own value when null returns MMO.math.Interval a NEW interval ending elsewhere
withStart(start, includeStart = null) start numberincludeStart = null ?booleankeeps this interval's own value when null returns MMO.math.Interval a NEW interval starting elsewhere
getStorage(create = false) addStorage(storage) hasStorage() returns booleantrue when at least one object is attached
Detach every object.
freeStorage() Attach an object to this interval; it travels with it through the set operations.
attach(object, info = null) object Objectinfo = null *anything to remember alongside it
storageObjects() returns Array<Object>the attached objects
The smallest interval covering this one, i.e. itself.
limit() It exists so an Interval and a `MMO.math.Domain` can be used interchangeably. position(value) The euclidean distance between two intervals, taking (start,end) as a point in the plane.
distance(value) size() returns numberthe interval's length, Infinity when unbounded
norm() returns numberthe euclidean norm of (start,end)
This interval as a list, so it can stand in for a MMO.math.Domain
intervals() returns Array<MMO.math.Interval>empty when this interval is
isEmpty() returns booleantrue when the interval holds no value at all
Test whether a value lies entirely inside this interval.
contains(value) Test whether a value shares any point with this interval.
overlap(value) Test whether a value covers exactly the same points, bounds included.
isEqual(value) Intersection
intersect(value) Union
union(value) Exclusion
exclude(value) Inverse
inverse() offsetBy(offset) offset numberreturns MMO.math.Interval a NEW interval slid along the axis; this one is untouched
Get a normal vector from this interval (start at 0, with a length of [0,1])
normalize()