modeling/maths/line2

Represents a unbounded line in 2D space, positioned at a point of origin.

Source:
See:
  • line2 for data structure information.

Methods

(static) clone(line) → {line2}

Source:

Create a clone of the given line.

Parameters:
Name Type Description
line line2

line to clone

Returns:

a new unbounded line

Type
line2

(static) closestPoint(line, point) → {vec2}

Source:

Determine the closest point on the given line to the given point.

Parameters:
Name Type Description
line line2

line of reference

point vec2

point of reference

Returns:

closest point

Type
vec2

(static) copy(out, line) → {line2}

Source:

Copy the given line to the receiving line.

Parameters:
Name Type Description
out line2

receiving line

line line2

line to copy

Returns:

out

Type
line2

(static) create() → {line2}

Source:

Create a line, positioned at 0,0, and running along the X axis.

Returns:

a new unbounded line

Type
line2

(static) direction(line) → {vec2}

Source:

Return the direction of the given line.

Parameters:
Name Type Description
line line2

line of reference

Returns:

a vector in the direction of the line

Type
vec2

(static) distanceToPoint(line, point) → {Number}

Source:

Calculate the distance (positive) between the given point and line.

Parameters:
Name Type Description
line line2

line of reference

point vec2

point of reference

Returns:

distance between line and point

Type
Number

(static) equals(a, b) → {Boolean}

Source:

Compare the given lines for equality.

Parameters:
Name Type Description
a line2

first line to compare

b line2

second line to compare

Returns:

true if lines are equal

Type
Boolean

(static) fromPoints(out, point1, point2) → {line2}

Source:

Create a new line that passes through the given points.

Parameters:
Name Type Description
out line2

receiving line

point1 vec2

start point of the line

point2 vec2

end point of the line

Returns:

a new unbounded line

Type
line2

(static) fromValues(x, y, d) → {line2}

Source:

Creates a new line initialized with the given values.

Parameters:
Name Type Description
x Number

X coordinate of the unit normal

y Number

Y coordinate of the unit normal

d Number

distance of the line from [0,0]

Returns:

a new unbounded line

Type
line2

(static) intersectPointOfLines(line1, line2) → {vec2}

Source:

Return the point of intersection between the given lines.

NOTES: The point will have Infinity values if the lines are paralell. The point will have NaN values if the lines are the same.

Parameters:
Name Type Description
line1 line2

line of reference

line2 line2

line of reference

Returns:

the point of intersection

Type
vec2

(static) origin(line) → {vec2}

Source:

Return the origin of the given line.

Parameters:
Name Type Description
line line2

line of reference

Returns:

the origin of the line

Type
vec2

(static) reverse(out, line) → {line2}

Source:

Create a new line in the opposite direction as the given.

Parameters:
Name Type Description
out line2

receiving line

line line2

line to reverse

Returns:

out

Type
line2

(static) toString(line) → {String}

Source:

Return a string representing the given line.

Parameters:
Name Type Description
line line2

line of reference

Returns:

string representation

Type
String

(static) transform(out, line, matrix) → {line2}

Source:

Transforms the given line using the given matrix.

Parameters:
Name Type Description
out line2

receiving line

line line2

line to transform

matrix mat4

matrix to transform with

Returns:

out

Type
line2

(static) xAtY(line, y) → {Number}

Source:

Determine the X coordinate of the given line at the Y coordinate.

The X coordinate will be Infinity if the line is parallel to the X axis.

Parameters:
Name Type Description
line line2

line of reference

y Number

Y coordinate on the line

Returns:

the X coordinate on the line

Type
Number