Packagecom.yworks.canvas.geom
Classpublic final class GeomSupport
InheritanceGeomSupport Inheritance Object

Utility class that performs all kind of geometric operations.

In addition, it serves as a factory for various implementations of geometric primitives.



Public Methods
 MethodDefined By
  
[static] Enlarges the given rect by the given insets.
GeomSupport
  
[static] Adds a point to a rectangle, possibly enlarging the rectangle.
GeomSupport
  
[static] Adds a rectangle to another one.
GeomSupport
  
calculateSegmentTangent(controlPoints:IControlPoints, segment:int, ratio:Number, p:YPoint, v:YPoint):Boolean
[static] Calculates the tangent on the path defined by the control points at the given segment and ratio point.
GeomSupport
  
[static] Create a dynamic IPoint implementation that always points to the center of the given rectangle.
GeomSupport
  
[static] Create a dynamic IPoint implementation that always points to the specified position at the given rectangle.
GeomSupport
  
distance(p:IPoint, q:IPoint):Number
[static] Calculates the euclidean distance between two points.
GeomSupport
  
distance2(px:Number, py:Number, qx:Number, qy:Number):Number
[static] Calculates the euclidean distance between two points.
GeomSupport
  
[static] Calculates the euclidean distance between two rectangles.
GeomSupport
  
ellipseContains(x:Number, y:Number, width:Number, height:Number, px:Number, py:Number, epsilon:Number):Boolean
[static] Checks whether an ellipse contains the given point.
GeomSupport
  
findEllipseLineIntersection(x:Number, y:Number, width:Number, height:Number, innerX:Number, innerY:Number, outerX:Number, outerY:Number, intersectionPoint:IPointSetter):Boolean
[static] Returns the ellipse/line intersection point for the given point pair.
GeomSupport
  
findLineIntersection(l1x1:Number, l1y1:Number, l1x2:Number, l1y2:Number, l2x1:Number, l2y1:Number, l2x2:Number, l2y2:Number):IPoint
[static] Find the intersection point of two lines if one exists.
GeomSupport
  
findLineSegmentIntersection(l1x1:Number, l1y1:Number, l1x2:Number, l1y2:Number, l2x1:Number, l2y1:Number, l2x2:Number, l2y2:Number):Number
[static] Find the intersection of two line segments if one exists.
GeomSupport
  
findRectangleLineIntersection(rect:IRectangle, innerX:Number, innerY:Number, outerX:Number, outerY:Number, intersectionPoint:IPointSetter):Boolean
[static] Finds the intersection between a rectangle and a line.
GeomSupport
  
[static] Returns the current center of the oriented rectangle.
GeomSupport
  
[static] Creates a constrained copy of the given location that lies within the given rectangle.
GeomSupport
  
[static] Returns the current center point of the rectangle.
GeomSupport
  
grow(rectangle:IMutableRectangle, width:Number):void
[static] Grows a mutable rectangle given a stroke width.
GeomSupport
  
[static] Creates the union of two insets rectangles, placing the result in a third.
GeomSupport
  
lineContains(x1:Number, y1:Number, x2:Number, y2:Number, testX:Number, testY:Number, epsilon:Number):Boolean
[static] Determines whether a given line is hit by a point given an epsilon.
GeomSupport
  
[static] Determines the bounds of an oriented rectangle.
GeomSupport
  
orientedRectangleContains(rect:IOrientedRectangle, x:Number, y:Number, epsilon:Number):Boolean
[static] Determines whether the given oriented rectangle contains the provided point, using an epsilon value.
GeomSupport
  
pointHits(x:Number, y:Number, testX:Number, testY:Number, hitTestRadius:Number):Boolean
[static] Determines if two points lie close to each other given an epsilon.
GeomSupport
  
pointLineDistance(x1:Number, y1:Number, x2:Number, y2:Number, px:Number, py:Number):Number
[static] Determines the distance between a point and a line.
GeomSupport
  
pointsAreEqual(p1:IPoint, p2:IPoint):Boolean
[static] Compares if the x and y coordinates of the given points are equal.
GeomSupport
  
