Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Segment

Hierarchy

Implements

Index

Constructors

constructor

  • new Segment(): Segment
  • new Segment(x1: number, y1: number, x2: number, y2: number): Segment

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 segment is parallel to Line L, then return null.

crossPoint

crossRay

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

    Parameters

    Returns [number, number]

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

crossSegment

  • Returns a cross point with a segment. 求与线段的交点。

    Parameters

    Returns ArrayPoint2

equals

  • equals(s: Segment, isStrict?: boolean): boolean
  • Parameters

    • s: Segment
    • Optional isStrict: boolean

    Returns boolean

inside

intersects

isEmpty

  • isEmpty(): boolean

midPoint

  • midPoint(): [number, number]
  • Returns the middle point of Segment P1P2. 返回线段的中点

    Returns [number, number]

onside

p1

p2

perimeter

  • perimeter(): number

ratioPoint

  • Returns the ratio point of this segment. 定比分点公式

    Parameters

    • ratio: number

      Must not equals -1.

    Returns ArrayPoint2

set

slope

  • slope(): number
  • 斜率

    Returns number

toLine

toSegment

toVector

vertexes

Static distanceSqToPoint

  • Returns the square of the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, 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 segment.

Static distanceToPoint

  • Returns the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.

    Parameters

    Returns number

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

Static inSegment

Static intersect

  • Tests if the line segment from p1 to p2 intersects the line segment from p3 to p4.

    Parameters

    Returns boolean

    true if the first specified line segment and the second specified line segment intersect each other; false otherwise.

Static isCollinear

Static isCollinearLine

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

Static toSegment