twodee · version 0.2.6

/source/Circle2.js:Circle28-213

Circle geometry

Import

import { Circle2 } from 'twodee/source/Circle2.js'

.Define(p, r, target)17-22

Returns an instance representing p and r

Signature

{Circle2} Circle2.Define({Vector2} p, {number} r [, {Circle2} target])

Arguments

{Vector2} p

The center point

{number} r

The radius

{Circle2} target optional

The target instance

Returns

{Circle2}

.Area(p, a, target)31-35

Returns an instance at p with area a

Signature

{Circle2} Circle2.Area({Vector2} p, {number} a [, {Circle2} target])

Arguments

{Vector2} p

The center point

{number} a

The area

{Circle2} target optional

The target instance

Returns

{Circle2}

.Copy(circle, target)44-46

Returns a copy of circle

Signature

{Circle2} Circle2.Copy({Circle2} circle [, {Circle2} target])

Arguments

{Circle2} circle

The source

{Circle2} target optional

The target instance

Returns

{Circle2}

.intersectPoint(p, r, q)56-58

Returns true if q intersects circle (p,r), false otherwise

Signature

{boolean} Circle2.intersectPoint({Vector2} p, {number} r, {Vector2} q)

Arguments

{Vector2} p

The circle center

{number} r

The circle radius

{Vector2} q

The point

Returns

{boolean}

.intersect(p0, r0, p1, r1, points)69-96

Returns true if circle (p0,r0) intersects circle (p1,r1), false otherwise

Signature

{boolean} Circle2.intersect({Vector2} p0, {number} r0, {Vector2} p1, {number} r1 [, {Vector2[]} points])

Arguments

{Vector2} p0

The first circle center

{number} r0

The first circle radius

{Vector2} p1

The second circle center

{number} r1

The second circle radius

{Vector2[]} points optional

The intersection points

Returns

{boolean}

.isEQ(a, b)105-107

Returns true if a and b are equal (a == b), false otherwise

Signature

{boolean} Circle2.isEQ({Circle2} a, {Circle2} b)

Arguments

{Circle2} a

The protagonist

{Circle2} b

The antagonist

Returns

{boolean}

#constructor(p, r)115-126

Creates a new instance

Signature

{undefined} Circle2#constructor({Vector2} p, {number} r)

Arguments

{Vector2} p

The center point

{number} r

The radius

Returns

No return value

#center120-120

The center point

Signature

{Vector2} Circle2#center

#radius125-125

The radius

Signature

{number} Circle2#radius

#define(p, r)135-139

Redefines the instance

Signature

{Circle2} Circle2#define({Vector2} p, {Vector2} r)

Arguments

{Vector2} p

The center point

{Vector2} r

The radius

Returns

{Circle2}

#area146-148

The area

Signature

{number} Circle2#area

#intersectsPoint(p)156-158

Returns true if p intersects the instance, false otherwise

Signature

{boolean} Circle2#intersectsPoint({Vector2} p)

Arguments

{Vector2} p

The point

Returns

{boolean}

#intersects(circle, points)166-168

Returns true if circle intersects the instance, false otherwise

Signature

{boolean} Circle2#intersects({Circle2} circle [, {Vector2[]} points])

Arguments

{Circle2} circle

The circle

{Vector2[]} points optional

The intersection points

Returns

{boolean}

#transformationOf(circle, transform)177-181

The transformation of circle

Signature

{Circle2} Circle2#transformationOf({Circle2} circle, {Matrix3} transform)

Arguments

{Circle2} circle

The source

{Matrix3} transform

The transform

Returns

{Circle2}

#copyOf(circle)188-190

The copy of circle

Signature

{Circle2} Circle2#copyOf({Circle2} circle)

Arguments

{Circle2} circle

The source

Returns

{Circle2}

#transformation(transform)198-202

The transformation of the instance

Signature

{Circle2} Circle2#transformation({Matrix3} transform)

Arguments

{Matrix3} transform

The transform

Returns

{Circle2}

#toString(digits)210-212

Returns a string representation of the instance

Signature

{string} Circle2#toString({int} digits)

Arguments

{int} digits

The decimal places

Returns

{string}

/source/Polygon2.js:Polygon2182-935

Planar triangle mesh

Import

import { Polygon2 } from 'twodee/source/Polygon2.js'

.Define(target)189-194

Returns a defined instance

Signature

{Polygon2} Polygon2.Define([{Polygon2} target])

Arguments

{Polygon2} target optional

The target instance

Returns

{Polygon2}

.JSON(json, target)202-212

Returns an instance created from json

Signature

{Polygon2} Polygon2.JSON({Object} json [, {Polygon2} target])

Arguments

{Object} json

The json representation of the instance

{Polygon2} target optional

The target instance

Returns

{Polygon2}

.Points(points)221-230

Returns an instance from points Using TriangleSubdivisionTree

Signature

{Polygon2} Polygon2.Points({Vector2[]} points)

Arguments

{Vector2[]} points

The points

Returns

{Polygon2}

.PolyLine2(outline)238-247

Returns an instance from outline Using TriangleSubdivisionTree

Signature