polyLineContains(x:Number, y:Number, controlPoints:IControlPoints, epsilon:Number):Boolean
[static] Determines whether a polygonal line is hit by a point given an epsilon.
GeomSupport
  
polyLineIntersects(rect:IRectangle, controlPoints:IControlPoints, epsilon:Number):Boolean
[static] Determines whether a rectangle intersects a polygonal line.
GeomSupport
  
projectOnLine(x1:Number, y1:Number, dx:Number, dy:Number, px:Number, py:Number):IPoint
[static] Determines the closest point on a line to a given point.
GeomSupport
  
projectOnSegment(x1:Number, y1:Number, x2:Number, y2:Number, px:Number, py:Number):IPoint
[static] Determines the closest point on a line segment to a given point.
GeomSupport
  
rectangleContains(x:Number, y:Number, w:Number, h:Number, px:Number, py:Number, epsilon:Number = 0):Boolean
[static] Determines whether the given rectangle contains the provided point.
GeomSupport
  
[static] Determines whether two rectangles intersect.
GeomSupport
  
rectangleIntersectsLine(boxX:Number, boxY:Number, boxWidth:Number, boxHeight:Number, x1:Number, y1:Number, x2:Number, y2:Number, epsilon:Number = 0):Boolean
[static] Determines whether a rectangle intersects a line.
GeomSupport
  
rectangleIntersectsOriented(rectangle:IRectangle, orientedRectangle:IOrientedRectangle, epsilon:Number):Boolean
[static] Determines whether a rectangle intersects an oriented rectangle, given an epsilon.
GeomSupport
  
[static] Compares if the x and y coordinates as well as the width and height values of the given rectangles are equal.
GeomSupport
  
setCenter(orientedRectangle:IMutableOrientedRectangle, cx:Number, cy:Number):IMutableOrientedRectangle
[static] Sets the anchor of an IMutableOrientedRectangle so that the center of the rectangle coincides with the given coordinate pair.
GeomSupport
  
[static] Convenience method that reshapes the provided rectangle to have the same bounds as src.
GeomSupport
  
[static] Calculates the square of the euclidean distance between two points.
GeomSupport
  
squaredDistance2(x1:Number, y1:Number, x2:Number, y2:Number):Number
[static] Calculates the square of the euclidean distance between two points.
GeomSupport
  
[static] Transforms a rectangle that is used as a bounding box using a matrix and places the result in another bounds object.
GeomSupport
  
[static] Creates the union of two rectangles, placing the result in a third.
GeomSupport
Method Detail
addInsetsToRectangle()method
public static function addInsetsToRectangle(rect:IRectangle, insets:IRectangle):IRectangle

Enlarges the given rect by the given insets.

Parameters

rect:IRectangle — The rectangle to enlarge.
 
insets:IRectangle — The insets to add to the rectangle.

Returns
IRectangle — The unmodified rect if it's width or height are negative or a new rectangle enlarging the rect's initial bounds with the given insets.
addPointToRectangle()method 
public static function addPointToRectangle(rect:IMutableRectangle, p:IPoint):IMutableRectangle

Adds a point to a rectangle, possibly enlarging the rectangle.

If the rectangle is initially empty, i.e. its width or height is negative, the bounds of the rectangle will be set to (p.x, p.y, 0, 0)

Parameters

rect:IMutableRectangle — The rectangle to add to.
 
p:IPoint — The coordinate to include in the bounds.

Returns
IMutableRectangle — The resulting rectangle, which is the parameter rect
addRectangle()method 
public static function addRectangle(toModify:IMutableRectangle, toBeAdded:IRectangle):IMutableRectangle

Adds a rectangle to another one.

The result is placed into the first rectangle, which is returned. If either of the two rectangles is empty, i.e. it's width or height is negative, the result will be the other rectangle.

Parameters

toModify:IMutableRectangle — The rectangle to modify.
 
toBeAdded:IRectangle — The rectangle to be added.

Returns
IMutableRectangle — The first rectangle.
calculateSegmentTangent()method 
public static function calculateSegmentTangent(controlPoints:IControlPoints, segment:int, ratio:Number, p:YPoint, v:YPoint):Boolean

Calculates the tangent on the path defined by the control points at the given segment and ratio point.

