Communicator.Point2

 Point2

Constructors

constructor

  • new Point2(x: number, y: number): Point2
  • Creates a new point

    Parameters

    • x: number

      value to set for x

    • y: number

      value to set for y

    Returns Point2

Properties

x

x: number

y

y: number

Methods

add

  • Adds a point to this one

    Parameters

    • pt: Point2

      the point whose values will be added

    Returns Point2

    the point object

assign

  • Sets this point equal to another point

    Parameters

    • pt: Point2

      the point whose values will be used to set this object

    Returns Point2

    the point object

copy

  • Creates a copy of this point

    Returns Point2

    Copy of this point

equals

  • Compares this point with another point

    Parameters

    • pt: Point2

      the point to compare with

    Returns boolean

    True if the values of this point equal the other. False otherwise.

forJson    [deprecated]

  • forJson(): Object
  • deprecated

    Use toJson instead.

    Returns Object

length

  • length(): number
  • Returns the length of this point

    Returns number

    the point length

scale

  • Scales the point by a constant value

    Parameters

    • k: number

      the value to scale by

    Returns Point2

    the point object

set

  • set(x: number, y: number): Point2
  • Sets the values of this point

    Parameters

    • x: number

      value to set for x

    • y: number

      value to set for y

    Returns Point2

    the point object

squaredLength

  • squaredLength(): number
  • Returns the squared length of this vector.

    Returns number

    Vector squared length.

subtract

  • Subtracts a point from this one

    Parameters

    • pt: Point2

      the point whose values will be subtracted

    Returns Point2

    the point object

toJson

  • toJson(): Object
  • Creates an object ready for JSON serialization.

    Returns Object

    The prepared object.

Static add

  • Adds two points

    Parameters

    Returns Point2

    new point set to pt1 + pt2

Static distance

  • Calculate distance between two points

    Parameters

    Returns number

    the distance between p1 and p2

Static fromJson

  • fromJson(objData: any): Point2
  • Creates a new Point2 from an object given by toJson.

    Parameters

    • objData: any

      An object given by toJson.

    Returns Point2

    The prepared object.

Static fromPoint3

Static scale

  • Scale a point by a constant factor

    Parameters

    • pt: Point2

      Point to be scaled

    • k: number

      Amount to scale by

    Returns Point2

    The scaled point

Static subtract

  • Subtracts a point from another

    Parameters

    • pt1: Point2

      initial point

    • pt2: Point2

      the point to subtract

    Returns Point2

    new point set to pt1 - pt2

Static zero

  • Creates a point initialized to (0,0)

    Returns Point2

    The new point