{Polygon2} Polygon2.PolyLine2({PolyLine2} outline)

Arguments

{PolyLine2} outline

The outline

Returns

{Polygon2}

.Copy(poly, target)256-280

Returns a copy of poly

Signature

{Polygon2} Polygon2.Copy({Polygon2} poly [, {Polygon2} target])

Arguments

{Polygon2} poly

The source

{Polygon2} target optional

The target instance

Returns

{Polygon2}

#constructor()287-296

Creates a new instance

Signature

{undefined} Polygon2#constructor()

Arguments

None

Returns

No return value

#define()303-307

Redefines the instance

Signature

{Polygon2} Polygon2#define()

Arguments

None

Returns

{Polygon2}

#face314-322

The dereferenced defined face indices of the instance

Signature

{int[]} Polygon2#face

#edge328-336

The dereferenced defined edge indices of the instance

Signature

{int[]} Polygon2#edge

#vertex342-350

The dereferenced defined vertex indices of the instance

Signature

{int[]} Polygon2#vertex

#point356-358

The deferenced list of points of the instance

Signature

{Vector2[]} Polygon2#point

#indexList365-373

The dereferenced display list of vertex indices of the instance

Signature

{number[]} Polygon2#indexList

#centroid380-397

The dereferenced centroid point

Signature

{Vector2} Polygon2#centroid

#area403-419

The area sum((1/2)|AB x AC|)

Signature

{number} Polygon2#area

#hasFace(face)427-429

Returns true if face is a defined face index, false otherwise

Signature

{boolean} Polygon2#hasFace({int} face)

Arguments

{int} face

The face index

Returns

{boolean}

#edgeOfFace(face, vertex)437-447

Returns a ccw-ordered Array of edge indices associated with face

Signature

{int[]} Polygon2#edgeOfFace({int} face [, {int} vertex])

Arguments

{int} face

The face index

{int} vertex optional

The first ccw vertex index of the first edge index

Returns

{int[]}

#vertexOfFace(face, edge)455-465

Returns a ccw-ordered Array of vertex indices associated with face

Signature

{int[]} Polygon2#vertexOfFace({int} face [, {int} edge])

Arguments

{int} face

The face index

{int} edge optional

The edge index of the first ccw vertex index

Returns

{int[]}

#pointOfFace(face, edge)474-479

Returns the ccw ordered points associated with face Proxies Polygon2#vertexOfFace

Signature

{Vector2[]} Polygon2#pointOfFace({int} face [, {int} edge])

Arguments

{int} face

The face index

{int} edge optional

The edge index of the first ccw vertex index

Returns

{Vector2[]}

#hasEdge(edge)487-489

Returns true if edge is a defined edge index, false otherwise

Signature

{boolean} Polygon2#hasEdge({int} edge)

Arguments

{int} edge

The edge index

Returns

{boolean}

#faceOfEdge(edge, face)497-502

Returns a front,back sorted Array of face indices associated with edge

Signature

{int[]} Polygon2#faceOfEdge({int} edge [, {int} face])

Arguments

{int} edge

The edge index

{int} face optional

The second face index

Returns

{int[]}

#vertexOfEdge(edge, vertex)510-515

Returns a from,to sorted Array of vertex indices associated with edge

Signature

{int[]} Polygon2#vertexOfEdge({int} edge [, {int} vertex])

Arguments

{int} edge

The edge index

{int} vertex optional

The second vertex index

Returns

{int[]}

#pointOfEdge(edge, vertex)524-529

Returns the from, to ordered points associated with edge Proxies Polygon2#vertexOfEdge

Signature

{Vector2[]} Polygon2#pointOfEdge({int} edge [, {int} vertex])

Arguments

{int} edge

The edge

{int} vertex optional

The second vertex

Returns

{Vector2[]}

#hasVertex(vertex)537-539

Returns true if vertex is a defined vertex index, false otherwise

Signature

{boolean} Polygon2#hasVertex({int} vertex)

Arguments

{int} vertex

The vertex index

Returns

{boolean}

#faceOfVertex(vertex, constraint)547-560

Returns an Array of face indices associated with vertex

Signature

{int[]} Polygon2#faceOfVertex({int} vertex [, {int[]} constraint])

Arguments

{int} vertex

The vertex index

{int[]} constraint optional

Array of complementary face vertex indices

Returns

{int[]}

#edgeOfVertex(vertex, constraint)568-584

Returns an Array of edge indices associated with vertex

Signature

{int[]} Polygon2#edgeOfVertex({int} vertex [, {int[]} constraint])

Arguments

{int} vertex

The vertex index

{int[]} constraint optional

Array of complementary edge vertex indices

Returns

{int[]}

#pointOfVertex(vertex)591-593

Returns the point associated with vertex

Signature

{Vector2} Polygon2#pointOfVertex({int} vertex)

Arguments

{int} vertex

The vertex

Returns

{Vector2}

#hasPoint(point)601-603

Returns true if point is a defined point, false otherwise

Signature

{boolean} Polygon2#hasPoint({Vector2} point)

Arguments

{Vector2} point

The point

Returns

{boolean}

#pointAt(point)610-618

