Module: algeobra

Source:

Classes

ClosestPointRegistry
Complex
CreateInfo
DefAngle
DefArc
DefArcLength
DefArray
DefBezier
DefBezierSpline
DefBoolean
DefChainApply
DefClosestPoint
DefConditional
DefCoordSystem
DefCoordSystemOps
DefCurveNormal
DefCurveParam
DefCurvePoint
DefCurveTangent
DefEllipse
DefEllipseFocus
DefFunc
DefInterpolate
DefIntersection
DefLength
DefLengthSquared
DefLine
DefLineStrip
DefMap
DefMidPoint
DefNormalVector
DefNumber
DefParallelLine
DefPerpendicularLine
DefPoint
DefPolarCoord
DefPolarVector
DefPolygon
DefReflection
DefRefraction
DefSelect
DefTangentLines
DefTangentPoints
DefText
DefVector
DefVectorOps
DefinitionRemovedEvent
DefinitionUpdateEvent
EventType
GeometryScene
IntersectionRegistry
PropertyUpdateEvent
Vec2

Members

(inner, constant) EMPTY

Specifies an optional dependency These allows to leave out some values and for example use default values instead
Source:

(inner, constant) EMPTY_INFO

Fixed value to specify explicitely, that a definition does not need any additional information
Source:

(inner, constant) INVALID

Specifies an INVALID value This could be something like the intersection of objects that do not intersect
Source:

(inner, constant) TYPE_ANGLE

Type specifier for an angle type
Source:

(inner, constant) TYPE_ARC

Type specifier for an arc type
Source:

(inner, constant) TYPE_BEZIER

Type specifier for a Bezier curve type
Source:

(inner, constant) TYPE_BEZIER_SPLINE

Type specifier for a Bezier spline type
Source:

(inner, constant) TYPE_BOOLEAN

Type specifier for a boolean type
Source:

(inner, constant) TYPE_COLLECTION

Type specifier for a collection type
Source:

(inner, constant) TYPE_COORD_SYSTEM

