Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Line

Hierarchy

Implements

Index

Constructors

constructor

  • new Line(): Line
  • new Line(x1: number, y1: number, x2: number, y2: number): Line
  • Returns Line

  • Parameters

    • x1: number
    • y1: number
    • x2: number
    • y2: number

    Returns Line

Properties

x1

x1: number

x2

x2: number

y1

y1: number

y2

y2: number

Static X

X: Line = new Line(0, 0, 1, 0)

Static Y

Y: Line = new Line(0, 0, 0, 1)

Methods

bounds

clone

  • clone(): this

crossLine

  • Returns a cross point of Line L. 求与直线的交点。

    Parameters

    Returns ArrayPoint2

    If this line is parallel to Line L, then return null.

crossPoint

  • Returns a vertical cross point with P. 求点P到直线的垂直交点。

    Parameters

    Returns ArrayPoint2

crossRay

  • crossRay(p: ArrayPoint2, rad: number): [number, number]
  • Returns a cross point of this line and Ray(p, rad). 直线与射线的交点。

    Parameters

    Returns [number, number]

    If the cross point is not exist, then return null.

equals

  • equals(s: Line): boolean
  • Parameters

    Returns boolean

inside

intersects

isEmpty

  • isEmpty(): boolean

onside

p1

  • Returns ArrayPoint2

  • Parameters

    • x: number
    • y: number

    Returns this

p2

  • Returns ArrayPoint2

  • Parameters

    • x: number
    • y: number

    Returns this

perimeter

  • perimeter(): number

set

slope

  • slope(): number
  • 斜率

    Returns number

toSegment

toVector

vertexes

Static distanceSqToPoint

  • Returns the square of the distance from a point to a line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by the specified coordinates. If the specified point intersects the line, this method returns 0.0.

    Parameters

    Returns number

    a value that is the square of the distance from the specified point to the specified line.

Static distanceToPoint

  • Returns the distance from a point to a line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by the specified coordinates. If the specified point intersects the line, this method returns 0.0.

    Parameters

    Returns number

    a value that is the distance from the specified point to the specified line.

Static isCollinear

Static isCollinearLine

  • Line is collinear with Line2. 两直线或线段是否共线

    Parameters

    Returns boolean

Static position

  • Returns the relation position of Line1(p1,p2) and Line2(p3,p4). 直线1与直线2的位置关系。

    Parameters

    Returns number

    -1 is Parallel and Non-Collinear; 0 is Collinear; 1 is Cross and Non-Vertical; 2 is Cross and Vertical.

Static slope

  • Caculate the slope of Segment P1P2. 计算线段(p1,p2)的斜率。当线段与X轴垂直时,斜率不存在

    Parameters

    Returns number

    when P1P2 is vertical to the X, then return null.

Static toLine