Returns the point at coordinates of point if found, null otherwise

Signature

{Vector2|null} Polygon2#pointAt({Vector2} point)

Arguments

{Vector2} point

The point

Returns

{Vector2|null}

#vertexOfPoint(point)625-627

Returns the vertex index associated with point

Signature

{int} Polygon2#vertexOfPoint({Vector2} point)

Arguments

{Vector2} point

The point

Returns

{int}

#createFace(vertex0, vertex1, vertex2)637-658

Returns the index of the face created between vertex0, vertex1 and vertex2

Signature

{int} Polygon2#createFace({int} vertex0, {int} vertex1, {int} vertex2)

Arguments

{int} vertex0

The first vertex

{int} vertex1

The second vertex

{int} vertex2

The third vertex

Returns

{int}

#removeFace(face)664-683

Removes face

Signature

{undefined} Polygon2#removeFace({int} face)

Arguments

{int} face

The face index

Returns

No return value

#createVertex(p)690-698

Returns the index of the vertex created from p

Signature

{int} Polygon2#createVertex({Vector2} p)

Arguments

{Vector2} p

The point

Returns

{int}

#removeVertex(vertex)704-716

Removes vertex and all associated faces

Signature

{undefined} Polygon2#removeVertex({int} vertex)

Arguments

{int} vertex

Returns

No return value

#clearIsolatedVertices()722-728

Removes all isolated vertices

Signature

{Polygon2} Polygon2#clearIsolatedVertices()

Arguments

None

Returns

{Polygon2}

#subdivideFace(face, point)737-756

Returns the subdivision vertex index of the faces created by subdividing face

Signature

{int} Polygon2#subdivideFace({int} face [, {Vector2} point])

Arguments

{int} face

The source face index

{Vector2} point optional

The subdivision point

Returns

{int}

#splitEdge(edge, point)764-792

Returns the split vertex index of the edges created by splitting edge

Signature

{int} Polygon2#splitEdge({int} edge [, {Vector2} point])

Arguments

{int} edge

The source edge index

{Vector2} point optional

The splitting point

Returns

{int}

#turnEdge(edge)799-811

Returns the index of the edge created by turning edge

Signature

{int} Polygon2#turnEdge({int} edge)

Arguments

{int} edge

The edge

Returns

{int}

#intersectsPoint(q, fuv)819-837

Returns true if the instance intersects with q, false otherwise

Signature

{boolean} Polygon2#intersectsPoint({Vector2} q [, {number[]} fuv])

Arguments

{Vector2} q

The antagonist

{number[]} fuv optional

The face index and barycentric (u,v) coordindates

Returns

{boolean}

#intersects(poly)844-863

Returns true if the instance intersects with poly, false otherwise

Signature

{boolean} Polygon2#intersects({Polygon2} poly)

Arguments

{Polygon2} poly

The antagonist

Returns

{boolean}

#transformationOf(poly, transform)872-876

The transformation of poly

Signature

{Polygon2} Polygon2#transformationOf({Polygon2} poly, {Matrix3} transform)

Arguments

{Polygon2} poly

The source

{Matrix3} transform

The transform

Returns

{Polygon2}

#copyOf(poly)883-885

The copy of poly

Signature

{Polygon2} Polygon2#copyOf({Polygon2} poly)

Arguments

{Polygon2} poly

The source polygon

Returns

{Polygon2}

#transformation(transform)893-905

The transformation of the instance

Signature

{Polygon2} Polygon2#transformation({Matrix3} transform)

Arguments

{Matrix3} transform

the transform

Returns

{Polygon2}

#toJSON()912-934

Returns a json reprentation of the instance

Signature

{} Polygon2#toJSON()

Arguments

None

Returns

{}

/source/PolyLine2.js:PolyLine246-352

Planar geometric primitive, first order

Import

import { PolyLine2 } from 'twodee/source/PolyLine2.js'

.ConvexHullGraham(point, target)55-88

Returns a new instance from the convex hull of point Using graham scanning

Signature

{PolyLine2} PolyLine2.ConvexHullGraham({Vector2[]} point [, {PolyLine2} target])

Arguments

{Vector2[]} point

The points

{PolyLine2} target optional

The target instance

Returns

{PolyLine2}

.Rectangle2(rectangle, target)96-114

Returns a new instance from rectangle

Signature

{PolyLine2} PolyLine2.Rectangle2({Rectangle2} rectangle [, {PolyLine2} target])

Arguments

{Rectangle2} rectangle

The source

{PolyLine2} target optional

The target instance

Returns

{PolyLine2}

.Transformation(poly, transform, target)124-128

Returns an instance representing the transformation of poly

Signature

{Polyline2} PolyLine2.Transformation({PolyLine2} poly, {Matrix3} transform [, {PolyLine2} target])

Arguments

{PolyLine2} poly

The source

{Matrix3} transform

The transform

{PolyLine2} target optional

The target instance

Returns

{Polyline2}

.Copy(poly, target)136-140

Returns a copy of poly

Signature

{PolyLine2} PolyLine2.Copy({PolyLine2} poly [, {PolyLine2} target])

Arguments

{PolyLine2} poly