The result is provided through the given point parameters. If the method returns false, no valid result could be calculated and the values of the point parameters should be ignored.

Parameters

controlPoints:IControlPoints — The list of points that is interpreted as a number of line segments.
 
segment:int — the index of the zero-based segment.
 
ratio:Number — a value in [0,1] where 0 is at the start point and 1 is at the target point of the specified segment.
 
p:YPoint — A point in world-coordinate space that denotes the tangent point.
 
v:YPoint — The vector which is tangent to the segment at the point p. The tangent vector needs not necessarily be normalized.

Returns
Booleantrue iff the values written to the given points are valid.
createRectangleCenter()method 
public static function createRectangleCenter(rect:IRectangle):IPoint

Create a dynamic IPoint implementation that always points to the center of the given rectangle.

Parameters

rect:IRectangle — The rectangle that will be used for providing the center.

Returns
IPoint — A live view of the rectangle's center.
createRectanglePoint()method 
public static function createRectanglePoint(rect:IRectangle, position:uint):IPoint

Create a dynamic IPoint implementation that always points to the specified position at the given rectangle.

Parameters

rect:IRectangle — The rectangle that will be used for providing the center.
 
position:uint — One of the RectangleHandlePositions to use.

Returns
IPoint

See also

distance()method 
public static function distance(p:IPoint, q:IPoint):Number

Calculates the euclidean distance between two points.

Parameters

p:IPoint — The first point.
 
q:IPoint — The second point.

Returns
Number — The distance.
distance2()method 
public static function distance2(px:Number, py:Number, qx:Number, qy:Number):Number

Calculates the euclidean distance between two points.

Parameters

px:Number — The x value of the first point
 
py:Number — The y value of the first point
 
qx:Number — The x value of the second point
 
qy:Number — The y value of the second point

Returns
Number — The distance.
distanceBetweenRectangles()method 
public static function distanceBetweenRectangles(rect1:IRectangle, rect2:IRectangle):Number

Calculates the euclidean distance between two rectangles.

If the rectangles intersect their distance is 0, otherwise the minimum euclidean distance between any points in rect1 and rect2 is returned.

Parameters

rect1:IRectangle — The first rectangle.
 
rect2:IRectangle — The second rectangle.

Returns
Number — The euclidean distance between two points o
ellipseContains()method 
public static function ellipseContains(x:Number, y:Number, width:Number, height:Number, px:Number, py:Number, epsilon:Number):Boolean

Checks whether an ellipse contains the given point.

Parameters

x:Number — The x coordinate of the upper left corner of the ellipse's enclosing rectangle.
 
y:Number — The y coordinate of the upper left corner of the ellipse's enclosing rectangle.
 
width:Number — The width of the ellipse's enclosing rectangle.
 
height:Number — The height of the ellipse's enclosing rectangle..
 
px:Number — The x coordinate of the point to test.
 
py:Number — The y coordinate of the point to test.
 
epsilon:Number — A positive value allows for fuzzy hit testing. If the point lies outside the given object but it's distance is less than or equal to that value, it will be considered a hit.

Returns
Boolean — Whether the point lies within the ellipse
findEllipseLineIntersection()method 
public static function findEllipseLineIntersection(x:Number, y:Number, width:Number, height:Number, innerX:Number, innerY:Number, outerX:Number, outerY:Number, intersectionPoint:IPointSetter):Boolean

Returns the ellipse/line intersection point for the given point pair.

This will always return the intersection point that lies in the direction from inner to outer.

Parameters

x:Number — The x coordinate of the upper left corner of the ellipse's enclosing rectangle.
 
y:Number — The y coordinate of the upper left corner of the ellipse's enclosing rectangle.
 
width:Number — The width of the ellipse's enclosing rectangle.
 
height:Number — The height of the ellipse's enclosing rectangle.
 
innerX:Number — The x coordinate of a point lying inside the ellipse.
 
innerY:Number — The y coordinate of a point lying inside the ellipse.
 
outerX:Number — The x coordinate of a point lying outside the ellipse.
 
outerY:Number — The y coordinate of a point lying outside the ellipse.
 
intersectionPoint:IPointSetter — The intersection point to set.

