Math.distanceSq(x1,y1,x2,y2) +
Top  Previous  Next


SWiSH Player Support
SWF4 or later - Supported Internally

Syntax
Math.distanceSq(x1,y1,x2,y2)

Arguments
x1, y1, x1, y2: Numbers or expressions.

Returns
A number, the square of the distance between the two points (x1, y1) and (x2, y2).

Description
Calculates the square of the distance between the two points (x1, y1) and (x2, y2) using ((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)).

Sample
Math.distanceSq(1
,1,10,10); // returns 162
Math.distanceSq(3
,5,30,40); // returns 1954

Note: Requires Advanced Math Support. See here for more information

See Also
Math.distance()