The source

{PolyLine2} target optional

The target instance

Returns

{PolyLine2}

.intersectPoint(pN, q0)150-168

Returns true if point q0 intersects poly line pN, false otherwise Using the crossings test (RRp754)

Signature

{boolean} PolyLine2.intersectPoint({Vector2[]} pN, {Vector2} q0)

Arguments

{Vector2[]} pN

The poly line segments

{Vector2} q0

The point

Returns

{boolean}

.intersectSegments(p0, p1, q0, q1, r)181-203

Returns true if segment (p0,p1) intersects segment (q0,q1), false otherwise (RRp781)

Signature

{boolean} PolyLine2.intersectSegments({Vector2} p0, {Vector2} p1, {Vector2} q0, {Vector2} q1 [, {Vector2} r])

Arguments

{Vector2} p0

The first point of the first segment

{Vector2} p1

The second point of the first segment

{Vector2} q0

The first point of the second segment

{Vector2} q1

The second point of the second segment

{Vector2} r optional

The intersection point References the intersection point if segments intersect

Returns

{boolean}

.intersect(pN, qN, r)213-237

Returns true if pN intersects qN, false otherwise

Signature

{boolean} PolyLine2.intersect({Vector2[]} pN, {Vector2[]} qN [, {Vector2[]} r])

Arguments

{Vector2[]} pN

The first array of points

{Vector2[]} qN

The second array of points

{Vector2[]} r optional

The intersection point(s) References the intersection point(s) if primitives intersect

Returns

{boolean}

#constructor(point)245-251

Creates a new instance

Signature

{undefined} PolyLine2#constructor({Vector2[]} point)

Arguments

{Vector2[]} point

The points

Returns

No return value

#point250-250

The points

Signature

{Vector2[]} PolyLine2#point

#define(point)259-263

Redefines the instance

Signature

{PolyLine2} PolyLine2#define([{Vector2[]} point])

Arguments

{Vector2[]} point optional

The points

Returns

{PolyLine2}

#segments270-272

The number of segments

Signature

{int} PolyLine2#segments

#closed278-280

true if the first and last points are identical (===), false otherwise

Signature

{boolean} PolyLine2#closed

#intersectsPoint(point)289-291

Returns true if the instance intersects with point, false otherwise Alias for PolyLine2.intersectsPoint

Signature

{boolean} PolyLine2#intersectsPoint({Vector2} point)

Arguments

{Vector2} point

The antagonist

Returns

{boolean}

#intersects(poly, point)301-303

Returns true if the instance intersects with poly, false otherwise Alias for PolyLine2.intersect

Signature

{boolean} PolyLine2#intersects({PolyLine2} poly [, {Vector2[]} point])

Arguments

{PolyLine2} poly

The antagonist

{Vector2[]} point optional

The intersection points References the intersection points if polylines intersect

Returns

{boolean}

#transformationOf(poly, transform)312-319

The transformation of poly

Signature

{PolyLine2} PolyLine2#transformationOf({PolyLine2} poly, {Matrix3} transform)

Arguments

{PolyLine2} poly

The source

{Matrix3} transform

The transform

Returns

{PolyLine2}

#copyOf(poly)326-332

The copy of poly

Signature

{PolyLine2} PolyLine2#copyOf({PolyLine2} poly)

Arguments

{PolyLine2} poly

The source

Returns

{PolyLine2}

#transformation(transform)340-342

The transformation of the instance

Signature

{PolyLine2} PolyLine2#transformation({Matrix3} transform)

Arguments

{Matrix3} transform

The transform

Returns

{PolyLine2}

#toString()349-351

Returns a string representation of the instance

Signature

{string} PolyLine2#toString()

Arguments

None

Returns

{string}

/source/Ray2.js:Ray261-231

Planar Ray

Import

import { Ray2 } from 'twodee/source/Ray2.js'

.Define(origin, orientation, target)70-76

Returns a defined instance

Signature

{Ray2} Ray2.Define({Vector2} origin, {Vector2} orientation [, {Ray2} target])

Arguments

{Vector2} origin

The ray origin

{Vector2} orientation

The ray orientation

{Ray2} target optional

The target instance

Returns

{Ray2}

.intersectSegment(pa, oa, q0, q1, r)88-110

Returns true if ray (pa,oa) intersects line segment (q0,q1), false otherwise

Signature

{boolean} Ray2.intersectSegment({Vector2} pa, {Vector2} oa, {Vector2} q0, {Vector2} q1 [, {Vector2} r])

Arguments

{Vector2} pa

The ray origin

{Vector2} oa

The ray orientation

{Vector2} q0

The first point of the line segment

{Vector2} q1

The second point of the line segment

{Vector2} r optional

The intersection point

Returns

{boolean}

.intersect(pa, oa, pb, ob, r)121-142

Returns true if ray (pa,oa) and ray (pb,ob) intersect, false otherwise

Signature

{boolean} Ray2.intersect({Vector2} pa, {Vector2} oa, {Vector2} pb, {Vector2} ob [, {Vector2} r])

Arguments

{Vector2} pa

The origin of the first ray

{Vector2} oa

The orientation of the first ray