Returns
Booleantrue iff the inner point lies inside the ellipse and an intersection point has been found.
findLineIntersection()method 
public static function findLineIntersection(l1x1:Number, l1y1:Number, l1x2:Number, l1y2:Number, l2x1:Number, l2y1:Number, l2x2:Number, l2y2:Number):IPoint

Find the intersection point of two lines if one exists.

Parameters

l1x1:Number — The x coordinate of the first point of the first line.
 
l1y1:Number — The y coordinate of the first point of the first line.
 
l1x2:Number — The x coordinate of the second point of the first line.
 
l1y2:Number — The y coordinate of the second point of the first line.
 
l2x1:Number — The x coordinate of the first point of the second line.
 
l2y1:Number — The y coordinate of the first point of the second line.
 
l2x2:Number — The x coordinate of the second point of the second line.
 
l2y2:Number — The y coordinate of the second point of the second line.

Returns
IPoint — The intersection point of the two lines or null if none exists.
findLineSegmentIntersection()method 
public static function findLineSegmentIntersection(l1x1:Number, l1y1:Number, l1x2:Number, l1y2:Number, l2x1:Number, l2y1:Number, l2x2:Number, l2y2:Number):Number

Find the intersection of two line segments if one exists.

In order to obtain the intersection point do the following: var factor:Number = findLineIntersection(l1x1, l1y1, l1x2, l1y2, l2x1, l2y1, l2x2, l2y2); if ( factor < Infinity ){ var ix:Number = l2x1 + (l2x2 - l2x1) factor; var iy:Number = l2y1 + (l2y2 - l2y1) factor; }

Parameters

l1x1:Number — The x coordinate of the first point of the first line.
 
l1y1:Number — The y coordinate of the first point of the first line.
 
l1x2:Number — The x coordinate of the second point of the first line.
 
l1y2:Number — The y coordinate of the second point of the first line.
 
l2x1:Number — The x coordinate of the first point of the second line.
 
l2y1:Number — The y coordinate of the first point of the second line.
 
l2x2:Number — The x coordinate of the second point of the second line.
 
l2y2:Number — The y coordinate of the second point of the second line.

Returns
Number — The factor to determine the intersection point.
findRectangleLineIntersection()method 
public static function findRectangleLineIntersection(rect:IRectangle, innerX:Number, innerY:Number, outerX:Number, outerY:Number, intersectionPoint:IPointSetter):Boolean

Finds the intersection between a rectangle and a line.

Parameters

rect:IRectangle — The rectangle to find the intersection.
 
innerX:Number — The x coordinate of a point lying inside the rectangle.
 
innerY:Number — The y coordinate of a point lying inside the rectangle.
 
outerX:Number — The x coordinate of a point lying outside the rectangle.
 
outerY:Number — The y coordinate of a point lying outside the rectangle.
 
intersectionPoint:IPointSetter — The intersection point to set.

Returns
Booleantrue iff the inner point lies inside the rectangle, the outer point lies outside the rectangle and thus an intersection point has been found.
getCenter()method 
public static function getCenter(orientedRectangle:IOrientedRectangle):IPoint

Returns the current center of the oriented rectangle.

This returns a snapshot of the current center of the rectangle, it will not change over time.

Parameters

orientedRectangle:IOrientedRectangle — The rectangle to get the center from.

Returns
IPoint — An immutable instance that describes the current center of the rectangle.
getConstrainedLocation()method 
public static function getConstrainedLocation(location:IPoint, constraint:IRectangle):IPoint

Creates a constrained copy of the given location that lies within the given rectangle.

Parameters

location:IPoint — The location to constrain.
 
constraint:IRectangle — The constraint to apply to the given location.

Returns
IPoint — A constrained copy of the given location that lies within the given rectangle.
getRectangleCenter()method 
public static function getRectangleCenter(rect:IRectangle):IPoint

Returns the current center point of the rectangle.

This returns a snapshot of the current center of the rectangle, it will not change over time.

Parameters

rect:IRectangle — The rectangle to get the center from.

Returns
IPoint — An immutable instance that describes the current center of the rectangle.
grow()method 
public static function grow(rectangle:IMutableRectangle, width:Number):void

