# Namespace: Math2D

# Table of contents

# Classes

# Interfaces

# Functions

# Functions

# computeSquaredLineLength

computeSquaredLineLength(line: number[]): number

Computes the squared length of a line.

# Parameters
Name Type Description
line number[] An array of that forms a line via [x,y,z,x,y,z,...] tuples.

Returns: number


# dist

dist(ax: number, ay: number, bx: number, by: number, az?: number, bz?: number): number

Compute distance between two 2D points a and b.

# Parameters
Name Type Description
ax number Point a.x
ay number Point a.y
bx number Point b.x
by number Point b.y
az? number
bz? number

Returns: number

between the two points


# distSquared

distSquared(ax: number, ay: number, bx: number, by: number): number

Compute squared distance between two 2D points a and b.

# Parameters
Name Type Description
ax number Point a.x
ay number Point a.y
bx number Point b.x
by number Point b.y

Returns: number

Squared distance between the two points


# distToSegmentSquared

distToSegmentSquared(px: number, py: number, l0x: number, l0y: number, l1x: number, l1y: number): number

Compute squared distance between a 2D point and a 2D line segment.

# Parameters
Name Type Description
px number Test point X
py number Test point y
l0x number Line segment start X
l0y number Line segment start Y
l1x number Line segment end X
l1y number Line segment end Y

Returns: number

Squared distance between point and line segment


# intersectLineAndCircle

intersectLineAndCircle(xLine1: number, yLine1: number, xLine2: number, yLine2: number, radius: number, xCenter?: number, yCenter?: number): { x1: number ; x2?: number ; y1: number ; y2?: number } | undefined

Finds the intersections of a line and a circle.

# Parameters
Name Type Default value Description
xLine1 number - abscissa of first line point.
yLine1 number - ordinate of second line point.
xLine2 number - abscissa of second line point.
yLine2 number - ordinate of second line point.
radius number - circle radius.
xCenter number 0 abscissa of circle center.
yCenter number 0 ordinate of circle center.

Returns: { x1: number ; x2?: number ; y1: number ; y2?: number } | undefined

coordinates of the intersections (1 if the line is tangent to the circle, 2 if it's secant) or undefined if there's no intersection.


# intersectLines

intersectLines(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, result?: Vec2Like): Vec2Like | undefined

Computes the intersection point between two lines.

remarks This functions computes the line-line intersection (opens new window) of two lines given two points on each line.

# Parameters
Name Type Description
x1 number x coordinate of the first point of the first line.
y1 number y coordinate of the first point of the first line.
x2 number x coordinate of the second point of the first line.
y2 number y coordinate of the second point of the first line.
x3 number x coordinate of the first point of the second line.
y3 number y coordinate of the first point of the second line.
x4 number x coordinate of the second point of the second line.
y4 number y coordinate of the second point of the second line.
result Vec2Like The resulting point.

Returns: Vec2Like | undefined


# lineDist

lineDist(pts: GeoPointLike[]): number

求线的距离

# Parameters
Name Type
pts GeoPointLike[]

Returns: number

vjmap / Exports / MathUtils