{Vector2} pb

The origin of the second ray

{Vector2} ob

The orientation of the second ray

{Vector2} r optional

The intersection point

Returns

{boolean}

.isEQ(a, b)151-153

Returns true if a and b represent the same ray (a == b), false otherwise

Signature

{boolean} Ray2.isEQ({Ray2} a, {Ray2} b)

Arguments

{Ray2} a

The protagonist

{Ray2} b

The antagonist

Returns

{boolean}

#constructor(origin, orientation)161-172

Creates a new instance

Signature

{undefined} Ray2#constructor({Vector2} origin, {Vector2} orientation)

Arguments

{Vector2} origin

The ray origin

{Vector2} orientation

The orientation

Returns

No return value

#origin166-166

The origin

Signature

{Vector2} Ray2#origin

#orientation171-171

The orientation

Signature

{Vector2} Ray2#orientation

#define(origin, orientation)181-185

Redefines the instance

Signature

{Ray2} Ray2#define({Vector2} origin, {Vector2} orientation)

Arguments

{Vector2} origin

The ray origin

{Vector2} orientation

The orientation

Returns

{Ray2}

#intersectsSegment(p0, p1, r)195-197

Returns true if the instance intersects line segment (p0, p1), false otherwise

Signature

{boolean} Ray2#intersectsSegment({Vector2} p0, {Vector2} p1 [, {Vector2} r])

Arguments

{Vector2} p0

The first point of the segment

{Vector2} p1

The second point of the segment

{Vector2} r optional

The intersection point

Returns

{boolean}

#intersects(ray, r)205-207

Returns true if the instance intersects ray, false otherwise

Signature

{boolean} Ray2#intersects({Ray2} ray [, {Vector2} r])

Arguments

{Ray2} ray

The antagonist

{Vector2} r optional

The intersection point

Returns

{boolean}

#copyOf(ray)215-220

The copy of ray

Signature

{Ray2} Ray2#copyOf({Ray2} ray)

Arguments

{Ray2} ray

The source

Returns

{Ray2}

#toString(digits)228-230

Returns a string representation of the instance

Signature

{string} Ray2#toString([{int} digits=3])

Arguments

{int} digits optionaldefault3

The decimal digits

Returns

{string}

/source/Rectangle2.js:Rectangle212-405

Planar geometric primitive, second order

Import

import { Rectangle2 } from 'twodee/source/Rectangle2.js'

.Define(transform, extend, target)21-24

Defines an instance

Signature

{Rectangle2} Rectangle2.Define({Matrix3} transform, {Vector2} extend [, {Rectangle2} target])

Arguments

{Matrix3} transform

The transform

{Vector2} extend

The extend

{Rectangle2} target optional

The target instance

Returns

{Rectangle2}

.Box(w, h, target)32-37

Returns a new instance from w, h

Signature

{undefined} Rectangle2.Box({number} w, {number} h [, {Rectangle2} target])

Arguments

{number} w

The width

{number} h

The height

{Rectangle2} target optional

The target instance

Returns

No return value

.AABB(point, target)45-69

Returns a new instance from point

Signature

{Rectangle2} Rectangle2.AABB({Vector2[]} point [, {Rectangle2} target])

Arguments

{Vector2[]} point

The points

{Rectangle2} target optional

The target instance

Returns

{Rectangle2}

.Transformation(rectangle, transform, target)78-82

Returns an instance representing the transformation of rectangle

Signature

{Rectangle2} Rectangle2.Transformation({Rectangle2} rectangle, {Matrix3} transform [, {Rectangle2} target])

Arguments

{Rectangle2} rectangle

The source

{Matrix3} transform

The transform

{Rectangle2} target optional

The target instance

Returns

{Rectangle2}

.Copy(rectangle, target)90-97

Returns a copy of rectangle

Signature

{Rectangle2} Rectangle2.Copy({Rectangle2} rectangle [, {Rectangle2} target])

Arguments

{Rectangle2} rectangle

The source

{Rectangle2} target optional

The target instance

Returns

{Rectangle2}

.intersectPoint(tA, eA, p)107-114

Returns true if obb (tA,eA) intersects with point (p), false otherwise

Signature

{boolean} Rectangle2.intersectPoint({Matrix3} tA, {Vector2} eA, {Vector2} p)

Arguments

{Matrix3} tA

The transform of the obb

{Vector2} eA

The half-dimensions of the obb

{Vector2} p

The point

Returns

{boolean}

.intersectTriangle(t, e, p0, p1, p2)125-168

Returns true if obb (t, e) intersects with triangle(p0,p1,p2)

Signature

{boolean} Rectangle2.intersectTriangle({Matrix3} t, {Vector2} e, {Vector2} p0, {Vector2} p1, {Vector2} p2)

Arguments

{Matrix3} t

The obb transform

{Vector2} e

The obb extend

{Vector2} p0

The first point of the triangle

{Vector2} p1

The second point of the triangle

{Vector2} p2

The third point of the triangle

Returns

{boolean}

.intersect(tA, eA, tB, eB)179-199

