Methods
-
<static> AABBContains(aminX, aminY, amaxX, amaxY, bminX, bminY, bmaxX, bmaxY) → {Boolean}
-
Checks two 2D axis aligned bounding boxes: is A contained by B?
Parameters:Name Type Description aminXNumber A left aminYNumber A top amaxXNumber A right amaxYNumber A bottom bminXNumber B left bminYNumber B top bmaxXNumber B right bmaxYNumber B bottom - Source:
{ Boolean } whether bounds A contains bounds B -
<static> AABBIntersect(aminX, aminY, amaxX, amaxY, bminX, bminY, bmaxX, bmaxY) → {Boolean}
-
Checks two 2D axis aligned bounding boxes: does A intersect B?
Parameters:Name Type Description aminXNumber A left aminYNumber A top amaxXNumber A right amaxYNumber A bottom bminXNumber B left bminYNumber B top bmaxXNumber B right bmaxYNumber B bottom - Source:
{ Boolean } whether bounds intersect -
<static> bounds(x, y, width, height, bounds) → {Object}
-
Calculates bounds from a position and dimensions.
Parameters:Name Type Argument Description xNumber x position of top left yNumber y position of top left widthNumber width heightNumber height boundsObject <optional>
bounding object - Source:
{ Object } bounding objectExample// get bounds var bounds = ig.utilsintersection.bounds( 0, 0, 100, 100 ); // left bounds.minX; // right bounds.maxX; // top bounds.minY; // bottom bounds.maxY; // width bounds.width; // height bounds.height; -
<static> boundsAABBIntersect(bounds, minX, minY, maxX, maxY) → {Boolean}
-
This is a convenience method to test intersection of two bounding boxes.
Parameters:
Returns:Name Type Description boundsObject bounding object A minXNumber B left minYNumber B top maxXNumber B right maxYNumber B bottom { Boolean } whether bounds intersect -
<static> boundsClone(boundsSource, offsetX, offsetY, bounds) → {Object}
-
Clones a bounds object, with the addition of optional offset position.
Parameters:
Returns:Name Type Argument Default Description boundsSourceObject bounds to clone offsetXNumber <optional>
0 offset x offsetYNumber <optional>
0 offset y boundsObject <optional>
bounding object { Object } bounding object clone. -
<static> boundsCopy(boundsA, boundsB, offsetX, offsetY, scaleX, scaleY) → {Object}
-
Copies a bounds object into another bounds object, with the addition of optional offset position and scale.
Parameters:
Returns:Name Type Argument Default Description boundsAObject bounds to copy into boundsBObject bounds to copy from offsetXNumber <optional>
0 offset x offsetYNumber <optional>
0 offset y scaleXNumber <optional>
1 scale x scaleYNumber <optional>
1 scale y { Object } bounding object based on bounds plus offset -
<static> boundsCopyRotated(boundsA, boundsB, angle) → {Object}
-
Copies bounds after rotated by angle.
Parameters:Name Type Description boundsAObject bounds to copy into boundsBObject bounds to rotate angleNumber angle in radians - Source:
{ Object } boundsA -
<static> boundsCopyX(boundsA, boundsB, offsetX, scaleX) → {Object}
-
Copies the horizontal properties of a bounds object into another bounds object, with the addition of optional offset position and scale.
Parameters:
Returns:Name Type Argument Default Description boundsAObject bounds to copy into boundsBObject bounds to copy from offsetXNumber <optional>
0 offset x scaleXNumber <optional>
1 scale x { Object } bounding object based on bounds plus offset -
<static> boundsCopyY(boundsA, boundsB, offsetY, scaleY) → {Object}
-
Copies the vertical properties of a bounds object into another bounds object, with the addition of optional offset position and scale.
Parameters:
Returns:Name Type Argument Default Description boundsAObject bounds to copy into boundsBObject bounds to copy from offsetYNumber <optional>
0 offset y scaleYNumber <optional>
1 scale y { Object } bounding object based on bounds plus offset -
<static> boundsIntersect(boundsA, boundsB) → {Boolean}
-
This is a convenience method to test intersection of two bounding boxes.
Parameters:
Returns:Name Type Description boundsAObject bounding object A boundsBObject bounding object B { Boolean } whether bounds intersect -
<static> boundsMinMax(minX, minY, maxX, maxY, bounds) → {Object}
-
Calculates bounds from min/max values.
Parameters:Name Type Argument Description minXNumber x position of top left minYNumber y position of top left maxXNumber x position of bottom right maxYNumber y position of bottom right boundsObject <optional>
bounding object - Source:
{ Object } bounding objectExample// get bounds var bounds = ig.utilsintersection.boundsMinMax( 0, 0, 100, 100 ); // left bounds.minX; // right bounds.maxX; // top bounds.minY; // bottom bounds.maxY; // width bounds.width; // height bounds.height; -
<static> boundsOfPoints(points, bounds) → {Object}
-
Returns bounds from a set of points. Tip: each point should be an object with x and y values.
Parameters:Name Type Argument Description pointsArray Array of points. boundsObject <optional>
bounding object - Source:
{ Object } bounding objectExample// get bounds var bounds = ig.utilsintersection.boundsOfPoints( [ {x: 0, y: 0}, {x: 100, y: 0}, {x: 100, y: 100}, {x: 0, y: 100} ]); // left bounds.minX; // right bounds.maxX; // top bounds.minY; // bottom bounds.maxY; // width bounds.width; // height bounds.height; -
<static> entitiesInAABB(minX, minY, maxX, maxY, targetable, layerName, unsorted) → {Array}
-
Finds all entities intersecting an axis aligned bounding box in world space coordinates.
Parameters:Name Type Argument Description minXNumber left position. minYNumber top position. maxXNumber right position. maxYNumber bottom position. targetableBoolean <optional>
only find entities that are targetable. layerNameObject <optional>
name of layer to search. unsortedBoolean <optional>
whether to sort. - Source:
{ Array } list of all entities intersecting box. -
<static> getIsAABBInScreen(x, y, width, height) → {Boolean}
-
Gets if an axis aligned bounding box is in the screen.
Parameters:Name Type Description xNumber bounds top left x position yNumber bounds top left y position widthNumber bounds width heightNumber bounds height - Source:
{ Boolean } whether bounds is in screen -
<static> pointInAABB(x, y, minX, minY, maxX, maxY) → {Boolean}
-
This is a convenience method to test intersection of a point with a bounding box.
Parameters:
Returns:Name Type Description xNumber point x yNumber point y minXNumber bounds left minYNumber bounds top maxXNumber bounds right maxYNumber bounds bottom { Boolean } whether point is inside bounds -
<static> pointInBounds(x, y, bounds) → {Boolean}
-
This is a convenience method to test intersection of a point with a bounding box.
Parameters:
Returns:Name Type Description xNumber point x yNumber point y boundsObject bounding object { Boolean } whether point is inside bounds -
<static> pointInCircle(x, y, cx, cy, radius) → {Boolean}
-
Checks if a point lies inside or on the edge of a circle.
Parameters:Name Type Description xNumber point x yNumber point y cxNumber center x of circle cyNumber center y of circle radiusNumber radius of circle - Source:
{ Boolean } whether point is inside circle -
<static> pointInPolygon(x, y, vertices) → {Boolean}
-
Determine if a point is inside a polygon.
Parameters:Name Type Description xNumber point x yNumber point y verticesArray array of vertices that defines a polygon - Source:
{ Boolean } true if polygon contains the given point -
<static> sortByDistance(x, y, entities) → {Array}
-
Sort a list of entities by distance to a point in world space coordinates. IMPORTANT: this modifies the array in place.
Parameters:Name Type Description xNumber x position yNumber y position entitiesArray list of entities - Source:
{ Array } list of entities modified in place.

Impact++