MathUtils

Math utility methods used in SVG import.

Summary
MathUtilsMath utility methods used in SVG import.
Functions
ratioToTim Groleau’s Math method ratioTo.
intersect2LinesRobert Penner’s Math intersect2Lines.
midLineRobert Penner’s Math method midLine.
bezierSplitRobert Penner’s Math method bezierSplit.

Functions

ratioTo

public static function ratioTo(p1: Point,
p2: Point,
ratio: Number):Point

Tim Groleau’s Math method ratioTo.

Return the point on segment [p1,p2] which is ratio times the total distance between p1 and p2 away from p1.

Parameters

p1first Point
p2second Point
ratioa real number

intersect2Lines

public static function intersect2Lines(p1: Point,
p2: Point,
p3: Point,
p4: Point):Point

Robert Penner’s Math intersect2Lines.

Returns the point of intersection between two lines.

Parameters

p1, p2two points on first line
p3, p4two points on second line

Returns

Point of intersection

midLine

public static function midLine(
   a: Point,
   b: Point
):Point // Math.midLine = function (a, b)

Robert Penner’s Math method midLine.

Returns the midpoint of a line segment.

Parameters

a, bendpoints of line segment (each with .x and .y properties)

bezierSplit

public static function bezierSplit(
   p0: Point,
   p1: Point,
   p2: Point,
   p3: Point
):Object // Math.bezierSplit = function (p0, p1, p2, p3)

Robert Penner’s Math method bezierSplit.

Divides a cubic bezier curve into two halves (each also cubic beziers).

Parameters

p0first anchor (Point object)
p1first control (Point object)
p2second control (Point object)
p3second anchor (Point object)

Returns

An object with b0 - 1st cubic bezier (with properties a,b,c,d corresp to p0,p1,p2,p3) b1 - 2nd cubic bezier (same)

public static function ratioTo(p1: Point,
p2: Point,
ratio: Number):Point
Tim Groleau’s Math method ratioTo.
public static function intersect2Lines(p1: Point,
p2: Point,
p3: Point,
p4: Point):Point
Robert Penner’s Math intersect2Lines.
public static function midLine(
   a: Point,
   b: Point
):Point // Math.midLine = function (a, b)
Robert Penner’s Math method midLine.
public static function bezierSplit(
   p0: Point,
   p1: Point,
   p2: Point,
   p3: Point
):Object // Math.bezierSplit = function (p0, p1, p2, p3)
Robert Penner’s Math method bezierSplit.
Close