Returns true if obb (tA,eA) intersects with obb (tB,eB), false otherwise OBB intersection test using the seperating axis method by Gottschalk et. al. [RRp767]

Signature

{boolean} Rectangle2.intersect({Matrix3} tA, {Vector2} eA, {Matrix3} tB, {Vector2} eB)

Arguments

{Matrix3} tA

The transform of the first obb

{Vector2} eA

The half-dimensions of the first obb

{Matrix3} tB

The transform of the second obb

{Vector2} eB

The half-dimensions of the second obb

Returns

{boolean}

#isEQ(a, b)208-210

Returns true if a and b represent the same rectangle, false otherwise

Signature

{boolean} Rectangle2#isEQ({Rectangle2} a, {Rectangle2} b)

Arguments

{Rectangle2} a

The protagonist

{Rectangle2} b

The antagonist

Returns

{boolean}

#constructor(transform, extend)219-230

Creates a new instance

Signature

{undefined} Rectangle2#constructor([{Matrix3} transform [, {Vector2} extend]])

Arguments

{Matrix3} transform optional

The transform

{Vector2} extend optional

The extend

Returns

No return value

#transform224-224

The transform

Signature

{Matrix3} Rectangle2#transform

#extend229-229

The half-dimensions

Signature

{Vector2} Rectangle2#extend

#define(transform, extend)239-243

Redefines the instance

Signature

{Rectangle2} Rectangle2#define([{Matrix3} transform [, {Vector2} extend]])

Arguments

{Matrix3} transform optional

The transform

{Vector2} extend optional

The half-dimensions

Returns

{Rectangle2}

#center250-252

The dereferenced center point

Signature

{Vector2} Rectangle2#center

#width265-267

The width Alias of Rectangle2#extend

Signature

{number} Rectangle2#width

#height279-281

The height Alias of Rectangle#extend

Signature

{number} Rectangle2#height

#aspect292-294

The aspect (w/h)

Signature

{number} Rectangle2#aspect

#area300-302

The area (w*h)

Signature

{number} Rectangle2#area

#intersectsPoint(p)311-313

Returns true if the instance intersects with p, false otherwise Alias for Rectangle2.intersectPoint

Signature

{boolean} Rectangle2#intersectsPoint({Vector2} p)

Arguments

{Vector2} p

The antagonist

Returns

{boolean}

#intersectsSegment(p0, p1, r)324-326

Returns true if the instance intersects with segment (p0,p1), false otherwise Alias of Polyline2.intersect

Signature

{boolean} Rectangle2#intersectsSegment({Vector2} p0, {Vector2} p1 [, {Vector2[]} r])

Arguments

{Vector2} p0

The first point of the antagonist

{Vector2} p1

The second point of the antagonist

{Vector2[]} r optional

The intersection points References the intersection points if instances intersect

Returns

{boolean}

#intersects(rectangle, point)336-355

Returns true if the instance intersects with rectangle, false otherwise Alias of Rectangle2.intersect

Signature

{boolean} Rectangle2#intersects({Rectangle2} rectangle [, {Rectangle2} point])

Arguments

{Rectangle2} rectangle

The antagonist

{Rectangle2} point optional

The intersection point(s) References the intersection point(s) if obbs intersect

Returns

{boolean}

#transformationOf(rectangle, transform)364-369

The transformation of rectangle

Signature

{Rectangle2} Rectangle2#transformationOf({Rectangle2} rectangle, {Matrix3} transform)

Arguments

{Rectangle2} rectangle

The source

{Matrix3} transform

The transform

Returns

{Rectangle2}

#copyOf(rectangle)376-381

The copy of rectangle

Signature

{Rectangle2} Rectangle2#copyOf({Rectangle2} rectangle)

Arguments

{Rectangle2} rectangle

The source

Returns

{Rectangle2}

#transformation(transform)389-393

The transformation of the instance

Signature

{Rectangle2} Rectangle2#transformation({Matrix3} transform)

Arguments

{Matrix3} transform

The transform

Returns

{Rectangle2}

#toString()400-404

Returns a string representation of the instance

Signature

{string} Rectangle2#toString()

Arguments

None

Returns

{string}

/source/Triangle2.js:CW13-13

The clockwise orientation sign

Import

import { CW } from 'twodee/source/Triangle2.js'

/source/Triangle2.js:CCW18-18

The counter-clockwise orientation sign

Import

import { CCW } from 'twodee/source/Triangle2.js'

/source/Triangle2.js:DEGENERATE23-23

The degenerate orientation sign

Import

import { DEGENERATE } from 'twodee/source/Triangle2.js'

/source/Triangle2.js:Triangle233-434

Planar geometric primitive, second order

Import

import { Triangle2 } from 'twodee/source/Triangle2.js'

.Equilateral(p, r, rad, f, target)44-59

Returns an instance representing the equilateral triangle circumscribed|inscribed by r, rotated by rad

Signature

{Triangle2} Triangle2.Equilateral({Vector2} p, {number} r [, {number} rad=0.0 [, {boolean} f=0.0 [, {Triangle2} target]]])

Arguments

{Vector2} p

The centroid point

{number} r

The distance between centroid and point

{number} rad optionaldefault0.0

