diff --git a/docs/Line.html b/docs/Line.html index bdd74ad..1908364 100644 --- a/docs/Line.html +++ b/docs/Line.html @@ -1,3 +1,3 @@ Class: Line
On this page

Line

Class representing a line.

Constructor

new Line(a, b)

Create a line between two Vectors.

Parameters:
NameTypeAttributesDefaultDescription
aVector

The startpoint.

bVector

The endpoint.

options.strokestring<optional>
"black"
options.strokeWidthnumber<optional>
0.1

Classes

Line

Methods

intersects(target) → {boolean|Array}

Check if this line intersects another shape. Currently only Line is supported.

Parameters:
NameTypeDescription
targetobject

The target.

Returns:
  • False if lines don't intersect, otherwise returns the intersection point [x,y]
Type: 
boolean | Array

isContainedBy(line) → {boolean}

Check if this line lies directly on top of a longer line.

Parameters:
NameTypeDescription
lineLine

The target line to check against.

Returns:
  • True if this line's startpoint and endpoint are both on the line being checked against, otherwise False.
Type: 
boolean

isDuplicate(line) → {boolean}

Check if this line is the same as another line.

Parameters:
NameTypeDescription
lineLine

The target line to compare to.

Returns:

True if startpoints and endpoints are identical or in reverse.

Type: 
boolean

length() → {number}

Get the length.

Returns:

The distance from the startpoint to the endpoint. Uses the Vector#distance method.

Type: 
number

toSVGElement() → {SVGElement}

Returns:
Type: 
SVGElement

(static) fromArray(array) → {Line}

Create a Line from an array of numbers.

Parameters:
NameTypeDescription
arrayArray.<number>

[x1, y1, x2, y2].

Returns:
Type: 
Line

(static) lineIntersection(line1, line2) → {boolean|Array}

Check if two lines intersect.

Parameters:
NameTypeDescription
line1Line
line2Line
Returns:
  • False if lines don't intersect, otherwise returns the intersection point [x,y]
Type: 
boolean | Array
Penplotting.js
\ No newline at end of file +
On this page

Line

Class representing a line.

Constructor

new Line(a, b)

Create a line between two Vectors.

Parameters:
NameTypeAttributesDefaultDescription
aVector

The startpoint.

bVector

The endpoint.

options.strokestring<optional>
"black"
options.strokeWidthnumber<optional>
0.1

Classes

Line

Methods

intersects(target) → {boolean|Array}

Check if this line intersects another shape. Currently only Line is supported.

Parameters:
NameTypeDescription
targetobject

The target.

Returns:
  • False if lines don't intersect, otherwise returns the intersection point [x,y]
Type: 
boolean | Array

isContainedBy(line) → {boolean}

Check if this line lies directly on top of a longer line.

Parameters:
NameTypeDescription
lineLine

The target line to check against.

Returns:
  • True if this line's startpoint and endpoint are both on the line being checked against, otherwise False.
Type: 
boolean

isDuplicate(line) → {boolean}

Check if this line is the same as another line.

Parameters:
NameTypeDescription
lineLine

The target line to compare to.

Returns:

True if startpoints and endpoints are identical or in reverse.

Type: 
boolean

length() → {number}

Get the length.

Returns:

The distance from the startpoint to the endpoint. Uses the Vector#distance method.

Type: 
number

toSVGElement() → {SVGElement}

Returns:
Type: 
SVGElement

(static) fromArray(array) → {Line}

Create a Line from an array of numbers.

Parameters:
NameTypeDescription
arrayArray.<number>

[x1, y1, x2, y2].

Returns:
Type: 
Line

(static) lineIntersection(line1, line2) → {boolean|Vector}

Check if two lines intersect.

Parameters:
NameTypeDescription
line1Line
line2Line
Returns:
  • False if lines don't intersect, otherwise returns the intersection point as a Vector.
Type: 
boolean | Vector
Penplotting.js
\ No newline at end of file diff --git a/docs/Line.js.html b/docs/Line.js.html index c2f3ef7..e872b83 100644 --- a/docs/Line.js.html +++ b/docs/Line.js.html @@ -68,7 +68,7 @@ * Check if two lines intersect. * @param {Line} line1 * @param {Line} line2 - * @returns {(boolean|Array)} - False if lines don't intersect, otherwise returns the intersection point [x,y] + * @returns {(boolean|Vector)} - False if lines don't intersect, otherwise returns the intersection point as a {@link Vector}. */ static lineIntersection(line1, line2) { const x1 = line1.a.x; @@ -95,7 +95,7 @@ if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) { const x = x1 + ua * (x2 - x1); const y = y1 + ua * (y2 - y1); - return [x, y]; + return new Vector(x, y); } else { return false; }