Constructor
new Line(start, end)
Creates a new Line object from two points.
- Source
Classes
Members
end
The ending point of the line as Point2D.
- Source
end
The ending point of the line as Point2D.
- Source
length
Returns the length of the line.
- Source
start
The starting point of the line as Point2D.
- Source
start
The starting point of the line as Point2D.
- Source
vector_object_builder
Gets a VectorObjectBuilder with the line's points.
- Source
Methods
contains(point) → {boolean}
Returns whether the line contains a given Point2D.
Name | Type | Description |
---|---|---|
point | Point2D | The point to check if it is contained. |
- Source
Whether the line contains the given point.
- Type:
- boolean
distance_to_point(point) → {number}
Returns the distance from the line to a given Point2D.
Name | Type | Description |
---|---|---|
point | Point2D | The point to calculate the distance to. |
- Source
The distance from the line to the given point.
- Type:
- number
intersection(other) → {Point2D|undefined}
Returns the intersection Point2D of the line with another line, if it exists.
Name | Type | Description |
---|---|---|
other | Line | The other line to intersect with. |
- Source
The intersection point of the two lines if it exists.
- Type:
- Point2D |
undefined
midpoint() → {Point2D}
Returns the midpoint of the line as a Point2D.
- Source
The midpoint of the line.
- Type:
- Point2D
normal_slope() → {number}
Returns the normal slope of the line.
- Source
The normal slope of the line.
- Type:
- number
perpendicular_line(point) → {Line}
Returns the perpendicular line of the line at a given Point2D.
Name | Type | Description |
---|---|---|
point | Point2D | The point to create the perpendicular line at. |
- Source
The perpendicular line of the line at the given point.
- Type:
- Line
slope() → {number}
Returns the slope of the line.
- Source
The slope of the line.
- Type:
- number
with_tip_at_the_end(tip_shape) → {VectorObjectBuilder}
Creates a VectorObjectBuilder with the line's points and a tip at the end.
Name | Type | Description |
---|---|---|
tip_shape | VectorObjectBuilder | The shape of the tip. The shape must be pointing to the right and centered to (0, 0), this function will rotate and move it to the correct angle. |
- Source
A VectorObjectBuilder with the line's points and a tip at the end.
- Type:
- VectorObjectBuilder
with_tip_at_the_start(tip_shape) → {VectorObjectBuilder}
Creates a VectorObjectBuilder with the line's points and a tip at the start.
Name | Type | Description |
---|---|---|
tip_shape | VectorObjectBuilder | The shape of the tip. The shape must be pointing to the right and centered to (0, 0), this function will rotate and move it to the correct angle. |
- Source
A VectorObjectBuilder with the line's points and a tip at the start.
- Type:
- VectorObjectBuilder
with_tips_at_both_ends(tip_shape) → {VectorObjectBuilder}
Creates a VectorObjectBuilder with the line's points and tips at both ends.
Name | Type | Description |
---|---|---|
tip_shape | VectorObjectBuilder | The shape of the tip. The shape must be pointing to the right, this function will rotate and move it to the correct angle. |
- Source
A VectorObjectBuilder with the line's points and tips at both ends.
- Type:
- VectorObjectBuilder
y_intercept() → {number}
Returns the y-intercept of the line.
- Source
The y-intercept of the line.
- Type:
- number