The angle

{boolean} f optionaldefault0.0

The inscription factor

{Triangle2} target optional

The target instance

Returns

{Triangle2}

.Transformation(triangle, transform, target)68-72

Returns an instance representing the transformation of triangle

Signature

{Triangle2} Triangle2.Transformation({Triangle2} triangle, {Matrix3} transform [, {Triangle2} target])

Arguments

{Triangle2} triangle

The source

{Matrix3} transform

The transform

{Triangle2} target optional

The target instance

Returns

{Triangle2}

.Copy(triangle, target)80-88

Returns a copy of triangle

Signature

{Triangle2} Triangle2.Copy({Triangle2} triangle [, {Triangle2} target])

Arguments

{Triangle2} triangle

The source

{Triangle2} target optional

The target instance

Returns

{Triangle2}

.centroid(p0, p1, p2)97-99

Returns a Vector2 representing the centroid of triangle (p0,p1,p2)

Signature

{Vector2} Triangle2.centroid({Vector2} p0, {Vector2} p1, {Vector2} p2)

Arguments

{Vector2} p0

The first point

{Vector2} p1

The second point

{Vector2} p2

The third point

Returns

{Vector2}

.circumcenter(p0, p1, p2)108-120

Returns a Vector2 representing the circumcenter of triangle (p0,p1,p2)

Signature

{Vector2} Triangle2.circumcenter({Vector2} p0, {Vector2} p1, {Vector2} p2)

Arguments

{Vector2} p0

The first point

{Vector2} p1

The second point

{Vector2} p2

The third point

Returns

{Vector2}

.area(p0, p1, p2)129-134

Returns the area (1/2)|AB x AC| of triangle (p0,p1,p2)

Signature

{number} Triangle2.area({Vector2} p0, {Vector2} p1, {Vector2} p2)

Arguments

{Vector2} p0

The first point

{Vector2} p1

The second point

{Vector2} p2

The third point

Returns

{number}

.intersectPointCircumcircle(p0, p1, p2, q0)145-155

Returns true if the circumcircle of ccw triangle (p0,p1,p2) intersects with point (q0), false otherwise

Signature

{boolean} Triangle2.intersectPointCircumcircle({Vector2} p0, {Vector2} p1, {Vector2} p2, {Vector2} q0)

Arguments

{Vector2} p0

The first point of the triangle

{Vector2} p1

The second point of the triangle

{Vector2} p2

The third point of the triangle

{Vector2} q0

The antagonist

Returns

{boolean}

.intersectPoint(p0, p1, p2, q, uv)167-187

Returns true if triangle (p0,p1,p2) intersects with point (q0), false otherwise

Signature

{boolean} Triangle2.intersectPoint({Vector2} p0, {Vector2} p1, {Vector2} p2, {Vector2} q [, {number[]} uv])

Arguments

{Vector2} p0

The first point of the triangle

{Vector2} p1

The second point of the triangle

{Vector2} p2

The third point of the triangle

{Vector2} q

The point

{number[]} uv optional

Array holding the barycentric (u,v) coordinates References the barycentric intersection coordinates(u,v) if primitives intersect

Returns

{boolean}

.intersectSegment(p0, p1, p2, q0, q1, r)200-221

Returns true if triangle (p0,p1,p2) intersects with segment (q0,q1), false otherwise

Signature

{boolean} Triangle2.intersectSegment({Vector2} p0, {Vector2} p1, {Vector2} p2, {Vector2} q0, {Vector2} q1 [, {Vector2[]} r])

Arguments

{Vector2} p0

The first point of the triangle

{Vector2} p1

The second point of the triangle

{Vector2} p2

The third point of the triangle

{Vector2} q0

The first point of the segment

{Vector2} q1

The second point of the segment

{Vector2[]} r optional

The intersection point(s) References the intersection points if primitives intersect

Returns

{boolean}

.intersect(p0, p1, p2, q0, q1, q2, r)235-267

Returns true if triangle (p0,p1,p2) intersects with triangle(q0,q1,q2), false otherwise

Signature

{boolean} Triangle2.intersect({Vector2} p0, {Vector2} p1, {Vector2} p2, {Vector2} q0, {Vector2} q1, {Vector2} q2 [, {Vector2[]} r])

Arguments

{Vector2} p0

The first point of the first triangle

{Vector2} p1

The second point of the first triangle

{Vector2} p2

The third point of the first triangle

{Vector2} q0

The first point of the second triangle

{Vector2} q1

The second point of the second triangle

{Vector2} q2

The third point of the second triangle

{Vector2[]} r optional

The intersection point(s) References the intersection point(s) if triangles intersect

Returns

{boolean}

#constructor(p0, p1, p2)277-293

Creates a new instance

Signature

{undefined} Triangle2#constructor([{Vector2} p0 [, {Vector2} p1 [, {Vector2} p2]]])

Arguments

{Vector2} p0 optional

The first point

{Vector2} p1 optional

The second point

{Vector2} p2 optional

The third point

Returns

No return value

#p0282-282

The first point

Signature

{Vector2} Triangle2#p0

#p1287-287

The second point

Signature

{Vector2} Triangle2#p1