Grows a mutable rectangle given a stroke width.

An empty rectangle (with negative width or height) will stay empty.

Parameters

rectangle:IMutableRectangle — The rectangle to grow.
 
width:Number — The amount to grow the rectangle.

insetsUnion()method 
public static function insetsUnion(rect1:IRectangle, rect2:IRectangle, dest:IMutableRectangle):IMutableRectangle

Creates the union of two insets rectangles, placing the result in a third.

This implementation uses the greater of the values for each component to store in the result. Either of the first two parameters may be the same as the third. If the third parameter is null, this method will create an instance to hold the result. The result is placed into the third parameter (or the newly created instance) and that instance is returned.

Parameters

rect1:IRectangle — The first inset rectangle to create the union of.
 
rect2:IRectangle — The second inset rectangle to create the union of.
 
dest:IMutableRectangle — The inset rectangle to hold the result, or null.

Returns
IMutableRectangle — The inset union, which will be stored in dest, unless dest is null
lineContains()method 
public static function lineContains(x1:Number, y1:Number, x2:Number, y2:Number, testX:Number, testY:Number, epsilon:Number):Boolean

Determines whether a given line is hit by a point given an epsilon.

Parameters

x1:Number — The x coordinate of the first point of the line.
 
y1:Number — The y coordinate of the first point of the line.
 
x2:Number — The x coordinate of the second point of the line.
 
y2:Number — The y coordinate of the second point of the line.
 
testX:Number — The x coordinate of the point to test.
 
testY:Number — The y coordinate of the point to test.
 
epsilon:Number — A positive value allows for fuzzy hit testing. If the point lies outside the given object but it's distance is less than or equal to that value, it will be considered a hit.

Returns
Booleantrue if the line is hit by the point.
orientedRectangleBounds()method 
public static function orientedRectangleBounds(rect:IOrientedRectangle, scratch:IMutableRectangle):IRectangle

Determines the bounds of an oriented rectangle.

Bounding rectangles are parallel to the coordinate axes.

Parameters

rect:IOrientedRectangle — The rectangle to determine the bounds.
 
scratch:IMutableRectangle — The scratch variable to place the bounds into.

Returns
IRectangle — The bounds.
orientedRectangleContains()method 
public static function orientedRectangleContains(rect:IOrientedRectangle, x:Number, y:Number, epsilon:Number):Boolean

Determines whether the given oriented rectangle contains the provided point, using an epsilon value.

Parameters

rect:IOrientedRectangle — The rectangle.
 
x:Number — The x coordinate of the point to test.
 
y:Number — The y coordinate of the point to test.
 
epsilon:Number — A positive value allows for fuzzy hit testing. If the point lies outside the given object but it's distance is less than or equal to that value, it will be considered a hit.

Returns
Booleantrue if the point lies inside the rectangle.
pointHits()method 
public static function pointHits(x:Number, y:Number, testX:Number, testY:Number, hitTestRadius:Number):Boolean

Determines if two points lie close to each other given an epsilon.

Parameters

x:Number — The x coordinate of the first point.
 
y:Number — The y coordinate of the first point.
 
testX:Number — The x coordinate of the second point.
 
testY:Number — The y coordinate of the second point.
 
hitTestRadius:Number — The hit test epsilon.

Returns
Boolean — Whether the distance between the two points is smaller than hitTestRadius
pointLineDistance()method 
public static function pointLineDistance(x1:Number, y1:Number, x2:Number, y2:Number, px:Number, py:Number):Number

Determines the distance between a point and a line.

Parameters

x1:Number — The x coordinate of the first point of the line.
 
y1:Number — The y coordinate of the first point of the line.
 
x2:Number — The x coordinate of the second point of the line.
 
y2:Number — The y coordinate of the second point of the line.
 
px:Number — The x coordinate of the point to test.
 
py:Number — The x coordinate of the point to test.

Returns
Number — The distance between the point and the closest point on the line segment.
pointsAreEqual()method 
public static function pointsAreEqual(p1:IPoint, p2:IPoint):Boolean

Compares if the x and y coordinates of the given points are equal.

Parameters

p1:IPoint — The first point to compare.
 
