Package flare.util Class public final class Geometry

Utility methods for computational geometry.

Public Methods
MethodDefined by

bspline(u:Number, a:Array, b:Array, s:Point):Point
[static] Computes a point along a B-spline.
Geometry

bsplineCoeff(p:Array, a:Array, b:Array):void
[static] Computes the co-efficients for a B-spline.
Geometry

convexHull(p:Array, len:uint):Array
[static] Computes the convex hull for a set of points.
Geometry

cubic(u:Number, a:Point, c1:Point, c2:Point, c3:Point, p:Point):Point
[static] Computes a point along a cubic Bezier curve.
Geometry

cubicCoeff(a:Point, b:Point, c:Point, d:Point, c1:Point, c2:Point, c3:Point):void
[static] Computes the co-efficients for a cubic Bezier curve.
Geometry

intersectLineRect(a1x:Number, a1y:Number, a2x:Number, a2y:Number, r:Rectangle, p0:Point, p1:Point):int
[static] Compute the intersection of a line and a rectangle.
Geometry

intersectLines(a1x:Number, a1y:Number, a2x:Number, a2y:Number, b1x:Number, b1y:Number, b2x:Number, b2y:Number, intersect:Point):int
[static] Compute the intersection of two line segments.
Geometry
Public Constants
ConstantDefined by
COINCIDENT : int = -1
[static] Indicates intersection between shapes
Geometry
NO_INTERSECTION : int = 0
[static] Indicates no intersection between shapes
Geometry
PARALLEL : int = -2
[static] Indicates two lines are parallel
Geometry
Method detail
 bspline () method
`public static function bspline(u:Number, a:Array, b:Array, s:Point):Point`

Computes a point along a B-spline.

Parameters
 `u:Number` — the interpolation fraction along the curve (between 0 and 1) `a:Array` — an array of x-components of the B-spline co-efficients `b:Array` — an array of y-components of the B-spline co-efficients `s:Point` — point in which to store the calculated point on the curve

Returns
 `Point`
 bsplineCoeff () method
`public static function bsplineCoeff(p:Array, a:Array, b:Array):void`

Computes the co-efficients for a B-spline.

Parameters
 `p:Array` — the control points of the spline as an array of x,y values `a:Array` — an array for storing the x-components of co-efficients `b:Array` — an array for storing the y-components of co-efficients
 convexHull () method
`public static function convexHull(p:Array, len:uint):Array`

Computes the convex hull for a set of points.

Parameters
 `p:Array` — the input points, as a flat array of x,y values `len:uint` — the number of points to include in the hull

Returns
 `Array` — the convex hull, as a flat array of x,y values
 cubic () method
`public static function cubic(u:Number, a:Point, c1:Point, c2:Point, c3:Point, p:Point):Point`

Computes a point along a cubic Bezier curve.

Parameters
 `u:Number` — the interpolation fraction along the curve (between 0 and 1) `a:Point` — the starting point of the curve `c1:Point` — the zero-order Bezier co-efficients `c2:Point` — the first-order Bezier co-efficients `c3:Point` — the second-order Bezier co-efficients `p:Point` — point in which to store the calculated point on the curve

Returns
 `Point`
 cubicCoeff () method
`public static function cubicCoeff(a:Point, b:Point, c:Point, d:Point, c1:Point, c2:Point, c3:Point):void`

Computes the co-efficients for a cubic Bezier curve.

Parameters
 `a:Point` — the starting point of the curve `b:Point` — the first control point of the curve `c:Point` — the second control point of the curve `d:Point` — the ending point of the curve `c1:Point` — point in which to store the zero-order co-efficients `c2:Point` — point in which to store the first-order co-efficients `c3:Point` — point in which to store the second-order co-efficients
 intersectLineRect () method
`public static function intersectLineRect(a1x:Number, a1y:Number, a2x:Number, a2y:Number, r:Rectangle, p0:Point, p1:Point):int`

Compute the intersection of a line and a rectangle.

Parameters
 `a1x:Number` — the first endpoint of the line `a1y:Number` — the second endpoint of the line `a2x:Number` — the rectangle `a2y:Number` — a length 2 or greater array of points in which to store the results `r:Rectangle` `p0:Point` `p1:Point`

Returns
 `int` — the intersection code. This is either the number of intersections or one of {
 intersectLines () method
`public static function intersectLines(a1x:Number, a1y:Number, a2x:Number, a2y:Number, b1x:Number, b1y:Number, b2x:Number, b2y:Number, intersect:Point):int`

Compute the intersection of two line segments.

Parameters
 `a1x:Number` — the x-coordinate of the 1st endpoint of the 1st line `a1y:Number` — the y-coordinate of the 1st endpoint of the 1st line `a2x:Number` — the x-coordinate of the 2nd endpoint of the 1st line `a2y:Number` — the y-coordinate of the 2nd endpoint of the 1st line `b1x:Number` — the x-coordinate of the 1st endpoint of the 2nd line `b1y:Number` — the y-coordinate of the 1st endpoint of the 2nd line `b2x:Number` — the x-coordinate of the 2nd endpoint of the 2nd line `b2y:Number` — the y-coordinate of the 2nd endpoint of the 2nd line `intersect:Point` — a Point in which to store the intersection point

Returns
 `int` — the intersection code. This is either the number of intersections or one of {
Constant detail
 COINCIDENT constant
`public static const COINCIDENT:int = -1`

Indicates intersection between shapes

 NO_INTERSECTION constant
`public static const NO_INTERSECTION:int = 0`

Indicates no intersection between shapes

 PARALLEL constant
`public static const PARALLEL:int = -2`

Indicates two lines are parallel