#p2292-292

The third point

Signature

{Vector2} Triangle2#p2

#define(p0, p1, p2)303-307

Redefines the instance

Signature

{Triangle2} Triangle2#define([{Vector2} p0 [, {Vector2} p1 [, {Vector2} p2]]])

Arguments

{Vector2} p0 optional

The first point

{Vector2} p1 optional

The second point

{Vector2} p2 optional

The third point

Returns

{Triangle2}

#orientation314-320

CW (1) if the instance is cw rotated, CCW (-1) if the instance is ccw rotated, DEGENERATE (0) if the instance is degenerate

Signature

{int} Triangle2#orientation

#centroid326-328

The dereferenced centroid point

Signature

{Vector2} Triangle2#centroid

#circumcenter334-336

The dereferenced center of the enclosing circle

Signature

{Vector2} Triangle2#circumcenter

#area342-344

The area (1/2)|AB x AC|

Signature

{number} Triangle2#area

#intersectsPoint(q, uv)355-357

Returns true if the instance intersects with point (q), false otherwise Alias of Triangle2.intersectPoint

Signature

{boolean} Triangle2#intersectsPoint({Vector2} q [, {number[]} uv])

Arguments

{Vector2} q

The point

{number[]} uv optional

Array holding the barycentric (u,v) coordinates References the barycentric intersection coordinates(u,v) if primitives intersect

Returns

{boolean}

#intersectsSegment(q0, q1, r)368-370

Returns true if the instance intersects with segment (q0,q1), false otherwise Alias of Triangle2.intersectSegment

Signature

{boolean} Triangle2#intersectsSegment({Vector2} q0, {Vector2} q1 [, {Vector2[]} r])

Arguments

{Vector2} q0

The first point of the segment

{Vector2} q1

The second point of the segment

{Vector2[]} r optional

The intersection point(s) References the intersection points if instances intersect

Returns

{boolean}

#intersects(triangle, point)380-382

Returns true if the instance intersects with triangle, false otherwise Alias of Triangle2.intersect

Signature

{boolean} Triangle2#intersects({Triangle2} triangle [, {Vector2[]} point])

Arguments

{Triangle2} triangle

The opposing Triangle

{Vector2[]} point optional

The intersection point(s) References the intersection points if instances intersect

Returns

{boolean}

#transformationOf(triangle, transform)391-397

The transformation of triangle

Signature

{Triangle2} Triangle2#transformationOf({Triangle2} triangle, {Matrix3} transform)

Arguments

{Triangle2} triangle

The source

{Matrix3} transform

The transform

Returns

{Triangle2}

#copyOf(triangle)404-410

The copy of triangle

Signature

{Triangle2} Triangle2#copyOf({Triangle2} triangle)

Arguments

{Triangle2} triangle

The source

Returns

{Triangle2}

#transformation(transform)418-420

The transformation of the instance

Signature

{Triangle2} Triangle2#transformation({Matrix3} transform)

Arguments

{Matrix3} transform

The transform

Returns

{Triangle2}

#toString(digits)428-433

Returns a string representation of the instance

Signature

{string} Triangle2#toString([{int} digits=3])

Arguments

{int} digits optionaldefault3

The decimal places

Returns

{string}

/source/TriangleSubdivisionTree.js:TriangleSubdivisionTree217-404

Delaunay triangulation subdivision tree

Import

import { TriangleSubdivisionTree } from 'twodee/source/TriangleSubdivisionTree.js'

#constructor(boundary)223-244

Creates a new instance

Signature

{undefined} TriangleSubdivisionTree#constructor({Triangle2} boundary)

Arguments

{Triangle2} boundary

The boundary triangle

Returns

No return value

#poly251-268

Returns a dereferenced polygon representing the subdivision state

Signature

{} TriangleSubdivisionTree#poly

#intersectsPoint(q)276-302

Returns the intersection face and barycentric coordinate if q intersects with the subdivision tree, null otherwise

Signature

{null|Object} TriangleSubdivisionTree#intersectsPoint({Vector2} q)

Arguments

{Vector2} q

The point

Returns

{null|Object}

#testEdge(face0, edge)310-320

Returns true if edge is the optimal edge for the quad of face0 and the face opposite of edge, false otherwise

Signature

{boolean} TriangleSubdivisionTree#testEdge({int} face0, {int} edge)

Arguments

{int} face0

The face index of the first face

{int} edge

The edge index of the edge

Returns

{boolean}

#addPoint(point)327-359

Adds a point to the subdivision mesh

Signature

{undefined} TriangleSubdivisionTree#addPoint({Vector2} point)

Arguments

{Vector2} point

The point

Returns

No return value

#addPoints(points)365-367

Adds points to the subdivision mesh

Signature

{undefined} TriangleSubdivisionTree#addPoints({Vector2[]} points)

Arguments

{Vector2[]} points

The points

Returns

No return value

#intersectOutline(outline)374-403

Intersects outline with the subdivision mesh

Signature

{undefined} TriangleSubdivisionTree#intersectOutline({PolyLine2} outline)

Arguments

{PolyLine2} outline

The outline

Returns

No return value