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(p1x:Number, p1y:Number, c1x:Number, c1y:Number, c2x:Number, c2y:Number, p2x:Number, p2y:Number, k:Number, commandStack:CommandStack):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
  
lineIntersects(p1:Point, p2:Point, p3:Point, p4:Point):Point
[static] LineIntersects Returns the point of intersection between two lines
GeometryUtils
  
midPoint(p1:Point, p2:Point):Point
[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
  
pointOnQuadraticCurve(t:Number, x:Number, y:Number, cx:Number, cy:Number, x1:Number, y1:Number):Object
[static] Returns a point on a quadratic bezier curve.
GeometryUtils
  
radiusToDegress(angle:Number):Number
[static] Convert radius to degrees.
GeometryUtils
  
rotatePoint(value:Point, angle:Number):Point
[static] Rotate a point by a degrees.
GeometryUtils
  
rotatePointOnCenterPoint(point:Point, centerPoint:Point, degrees:Number):Point
[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
  
splitBezier(p1:Point, c1:Point, c2:Point, p2:Point):Object
[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(p1x:Number, p1y:Number, c1x:Number, c1y:Number, c2x:Number, c2y:Number, p2x:Number, p2y:Number, k:Number, commandStack:CommandStack):void

CubicToQuadratic

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

Parameters
p1x:Number — first endpoint x coord
 
p1y:Number — first endpoint y coord
 
c1x:Number — 1st control point x coord
 
c1y:Number — 1st control point y coord
 
c2x:Number — 2nd control point x coord
 
c2y:Number — 2nd control point y coord
 
p2x:Number — last endpoint x coord
 
p2y:Number — last endpoint y coord
 
k:Number — tolerance (low number = most accurate result)
 
commandStack:CommandStack — will contain the path of quadratic bezier curves that closely approximates the original cubic bezier curve
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:Point, p2:Point, p3:Point, p4:Point):Point

LineIntersects Returns the point of intersection between two lines

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

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

MidPoint Returns the midpoint Point of 2 Point structures

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

Returns
Point — Point (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.
pointOnQuadraticCurve()method 
public static function pointOnQuadraticCurve(t:Number, x:Number, y:Number, cx:Number, cy:Number, x1:Number, y1:Number):Object

Returns a point on a quadratic bezier curve.

Parameters
t:Number
 
x:Number
 
y:Number
 
cx:Number
 
cy:Number
 
x1:Number
 
y1:Number

Returns
Object
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:Point, angle:Number):Point

Rotate a point by a degrees.

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

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

Rotate a point around a given center point by degrees.

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

Returns
Point — The transformed Point 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:Point, c1:Point, c2:Point, p2:Point):Object

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

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

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