Options
All
  • Public
  • Public/Protected
  • All
Menu

表示二维世界的一条线

Class representing a line in Two-dimensional coordinate system

Hierarchy

  • Line2

Index

Constructors

constructor

Properties

end

end: Vector2 = ...

线的终点

Ending point of line or segment

start

start: Vector2 = ...

线的起点

Starting point of line or segment

Accessors

angle

  • get angle(): number
  • 线的方向角度

    Gets the angle of the current line's direction (start -> end)

    Returns number

center

direction

leftDirection

length

  • get length(): number

lengthSq

  • get lengthSq(): number
  • 线段长度的平方

    Gets the squared length of the current line

    Returns number

rightDirection

  • 线的正交右方向

    Gets the direction orthogonal to the current line and pointing to the right

    Returns Vector2

Methods

getAlpha

  • getAlpha(point: Vector2, isSegment?: boolean): number
  • 计算点在线上的比例

    Gets the interpolated number

    Parameters

    • point: Vector2
    • isSegment: boolean = false

    Returns number

getDistance

  • getDistance(point: Vector2, isSegment?: boolean): number
  • 获取点到线的距离

    Gets the distance from the point to the current line

    Parameters

    • point: Vector2

      target point

    • isSegment: boolean = false

      Whether to treat the current line as a segment

    Returns number

getProjectedPoint

  • getProjectedPoint(point: Vector2, isSegment?: boolean, useSegmentEnd?: boolean): Vector2
  • 获取点在线上的投影点

    Gets the projected point of the point onto the current line

    Parameters

    • point: Vector2

      target point 目标点

    • isSegment: boolean = false

      Whether to treat the current line as a segment 是否线段

    • useSegmentEnd: boolean = false

      When the projection point is beyond the line segment, use the end of the line segment as the projection point (当投影点超出线段时,是否使用线段端点作为投影点)

    Returns Vector2

getSide

  • getSide(point: Vector2): LineSide
  • 获取点在线的哪一侧

    Gets which side of the current line the point is on

    Parameters

    Returns LineSide

    LineSide

interpolate

  • interpolate(alpha: number): Vector2
  • 根据线性比例计算线上的一点

    Gets linear interpolation between start and end of this line

    Parameters

    • alpha: number

    Returns Vector2

isHorizontal

  • isHorizontal(): boolean
  • 是否水平线

    Determine whether the current line is a horizontal line

    Returns boolean

isOrthogonal

  • isOrthogonal(line: Line2): boolean
  • 和 line 是否正交垂直

    Determine whether the current line and line area orthogonal

    Parameters

    Returns boolean

isParallel

  • isParallel(line: Line2): boolean
  • 和 line 是否平行

    Determine whether the current line and line area parallel

    Parameters

    Returns boolean

isPointOnLine

  • isPointOnLine(point: Vector2, tolerance?: number): boolean
  • 点是否在直线上

    Determines if the point is on the line

    Parameters

    • point: Vector2
    • tolerance: number = ...

    Returns boolean

isPointOnSegment

  • isPointOnSegment(point: Vector2, tolerance?: number): boolean
  • 点是否在线段上

    Determine if the point is on the segment

    Parameters

    • point: Vector2
    • tolerance: number = ...

    Returns boolean

isVertical

  • isVertical(): boolean
  • 是否竖直线

    Determine whether the current line is a vertical line

    Returns boolean

set

  • 设置起点和终点

    Sets the start and the end of this line

    Parameters

    • start: Vector2

      Starting point of line or segment

    • end: Vector2

      Ending point of line or segment

    Returns Line2

    当前实例 (This line)

setEnd

  • 设置终点

    Sets the end of this line

    Parameters

    • point: Vector2

      Ending point of line or segment

    Returns Line2

    当前实例 (This line)

setStart

  • 设置起点

    Sets the start of this line

    Parameters

    • point: Vector2

      Starting point of line or segment

    Returns Line2

    当前实例 (This line)

translate

Legend

  • Constructor
  • Property
  • Method
  • Static property
  • Static method
  • Property
  • Private property

Generated using TypeDoc