p2:IPoint — The second point to compare.

Returns
Booleantrue if x and y are equal, false otherwise.
polyLineContains()method 
public static function polyLineContains(x:Number, y:Number, controlPoints:IControlPoints, epsilon:Number):Boolean

Determines whether a polygonal line is hit by a point given an epsilon.

Parameters

x:Number — The x coordinate of the point to test.
 
y:Number — The y coordinate of the point to test.
 
controlPoints:IControlPoints — The list of points that is treated as a polygon
 
epsilon:Number — A positive value allows for fuzzy hit testing. If the point lies outside the given object but it's distance is less than or equal to that value, it will be considered a hit.

Returns
Boolean — Whether the point hits the polygon.
polyLineIntersects()method 
public static function polyLineIntersects(rect:IRectangle, controlPoints:IControlPoints, epsilon:Number):Boolean

Determines whether a rectangle intersects a polygonal line.

Parameters

rect:IRectangle — The rectangle to test for intersection with the polygonal line.
 
controlPoints:IControlPoints — The list of points that is interpreted as a number of line segments.
 
epsilon:Number — A positive value allows for fuzzy hit testing. If the point lies outside the given object but its distance is less than or equal to that value, it will be considered a hit.

Returns
Boolean — Whether the point hits the polygon.
projectOnLine()method 
public static function projectOnLine(x1:Number, y1:Number, dx:Number, dy:Number, px:Number, py:Number):IPoint

Determines the closest point on a line to a given point.

Parameters

x1:Number — The x coordinate of the first point of the line.
 
y1:Number — The y coordinate of the first point of the line.
 
dx:Number — The x coordinate of the direction of the line.
 
dy:Number — The y coordinate of the direction of of the line.
 
px:Number — The x coordinate of the point to test.
 
py:Number — The y coordinate of the point to test.

Returns
IPoint — An immutable point that represents the closest point on the lines.
projectOnSegment()method 
public static function projectOnSegment(x1:Number, y1:Number, x2:Number, y2:Number, px:Number, py:Number):IPoint

Determines the closest point on a line segment to a given point.

Parameters

x1:Number — The x coordinate of the first point of the line.
 
y1:Number — The y coordinate of the first point of the line.
 
x2:Number — The x coordinate of the second point of the line.
 
y2:Number — The y coordinate of the second point of the line.
 
px:Number — The x coordinate of the point to test.
 
py:Number — The y coordinate of the point to test.

Returns
IPoint — the closest point.
rectangleContains()method 
public static function rectangleContains(x:Number, y:Number, w:Number, h:Number, px:Number, py:Number, epsilon:Number = 0):Boolean

Determines whether the given rectangle contains the provided point.

Parameters

x:Number — The x coordinate of the upper left corner of the rectangle.
 
y:Number — The y coordinate of the upper left corner of the rectangle.
 
w:Number — The width of the rectangle.
 
h:Number — The height of the rectangle.
 
px:Number — The x coordinate of the point to test.
 
py:Number — The y coordinate of the point to test.
 
epsilon:Number (default = 0)

Returns
Booleantrue if the point lies inside the rectangle.
rectangleIntersects()method 
public static function rectangleIntersects(rect1:IRectangle, rect2:IRectangle):Boolean

Determines whether two rectangles intersect.

Parameters

rect1:IRectangle — One rectangle.
 
rect2:IRectangle — The other rectangle.

Returns
Booleantrue if the two rectangles intersect.
rectangleIntersectsLine()method 
public static function rectangleIntersectsLine(boxX:Number, boxY:Number, boxWidth:Number, boxHeight:Number, x1:Number, y1:Number, x2:Number, y2:Number, epsilon:Number = 0):Boolean

Determines whether a rectangle intersects a line.

Parameters

boxX:Number — The x coordinate of the upper left corner of the rectangle.
 
boxY:Number — The y coordinate of the upper left corner of the rectangle.
 
boxWidth:Number — The width of the rectangle.
 
boxHeight:Number — The height of the rectangle.
 
x1:Number — The x coordinate of the first point of the line.
 
y1:Number — The y coordinate of the first point of the line.
 
x2:Number — The x coordinate of the second point of the line.
 