/** Type specifier for a coordinate system type
Source:

(inner, constant) TYPE_ELLIPSE

Type specifier for a ellipse type
Source:

(inner, constant) TYPE_LINE

Type specifier for a line type
Source:

(inner, constant) TYPE_LINE_STRIP

Type specifier for a line strip type
Source:

(inner, constant) TYPE_NUMBER

Type specifier for a number type
Source:

(inner, constant) TYPE_POINT

Type specifier for a point type
Source:

(inner, constant) TYPE_POLAR

Type specifier for a polar coordinate type
Source:

(inner, constant) TYPE_POLYGON

Type specifier for a polygon type
Source:

(inner, constant) TYPE_TEXT

Type specifier for a text type
Source:

(inner, constant) TYPE_VECTOR

Type specifier for a vector type
Source:

Methods

(inner) assertExistsAndNotOptional(…dependencies)

Checks whether all given dependencies exist and are not EMPTY. If any dependency does not satisfy this condition, an exception is thrown
Parameters:
Name Type Attributes Description
dependencies any <repeatable>
Dependencies to check
Source:

(inner) assertType(obj, …types)

Checks whether an object is one of the types given
Parameters:
Name Type Attributes Description
obj Object The dependency to check
types String <repeatable>
A number of types that the object should be one of
Source:
Returns:
True, if the object is of the give type. Throws an error otherwise

(inner) calcAngle(x, y)

Computes the angle of a vector
Parameters:
Name Type Description
x Number The x coordinate
y Number The y coordinate
Source:
Returns:
The angle that the vector points to in [0,2pi]

(inner) calcBezierParameterOfPoint(p, points, eps) → {Array.<Number>}

Calculates the bezier parameter(s) of a point on a Bezier curve. This will compute the exact solutions (modulo numerical issues) and so is only defined for curves up to degree 4
Parameters:
Name Type Default Description
p Object The point to find the parameter for
points Array.<{x:Number, y:Number}> The control points
eps Number 1e-10 [1E-10] The epsilon value to use in comparisons
Source:
Returns:
The parameters that result in the given points, might be empty or contain multiple possible solutions
Type
Array.<Number>

(inner) calcBezierPointsDerivative(points) → {Array.<{x:Number, y:Number}>}

Calculates the Bezier curve that is the derivative of the given one
Parameters:
Name Type Description
points Array.<{x:Number, y:Number}> The control points
Source:
Returns:
The derivative curve
Type
Array.<{x:Number, y:Number}>

(inner) calcCirclePointTangentPoints(p, c, r, options) → {Array.<{x:Number, y:Number}>}

Computes the points on an arc going through a given point, if they exist.
Parameters:
Name Type Description
p Object The point
c Object The arc's center
r Number The arc's radius
options Object
Properties
Name Type Description
angleMin Number The minimum first arc angle
angleMax Number The maximum first arc angle
eps Number The epsilon value used for comparisons
Source:
Returns:
The tangent points
Type
Array.<{x:Number, y:Number}>

(inner) calcConvexHull(points) → {Array.<{x:Number, y:Number}>}

Computes the convex hull of the given points
Parameters:
Name Type Description
points Array.<{x:Number, y:Number}> The input points
Source:
Returns:
The vertices of the convex hull in order
Type
Array.<{x:Number, y:Number}>

(inner) calcInnerTangentPoints(arc0, arc0, options) → {Array.<{x:Number, y:Number}>}

Computes the points on two arc's inner tangents, if they exist.
Parameters:
Name Type Description
arc0 Object The first arc
arc0 Object The second arc
options Object
Properties
Name Type Description
eps Number The epsilon value used for comparisons
Source:
Returns:
The tangent points. They come in pairs of point on first arc and point on second arc
Type
Array.<{x:Number, y:Number}>

(inner) calcLineImplicit(a0, a1) → {Array.<Number>}

Create an implicit representation ax + by + c = 0
Parameters:
Name Type Description
a0 Object The first line point
a1 Object The second line point
Source:
Returns:
[a,b,c]
Type
Array.<Number>

(inner) calcOuterTangentPoints(arc0, arc0, options) → {Array.<{x:Number, y:Number}>}

Computes the points on two arc's outer tangents, if they exist.
Parameters:
Name Type Description
arc0 Object The first arc
arc0 Object The second arc
options Object
Properties
Name Type Description
eps Number The epsilon value used for comparisons
Source:
Returns:
The tangent points. They come in pairs of point on first arc and point on second arc
Type
Array.<{x:Number, y:Number}>

(inner) calcParamOnLine(a0, a1, p) → {Number}

For a line: a0 + t(a1 - a0), compute t, such that a0 + t(a1 -a1) = p
Parameters:
Name Type Description
a0 Object The first line point
a1 Object The second line point
p Object The point
Source:
Returns:
t
Type
Number

(inner) clipPolygonAtPlane(points, plane) → {Array.<{x:Number, y:Number}>}

Clip a polygon at a plane. The plane normal defines inside and outside. Points of the polygon that are outside are clipped. A plane can be created by the @see computePlane function, where you can see how it is defined.
Parameters:
Name Type Description
points Array.<{x:Number, y:Number}> The polygon points
plane Object The plane to clip at.
Source:
Returns:
The clipped polygon
Type
Array.<{x:Number, y:Number}>

(inner) clipPolygonAtPolygon(points, clipPoints) → {Array.<{x:Number, y:Number}>}

Clips a polygon against another. The clip polygon must be convex, while the polygon to be clipped may be concave. The clip polygon should be defined counter-clockwise.
Parameters:
Name Type Description
points Array.<{x:Number, y:Number}>
clipPoints Array.<{x:Number, y:Number}>
Source:
Returns:
The clipped polygon
Type
Array.<{x:Number, y:Number}>

(inner) closestPointArc(p, c, r, options) → {Object}

Computes the closest point on an arc
Parameters:
Name Type Description
p Object The input point
c Object The arc center
r Number The arc radius
options Object
Properties
Name Type Description
minA Number The minimum parameter of the line. For a segment, that is 0
maxA Number The maximum parameter of the line. For a segment, that is 1
angleMin Number The minimum arc angle
angleMax Number The maximum arc angle
eps Number The epsilon value used for comparisons
Source:
Returns:
The closest point
Type
Object

(inner) closestPointBezier(p, points, options) → {Object}

Computes the closest point on a Bezier curves. For such a point to be exactly computable, the degree of the curve must not exceed 2
Parameters:
Name Type Description
p Object The input point
points Array.<{x:Number, y:Number}> The Bezier control points
options Object
Properties
Name Type Description
eps Number The epsilon value used for comparisons
Source:
Returns:
The closest point. If multiple such points exist, one is chosen
Type
Object

(inner) closestPointLine(p, a0, a1, options) → {Object}

Computes the closest point on a line
Parameters:
Name Type Description
p Object The input point
a0 Object The first point of the first line
a1 Object The second point of the first line
options Object
Properties
Name Type Description
minA Number The minimum parameter of the first line. For a segment, that is 0
maxA Number The maximum parameter of the first line. For a segment, that is 1
eps Number The epsilon value used for comparisons
Source:
Returns:
The closest point on the given line
Type
Object

(inner) computePlane(p, n) → {Object}

Computes the normal form of a plane. For a point p, you can compute whether it lies on the plane as: p.x * plane.x + p.y * plane.y + plane.d = 0
Parameters:
Name Type Description
p Object A point on the plane
n Object The plane normal
Source:
Returns:
The plane
Type
Object

(inner) convertCubicBezierToParamBase(p0, p1, p2, p3) → {Array.<{x:Number, y:Number}>}

Converts a cubic Bezier curve t^3*p3 + t^2*p2*(3 - 3*t) + 3*t*p1*(1 - t)^2 + p0*(1 - t)^3 to the form q0 + q1*t + q2*t^2 + q3*t^3
Parameters:
Name Type Description
p0 Object The first point
p1 Object The second point
p2 Object The third point
p3 Object The fourth point
Source:
Returns:
The array [q0,q1,q2,q2]
Type
Array.<{x:Number, y:Number}>

(inner) convertPointFromLocalEllipse(points, center, rotation, rx, ry, isVector) → {Array.<{x:Number, y:Number}>}

Transforms points from the coordinate system in which the specified ellipse is a unit circle to world
Parameters:
Name Type Default Description
points Array.<{x:Number, y:Number}> The input points
center Object The ellipse center
rotation Number The ellipse rotation
rx Number The eccentricity in x direction
ry Number The eccentricity in y direction
isVector Boolean false Whether the given points are vectors. If so, they are not translated
Source:
Returns:
The transformed points
Type
Array.<{x:Number, y:Number}>

(inner) convertPointToLocalEllipse(points, center, rotation, rx, ry, isVector) → {Array.<{x:Number, y:Number}>}

Transforms points into the coordinate system in which the specified ellipse is a unit circle
Parameters:
Name Type Default Description
points Array.<{x:Number, y:Number}> The input points
center Object The ellipse center
rotation Number The ellipse rotation
rx Number The eccentricity in x direction
ry Number The eccentricity in y direction
isVector Boolean false Whether the given points are vectors. If so, they are not translated
Source:
Returns:
The transformed points
Type
Array.<{x:Number, y:Number}>

(inner) convertQuadraticBezierToParamBase(p0, p1, p2) → {Array.<{x:Number, y:Number}>}

Converts a quadratic Bezier curve (1-t)^2 p0 + 2(1-t)t p1 + t^2 p1 to the form q0 + t q1 + t^2 q2
Parameters:
Name Type Description
p0 Object The first point
p1 Object The second point
p2 Object The third point
Source:
Returns:
The array [q0,q1,q2]
Type
Array.<{x:Number, y:Number}>

(inner) convertQuarticBezierToParamBase(p0, p1, p2, p3, p4) → {Array.<{x:Number, y:Number}>}

Converts a quartic Bezier curve to the form q0 + q1*t + q2*t^2 + q3*t^3 + q4*t^4
Parameters:
Name Type Description
p0 Object The first point
p1 Object The second point
p2 Object The third point
p3 Object The fourth point
p4 Object The fifth point
Source:
Returns:
The array [q0,q1,q2,q3,q4]
Type
Array.<{x:Number, y:Number}>

(inner) createFromTemplate(base, properties) → {Object}

Creates a new object from a base with another object being merged into it. Properties specified in properties overwrite the base
Parameters:
Name Type Description
base Object
properties Object
Source:
Returns:
Type
Object

(inner) deCasteljau(points, t) → {Object}

Computes a point on a Bezier curve using the de Casteljau algorithm
Parameters:
Name Type Description
points Object The control points
t Number The curve parameter
Source:
Returns:
The point on the curve
Type
Object

(inner) deg2rad(deg) → {Number}

Converts an angle in degree to one in radians
Parameters:
Name Type Description
deg Number The angle in degrees
Source:
Returns:
The angle in radians
Type
Number

(inner) getBezierSplineSegment(points, degree, i) → {Array.<{x:Number, y:Number}>}

Computes the segment i of a Bezier spline where each consecutive segment uses the last point of the previous one
Parameters:
Name Type Description
points Array.<{x:Number, y:Number}> The control points
degree Number The Bezier degree
i Number The index of the segment
Source:
Returns:
The segments
Type
Array.<{x:Number, y:Number}>

(inner) intersectArcArc(ca, r0, cb, r1, options) → {Array.<{x:Number, y:Number}>}

Computes the intersections of two arcs.
Parameters:
Name Type Description
ca Object The first arc's center
r0 Number The first arc's radius
cb Object The second arc's center
r1 Number The second arc's radius
options Object
Properties
Name Type Description
angleMinA Number The minimum first arc angle
angleMaxA Number The maximum first arc angle
angleMinB Number The minimum second arc angle
angleMaxB Number The maximum second arc angle
eps Number The epsilon value used for comparisons
Source:
Returns:
The intersections
Type
Array.<{x:Number, y:Number}>

(inner) intersectArcBezier(center, r, points, options) → {Array.<{x:Number, y:Number}>}

Computes the intersections of an arc and a Bezier curves. For such an intersection to be exactly computable, the degree of the curve must not exceed 2
Parameters:
Name Type Description
center Object The arc center
r Number The arc radius
points Array.<{x:Number, y:Number}> The Bezier control points
options Object
Properties
Name Type Description
angleMin Number The minimum arc angle
angleMax Number The maximum arc angle
eps Number The epsilon value used for comparisons
Source:
Returns:
The intersections
Type
Array.<{x:Number, y:Number}>

(inner) intersectBezierBezier(points0, points1, options) → {Array.<{x:Number, y:Number}>}

Computes the intersections of two Bezier curves. For such an intersection to be exactly computable, the product of the degrees of both curves must not be greater than 4
Parameters:
Name Type Description
points0 Array.<{x:Number, y:Number}> The first control points
points1 Array.<{x:Number, y:Number}> The second control points
options Object
Properties
Name Type Description
eps Number The epsilon value used for comparisons
Source:
Returns:
The intersections
Type
Array.<{x:Number, y:Number}>

(inner) intersectEllipseEllipse(ellipse0, ellipse1, options) → {Array.<{x:Number, y:Number}>}

Computes the intersections of two ellipses.
Parameters:
Name Type Description
ellipse0 Object The first ellipse
ellipse1 Object The second ellipse
options Object
Properties
Name Type Description
eps Number The epsilon value used for comparisons
Source:
Returns:
The intersections
Type
Array.<{x:Number, y:Number}>

(inner) intersectLineArc(a0, a1, center, r, options) → {Array.<{x:Number, y:Number}>}

Computes the intersections of a line and an arc.
Parameters:
Name Type Description
a0 Object The first line point
a1 Object The second line point
center Object The arc center
r Number The arc radius
options Object
Properties
Name Type Description
minA Number The minimum parameter of the line. For a segment, that is 0
maxA Number The maximum parameter of the line. For a segment, that is 1
angleMin Number The minimum arc angle
angleMax Number The maximum arc angle
eps Number The epsilon value used for comparisons
Source:
Returns:
The intersections
Type
Array.<{x:Number, y:Number}>

(inner) intersectLineBezier(a0, a1, points, options) → {Array.<{x:Number, y:Number}>}

Computes the intersections of a line and a Bezier curves. For such an intersection to be exactly computable, the degree of the curve must not exceed 4
Parameters:
Name Type Description
a0 Object The first line point
a1 Object The second line point
points Array.<{x:Number, y:Number}> The Bezier control points
options Object
Properties
Name Type Description
minA Number The minimum parameter of the line. For a segment, that is 0
maxA Number The maximum parameter of the line. For a segment, that is 1
eps Number The epsilon value used for comparisons
Source:
Returns:
The intersections
Type
Array.<{x:Number, y:Number}>

(inner) intersectLines(a0, a1, b0, b1, options) → {Object|null}

Intersects two lines
Parameters:
Name Type Description
a0 Object The first point of the first line
a1 Object The second point of the first line
b0 Object The first point of the second line
b1 Object The second point of the second line
options Object
Properties
Name Type Description
minA Number The minimum parameter of the first line. For a segment, that is 0
maxA Number The maximum parameter of the first line. For a segment, that is 1
minB Number The minimum parameter of the second line. For a segment, that is 0
maxB Number The maximum parameter of the second line. For a segment, that is 1
eps Number The epsilon value used for comparisons
Source:
Returns:
The intersection with respective parameters or null, if no intersection exists
Type
Object | null

(inner) intersectQuadraticBezier(points0, points1, options) → {Array.<{x:Number, y:Number}>}

Computes the four possible intersections of two quadratic Bezier curves
Parameters:
Name Type Description
points0 Array.<{x:Number, y:Number}> The first control points
points1 Array.<{x:Number, y:Number}> The second control points
options Object
Properties
Name Type Description
eps Number The epsilon value used for comparisons
Source:
Returns:
The intersections
Type
Array.<{x:Number, y:Number}>

(inner) intersectorApplyToLineSegments(inter, points, options) → {Array.<{x:Number, y:Number}>}

Applies a line intersection function to each segment in a Line strip
Parameters:
Name Type Description
inter function A function computing intersections with a line segment
points Array.<{x:Number, y:Number}>
options Object
Properties
Name Type Description
eps Number The epsilon value used for comparisons
Source:
Returns:
The intersections
Type
Array.<{x:Number, y:Number}>

(inner) isAngleInRange(p, a, b) → {Boolean}

Checks whether an angle is in the range specified by [a,b]
Parameters:
Name Type Description
p Number The pojnt
a Number The start angle
b Number The end angle
Source:
Returns:
True, if the angle is in the range, false otherwise
Type
Boolean

(inner) isLine(l)

Checks, whether the given object is an infinite line
Parameters:
Name Type Description
l Object TYPE_LINE object
Source:
Returns:
True, if the parameter is an infinite line, false otherwise

(inner) isLineSegment(l)

Checks, whether the given object is a line segment
Parameters:
Name Type Description
l Object TYPE_LINE object
Source:
Returns:
True, if the parameter is a line segment, false otherwise

(inner) isParamEmpty(value)

Checkes, whether a parameter is empty
Parameters:
Name Type Description
value * The value to check
Source:
Returns:
True, if the value is EMPTY, false otherwise

(inner) isParamValid(value)

Checkes, whether a parameter is valid
Parameters:
Name Type Description
value * The value to check
Source:
Returns:
True, if the value is not INVALID, false otherwise

(inner) isPointDirectionValidOnArc(p, arc)

Checks whether a point's direction lies in the angle range specified by the given arc
Parameters:
Name Type Description
p Object The point
arc Object The arc
Source:
Returns:
True, if the point is valid, false otherwise

(inner) isPointInAngleRange(p, a, b) → {Boolean}

Checks whether a point's angle is in the range specified by [a,b]
Parameters:
Name Type Description
p Object The pojnt
a Number The start angle
b Number The end angle
Source:
Returns:
True, if the point is in the range, false otherwise
Type
Boolean

(inner) isRay(l)

Checks, whether the given object is a one-sided infinite line
Parameters:
Name Type Description
l Object TYPE_LINE object
Source:
Returns:
True, if the parameter is a one-sided infinite line, false otherwise

(inner) makeAngle(value, start, ref) → {Object}

Creates an Angle type object of type TYPE_ANGLE Any object that has the following fields can be treated as an Angle value: { value: Number, value: Number, type = TYPE_ANGLE }
Parameters:
Name Type Description
value Number The angle
start Number The angle at which this angle begins
ref Object A point to which the angle attaches to
Source:
Returns:
Type
Object

(inner) makeArc(center, rx, startAngle, endAngle) → {Object}

Creates an Arc type object of type TYPE_ARC Any object that has the following fields can be treated as an Arc value: { center: {x:Number, y:Number}, r: Number, startAngle: Number, endAngle: Number, type = TYPE_ARC }
Parameters:
Name Type Description
center Object The center of the arc
rx Number The radius
startAngle Number The angle at which the arc begins (counterclockwise)
endAngle Number The angle at which the arc ends (counterclockwise)
Source:
Returns:
Type
Object

(inner) makeBezier(points) → {Object}

Creates a Bezier curve type object of type TYPE_BEZIER Any object that has the following fields can be treated as a Bezier curve value: { points : Array<{x:Number,y:Number}>, degree: Number, type = TYPE_BEZIER }
Parameters:
Name Type Description
points Array.<{x:Number, y:Number}> The Bezier control points
Source:
Returns:
Type
Object

(inner) makeBezierSpline(points, degree) → {Object}

Creates a Bezier spline type object of type TYPE_BEZIER_SPLINE Any object that has the following fields can be treated as a Bezier curve value: { points : Array<{x:Number,y:Number}>, degree: Number, type = TYPE_BEZIER_SPLINE }
Parameters:
Name Type Description
points Array.<{x:Number, y:Number}> The Bezier control points
degree Number The degree for the spline. Each consecutive curve segment uses the last segment's endpoint as its start. So for a degree d curve, each new segment only needs to specify d new points
Source:
Returns:
Type
Object

(inner) makeBoolean(value) → {Object}

Creates a Boolean type object of type TYPE_BOOLEAN Any object that has the following fields can be treated as a Boolean value: { value: Boolean, type = TYPE_BOOLEAN }
Parameters:
Name Type Default Description
value Boolean false The value
Source:
Returns:
Type
Object

(inner) makeCollection(objects, propertiesopt) → {Object}

Creates a collection type object of type TYPE_COLLECTION Any object that has the following fields can be treated as a collection value: { objects : Array, type = TYPE_COLLECTION }
Parameters:
Name Type Attributes Description
objects Array The objects
properties Array <optional>
The object properties
Source:
Returns:
Type
Object

(inner) makeCoordinateSystem(origin, u, v) → {Object}

Creates a coordinate system type object of type TYPE_COORD_SYSTEM Any object that has the following fields can be treated as a coordinate system value: { origin: {x:Number, y:Number}, u: {x:Number, y:Number}, v: {x:Number, y:Number}, type = TYPE_COORD_SYSTEM }
Parameters:
Name Type Description
origin Object The origin
u Object The first axis
v Object The second axis
Source:
Returns:
Type
Object

(inner) makeEllipse(center, rx, ry, startAngle, endAngle, rotation) → {Object}

Creates an Ellipse type object of type TYPE_ELLIPSE Any object that has the following fields can be treated as an Ellipse value: { center: {x:Number, y:Number}, rx: Number, ry: Number, startAngle: Number, endAngle: Number, rotation: Number, type = TYPE_ELLIPSE }
Parameters:
Name Type Description
center Object The center of the ellipse
rx Number The eccentricity in local x-direction
ry Number The eccentricity in local y-direction
startAngle Number The angle at which the ellipse begins (counterclockwise)
endAngle Number The angle at which the ellipse ends (counterclockwise)
rotation Number The rotation angle of the ellipse (counterclockwise)
Source:
Returns:
Type
Object

(inner) makeLine(p0, p1, leftOpen, rightOpen) → {Object}

Creates a Line type object of type TYPE_LINE Any object that has the following fields can be treated as a Line value: { {p0 : {x:Number, y:Number}, p1 : {x:Number, y:Number}, leftOpen : Boolean, rightOpen : Boolean, type = TYPE_LINE }
Parameters:
Name Type Description
p0 Object The first point
p1 Object The second point
leftOpen Boolean Whether the line extends to infinity from the first point
rightOpen Boolean Whether the line extends to infinity from the second point
Source:
Returns:
Type
Object

(inner) makeLineStrip(points) → {Object}

Creates a Line strip type object of type TYPE_LINE_STRIP Any object that has the following fields can be treated as a Line strip value: { points : Array<{x:Number,y:Number}>, type = TYPE_LINE_STRIP }
Parameters:
Name Type Description
points Array.<{x:Number, y:Number}> The line strip points
Source:
Returns:
Type
Object

(inner) makeNumber(value) → {Object}

Creates a Number type object of type TYPE_NUMBER Any object that has the following fields can be treated as a Number value: { value: Number, type = TYPE_NUMBER }
Parameters:
Name Type Default Description
value Number 0 The value
Source:
Returns:
Type
Object

(inner) makePoint(x, y, rest) → {Object}

Creates a Point type object of type TYPE_POINT Any object that has the following fields can be treated as a Point value: { x: Number, y: Number, type = TYPE_POINT }
Parameters:
Name Type Description
x Number The x coordinate
y Number The y coordinate
rest * Other fields that get included in the object
Source:
Returns:
Type
Object

(inner) makePolarCoordinate(r, alpha) → {Object}

Creates a Polar coordinate type object of type TYPE_POLAR Any object that has the following fields can be treated as a Polar coordinate value: { r: Number, alpha: Number, type = TYPE_POLAR }
Parameters:
Name Type Description
r Number The r coordinate
alpha Number The alpha coordinate
Source:
Returns:
Type
Object

(inner) makePolygon(points) → {Object}

Creates a Polygon type object of type TYPE_POLYGON Any object that has the following fields can be treated as a Polygon value: { points : Array<{x:Number,y:Number}>, type = TYPE_POLYGON }
Parameters:
Name Type Description
points Array.<{x:Number, y:Number}> The polygon points
Source:
Returns:
Type
Object

(inner) makeText(text, ref) → {Object}

Creates a Text type object of type TYPE_TEXT Any object that has the following fields can be treated as an Text value: { text : String, ref: {x:Number, y:Number}, type = TYPE_TEXT }
Parameters:
Name Type Description
text String The text
ref Object A point to which the text attaches to
Source:
Returns:
Type
Object

(inner) makeVector(x, y, ref) → {Object}

Creates a Vector type object of type TYPE_VECTOR Any object that has the following fields can be treated as a Vector value: { x: Number, y: Number, ref: {x:Number, y:Number}, type = TYPE_VECTOR }
Parameters:
Name Type Description
x Number The x coordinate
y Number The y coordinate
ref Object A point to which the vector attaches to
Source:
Returns:
Type
Object

(inner) mergeObjectInto(target, source)

Merges all properties of source recursively into target
Parameters:
Name Type Description
target Object
source Object
Source:
Returns:
target

(inner) miminumAbsoluteDifferenceAngle(a, b) → {Number}

Computes the minimum absolute angle separating the two given ones
Parameters:
Name Type Description
a Number The first angle
b Number The second angle
Source:
Returns:
The minimum absolute difference angle
Type
Number

(inner) numSegmentsBezierSpline(points, degree) → {Number}

Computes the number of segments of a Bezier spline where each consecutive segment uses the last point of the previous one
Parameters:
Name Type Description
points Array.<{x:Number, y:Number}> The control points
degree Number The Bezier degree
Source:
Returns:
The number of segments
Type
Number

(inner) objectToString(obj, params) → {String}

Converts an object into readable text
Parameters:
Name Type Description
obj * The object to stringify
params Object
Properties
Name Type Description
maxDecimals Number maximum numbers of decimals to be used for numbers
formatter Object A formatter object to format numbers
Source:
Returns:
The stringified object
Type
String

(inner) orientedAngle(u, v) → {Number}

Computes the oriented angle of v relative to u
Parameters:
Name Type Description
u Object The first vector
v Object The second vector
Source:
Returns:
The oriented angle
Type
Number

(inner) rad2deg(rad) → {Number}

Converts an angle in radians to one in degrees
Parameters:
Name Type Description
rad Number The angle in radians
Source:
Returns:
The angle in degrees
Type
Number

(inner) removeColinear(lines, eps) → {Array.<{x:Number, y:Number}>}

Removes colinear line segments, which cause issues in some algorithms
Parameters:
Name Type Default Description
lines Array.<{x:Number, y:Number}> Line segments
eps Number 1e-10 The epsilon value to use in comparisons
Source:
Returns:
The line segments without colinearities
Type
Array.<{x:Number, y:Number}>

(inner) subdivideBezierAdaptive(points, epsopt) → {Object}

Subdivides a Bezier curve in such a way, that the points can be drawn as line segments that do not differ more from the curve than the given error parameter
Parameters:
Name Type Attributes Default Description
points Object The Bezier control points
eps Number <optional>
1 Subdivision error parameter
Source:
Returns:
The subdivided curve
Type
Object

(inner) subdivideBezierControlPoints(points, t) → {Object}

Creates two new sets of control points, such that the left set creates the given Bezier curve up to the parameter t, while the right set creates the rest of the original curve.
Parameters:
Name Type Description
points Object The control points
t Number The curve parameter
Source:
Returns:
The subdivided curve control points
Type
Object

(inner) subintervalBezierControlPoints(points, t0, t1) → {Object}

Computes the control points for a Bezier curve of the same degree as the given one that starts and ends at the given parameters of the original curve.
Parameters:
Name Type Description
points Object The control points
t0 Number The lower curve parameter in [0,1]
t1 Number The upper curve parameter in [0,1]
Source:
Returns:
The new control points
Type
Object