Packagecom.degrafa.geometry.utilities
Classpublic class GeometryUtils

A helper utility class for various geometric calculations.



Public Methods
 MethodDefined by
  
barycenter(a:Number, b:Number, c:Number, t:Number):Number
[static] Calculates the barycenter of a quadratic bezier curve.
GeometryUtils
  
bezierBounds(x:Number, y:Number, cx:Number, cy:Number, x1:Number, y1:Number):Rectangle
[static] Return the tight bounding rectangle for a bezier curve.
GeometryUtils
  
cubicToQuadratic(p1:GraphicPoint, c1:GraphicPoint, c2:GraphicPoint, p2:GraphicPoint, k:Number, quadratics:Array):void
[static] CubicToQuadratic

Approximates a cubic bezier with as many quadratic bezier segments (n) as required to achieve a specified tolerance.

GeometryUtils
  
degressToRadius(angle:Number):Number
[static] Convert Degress to radius.
GeometryUtils
  
[static] LineIntersects Returns the point of intersection between two lines
GeometryUtils
  
[static] MidPoint Returns the midpoint Point of 2 Point structures
GeometryUtils
  
perimeter(x:Number, y:Number, cx:Number, cy:Number, x1:Number, y1:Number):Number
[static] Calculates the perimeter of a quadratic bezier curve
GeometryUtils
  
radiusToDegress(angle:Number):Number
[static] Convert radius to degrees.
GeometryUtils
  
rotatePoint(value:GraphicPoint, angle:Number):GraphicPoint
[static] Rotate a point by a degrees.
GeometryUtils
  
rotatePointOnCenterPoint(point:GraphicPoint, centerPoint:GraphicPoint, degrees:Number):GraphicPoint
[static] Rotate a point around a given center point by degrees.
GeometryUtils
  
roundTo(input:Number, digits:Number):Number
[static] Round a number a specified number of decimal places.
GeometryUtils
  
[static] SplitBezier Divides a cubic bezier curve into two cubic bezier curve definitions
GeometryUtils
Method detail
barycenter()method
public static function barycenter(a:Number, b:Number, c:Number, t:Number):Number

Calculates the barycenter of a quadratic bezier curve.

Parameters
a:Number — A number indicating the start axis coordinate.
 
b:Number — A number indicating the control axis coordinate.
 
c:Number — A number indicating the end axis coordinate.
 
t:Number — A number indicating the accuracy.

Returns
Number — The barycenter of the given points.
bezierBounds()method 
public static function bezierBounds(x:Number, y:Number, cx:Number, cy:Number, x1:Number, y1:Number):Rectangle

Return the tight bounding rectangle for a bezier curve.

Parameters
x:Number — A number indicating the starting x-axis coordinate.
 
y:Number — A number indicating the starting y-axis coordinate.
 
cx:Number — A number indicating the control x-axis coordinate.
 
cy:Number — A number indicating the control y-axis coordinate.
 
x1:Number — A number indicating the ending x-axis coordinate.
 
y1:Number — A number indicating the ending y-axis coordinate.

Returns
Rectangle — The bounds rectangle for the bezier curve.
cubicToQuadratic()method 
public static function cubicToQuadratic(p1:GraphicPoint, c1:GraphicPoint, c2:GraphicPoint, p2:GraphicPoint, k:Number, quadratics:Array):void

CubicToQuadratic

Approximates a cubic bezier with as many quadratic bezier segments (n) as required to achieve a specified tolerance.

Parameters
p1:GraphicPoint — (GraphicPoint) endpoint
 
c1:GraphicPoint — (GraphicPoint) 1st control point
 
c2:GraphicPoint — (GraphicPoint) 2nd control point
 
p2:GraphicPoint — (GraphicPoint) endpoint
 
k:Number — tolerance (low number = most accurate result)
 
quadratics:Array — (Array) will contain array of quadratic bezier curves, each element containing p1x, p1y, cx, cy, p2x, p2y (start point, control points, end point
degressToRadius()method 
public static function degressToRadius(angle:Number):Number

Convert Degress to radius.

Parameters
angle:Number — A angle value to convert.

Returns
Number — The resulting number converted to a radius.
lineIntersects()method 
public static function lineIntersects(p1:GraphicPoint, p2:GraphicPoint, p3:GraphicPoint, p4:GraphicPoint):GraphicPoint

LineIntersects Returns the point of intersection between two lines

Parameters
p1:GraphicPoint — p2 (GraphicPoint) line 1 point struct
 
p2:GraphicPoint — p4 (GraphicPoint) line 2 point struct
 
p3:GraphicPoint
 
p4:GraphicPoint

Returns
GraphicPoint — GraphicPoint (Point object of intersection)
midPoint()method 
public static function midPoint(p1:GraphicPoint, p2:GraphicPoint):GraphicPoint

MidPoint Returns the midpoint Point of 2 Point structures

Parameters
p1:GraphicPoint — GraphicPoint Struc 1
 
p2:GraphicPoint — GraphicPoint Struc 2

Returns
GraphicPoint — GraphicPoint (the midpoint of the 2 points)
perimeter()method 
public static function perimeter(x:Number, y:Number, cx:Number, cy:Number, x1:Number, y1:Number):Number

Calculates the perimeter of a quadratic bezier curve

Parameters
x:Number — A number indicating the starting x-axis coordinate.
 
y:Number — A number indicating the starting y-axis coordinate.
 
cx:Number — A number indicating the control x-axis coordinate.
 
cy:Number — A number indicating the control y-axis coordinate.
 
x1:Number — A number indicating the ending x-axis coordinate.
 
y1:Number — A number indicating the ending y-axis coordinate.

Returns
Number — The perimeter distance for the bezier curve.
radiusToDegress()method 
public static function radiusToDegress(angle:Number):Number

Convert radius to degrees.

Parameters
angle:Number — A angle radius to convert.

Returns
Number — The resulting number converted to degress.
rotatePoint()method 
public static function rotatePoint(value:GraphicPoint, angle:Number):GraphicPoint

Rotate a point by a degrees.

Parameters
value:GraphicPoint — The point to rotate.
 
angle:Number — A radius to rotate.

Returns
GraphicPoint — The transformed GraphicPoint point object.
rotatePointOnCenterPoint()method 
public static function rotatePointOnCenterPoint(point:GraphicPoint, centerPoint:GraphicPoint, degrees:Number):GraphicPoint

Rotate a point around a given center point by degrees.

Parameters
point:GraphicPoint — The point to rotate.
 
centerPoint:GraphicPoint — the center point that point should be roatated around.
 
degrees:Number — A radius to rotate.

Returns
GraphicPoint — The transformed GraphicPoint point object.
roundTo()method 
public static function roundTo(input:Number, digits:Number):Number

Round a number a specified number of decimal places.

Parameters
input:Number — The number to round.
 
digits:Number — The number of deciaml points to round to.

Returns
Number — The resulting rounded number.
splitBezier()method 
public static function splitBezier(p1:GraphicPoint, c1:GraphicPoint, c2:GraphicPoint, p2:GraphicPoint):Object

SplitBezier Divides a cubic bezier curve into two cubic bezier curve definitions

Parameters
p1:GraphicPoint — (GraphicPoint) endpoint 1
 
c1:GraphicPoint — (GraphicPoint) control point 1
 
c2:GraphicPoint — (GraphicPoint)control point 2
 
p2:GraphicPoint — (GraphicPoint) endpoint 2

Returns
Object — Object (object with two cubic bezier definitions, b0 and b1)