y2:Number — The y coordinate of the second point of the line.
 
epsilon:Number (default = 0) — A positive value allows for fuzzy hit testing. If the point lies outside the given object but it's distance is less than or equal to that value, it will be considered a hit.

Returns
Booleantrue if the line intersects the rectangle.
rectangleIntersectsOriented()method 
public static function rectangleIntersectsOriented(rectangle:IRectangle, orientedRectangle:IOrientedRectangle, epsilon:Number):Boolean

Determines whether a rectangle intersects an oriented rectangle, given an epsilon.

Parameters

rectangle:IRectangle — The rectangle to test.
 
orientedRectangle:IOrientedRectangle — The oriented rectangle to test.
 
epsilon:Number — A positive value allows for fuzzy hit testing. If the point lies outside the given object but it's distance is less than or equal to that value, it will be considered a hit.

Returns
Boolean — Whether the rectangles have a non-empty intersection.
rectanglesAreEqual()method 
public static function rectanglesAreEqual(rect1:IRectangle, rect2:IRectangle):Boolean

Compares if the x and y coordinates as well as the width and height values of the given rectangles are equal.

Parameters

rect1:IRectangle — The first rectangle to compare.
 
rect2:IRectangle — The second rectangle to compare.

Returns
Booleantrue if x, y, width and height are equal, false otherwise.
setCenter()method 
public static function setCenter(orientedRectangle:IMutableOrientedRectangle, cx:Number, cy:Number):IMutableOrientedRectangle

Sets the anchor of an IMutableOrientedRectangle so that the center of the rectangle coincides with the given coordinate pair.

Parameters

orientedRectangle:IMutableOrientedRectangle — The rectangle to set the anchor appropriately.
 
cx:Number — The x coordinate of the center.
 
cy:Number — The y coordinate of the center.

Returns
IMutableOrientedRectangle — The rectangle itself, to allow for chaining calls.
setRectangle()method 
public static function setRectangle(dst:IMutableRectangle, src:IRectangle):IMutableRectangle

Convenience method that reshapes the provided rectangle to have the same bounds as src.

Parameters

dst:IMutableRectangle — The rectangle to reshape.
 
src:IRectangle — The values to use.

Returns
IMutableRectangle — The reshaped instance itself.
squaredDistance()method 
public static function squaredDistance(p:IPoint, q:IPoint):Number

Calculates the square of the euclidean distance between two points.

Parameters

p:IPoint — The first point
 
q:IPoint — The second point

Returns
Number — The squared euclidean distance between the two points.
squaredDistance2()method 
public static function squaredDistance2(x1:Number, y1:Number, x2:Number, y2:Number):Number

Calculates the square of the euclidean distance between two points.

Parameters

x1:Number — The x coordinate of the first point.
 
y1:Number — The y coordinate of the first point.
 
x2:Number — The x coordinate of the second point.
 
y2:Number — The y coordinate of the second point.

Returns
Number — The squared euclidean distance between the two points.
transformBounds()method 
public static function transformBounds(transform:Matrix, bounds:IRectangle, scratch:IMutableRectangle):IMutableRectangle

Transforms a rectangle that is used as a bounding box using a matrix and places the result in another bounds object.

Parameters

transform:Matrix — The matrix to apply to the bounds.
 
bounds:IRectangle — The bounds to transform.
 
scratch:IMutableRectangle — The holder of the resulting bounds or null. If null, a new rectangle instance is created to hold the result.

Returns
IMutableRectangle — The result.
union()method 
public static function union(rect1:IRectangle, rect2:IRectangle, dest:IMutableRectangle):IMutableRectangle

Creates the union of two rectangles, placing the result in a third.

Either of the first two parameters may be the same as the third. If the third parameter is null, this method will create an instance to hold the result.

The result is placed into the third parameter (or the newly created instance) and that instance is returned.

This method treats rectangles with negative width or height as empty.

Parameters

rect1:IRectangle — The first rectangle to create the union of.
 
rect2:IRectangle — The second rectangle to create the union of.
 
dest:IMutableRectangle — The rectangle to hold the result, or null.

Returns
IMutableRectangle — The union, which will be stored in dest, unless dest is null