Packagenet.dmclaren.utils
Classpublic class GeomUtils

Utility class for working with flash.geom package.



Public Methods
 MethodDefined by
  
getAngleBetweenPoints(point0:Point, point1:Point):Number
[static] Gives the shortest angle between two given Points.
GeomUtils
  
getDotProduct(point0:Point, point1:Point):Number
[static] Gives the dot product of the two given Points.
GeomUtils
  
getLineCircleIntersections(x1:Number, y1:Number, x2:Number, y2:Number, r:Number):Array
[static] Fetches any intersection points between the given line and circle.
GeomUtils
  
getPointAngle(point:Point, flipYAxis:Boolean = false):Number
[static] Gives the angle of the given Point.
GeomUtils
  
getPointProjection(vector:Point, ontoVector:Point):Point
[static] Projects one Point vector onto a unit vector Point.
GeomUtils
  
rotatePoint(point:Point, angle:Number):Point
[static] Rotates the given Point by the given angle and returns it.
GeomUtils
  
scalePoint(point:Point, scale:Number):Point
[static] Scales the given Point by the given factor and returns it.
GeomUtils
Method detail
getAngleBetweenPoints()method
public static function getAngleBetweenPoints(point0:Point, point1:Point):Number

Gives the shortest angle between two given Points.

Parameters
point0:Point
 
point1:Point

Returns
Number
getDotProduct()method 
public static function getDotProduct(point0:Point, point1:Point):Number

Gives the dot product of the two given Points.

Parameters
point0:Point
 
point1:Point

Returns
Number
getLineCircleIntersections()method 
public static function getLineCircleIntersections(x1:Number, y1:Number, x2:Number, y2:Number, r:Number):Array

Fetches any intersection points between the given line and circle. The line is defined by two points and the circle is centered at (0, 0). The return value may be an empty array (no intersections), an array with one Point (tangent), or an array with two Points (two intersections).

If there are two intersections, the first will add the discriminant root and the second will subtract it. This ordering is gauranteed.

Thanks to MathWorld.

Parameters
x1:Number — The X-coordinate of the first point on the line.
 
y1:Number — The Y-coordinate of the first point on the line.
 
x2:Number — The X-coordinate of the second point on the line.
 
y2:Number — The Y-coordinate of the second point on the line.
 
r:Number — The radius of the circle.

Returns
Array — An array containing, zero, one, or two intersections as Points.

See also

getPointAngle()method 
public static function getPointAngle(point:Point, flipYAxis:Boolean = false):Number

Gives the angle of the given Point.

Parameters
point:Point
 
flipYAxis:Boolean (default = false)

Returns
Number
getPointProjection()method 
public static function getPointProjection(vector:Point, ontoVector:Point):Point

Projects one Point vector onto a unit vector Point.

Parameters
vector:Point
 
ontoVector:Point

Returns
Point
rotatePoint()method 
public static function rotatePoint(point:Point, angle:Number):Point

Rotates the given Point by the given angle and returns it. Note that this method modifies the given Point and does not create a new instance. If you don't want to modify the given point, use Point.clone().

Parameters
point:Point
 
angle:Number

Returns
Point
scalePoint()method 
public static function scalePoint(point:Point, scale:Number):Point

Scales the given Point by the given factor and returns it. Note that this method modifies the given Point and does not create a new instance. If you don't want to modify the given point, use Point.clone().

Parameters
point:Point
 
scale:Number

Returns
Point