Line2D

interface Line2D<P : Vector2D<P>>(source)

Defines a straight line in a cartesian plane.

Inheritors

Properties

Link copied to clipboard
abstract val isHorizontal: Boolean

Indicates if the line is aligned to the x-axis.

Link copied to clipboard
abstract val isVertical: Boolean

Indicates if the line is aligned to the y-axis.

Link copied to clipboard
abstract val slope: Double

The slope of the line, if isVertical this is undefined (= Double.NaN).

Link copied to clipboard
abstract val xIntercept: Double

The x-coordinate of the x-intercept (= the point where the line intersects the x-axis). If isHorizontal there's no x-intercept and this is Double.NaN.

Link copied to clipboard
abstract val yIntercept: Double

The y-coordinate of the y-intercept (= the point where the line intersects the y-axis). If isVertical there's no y-intercept and this is Double.NaN. The slope-intercept representation (y = mx + b) uses this intercept.

Functions

Link copied to clipboard
abstract fun contains(point: P): Boolean

Checks if the point belongs to this line.

Link copied to clipboard
abstract fun findPoint(x: Double): P

Finds the point belonging to the line with the given x-coordinate. Throws an UnsupportedOperationException if the line isVertical.

Link copied to clipboard
abstract fun intersect(other: Line2D<P>): Intersection2D<P>

Intersects two lines.

Link copied to clipboard
abstract fun intersectCircle(center: P, radius: Double): Intersection2D<P>

Intersects a line and a circle.

Link copied to clipboard
abstract fun isParallelTo(other: Line2D<P>): Boolean

Checks if two lines are parallel.