Point2

class Communicator.Point2()

Constructors

Properties


Constructors

Point2.constructor(x, y)

Creates a new point

Arguments
  • x (number()) –

  • y (number()) –

Return type

Point2()

Properties

Point2.x
Type

number

Point2.y
Type

number

Methods

static add

Point2.add(pt1, pt2)

Adds two points

Arguments
Return type

Point2()

Returns

new point set to pt1 + pt2

assign

Point2.assign(pt)

Sets this point equal to another point

Arguments
  • pt (Point2()) – the point whose values will be used to set this object

Return type

Point2()

Returns

the point object

copy

Point2.copy()

Creates a copy of this point

Return type

Point2()

Returns

Copy of this point

equals

Point2.equals(pt)

Compares this point with another point

Arguments
  • pt (Point2()) – the point to compare with

Return type

boolean

Returns

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

forJson

Point2.forJson()
Deprecated

Use toJson instead.

Return type

Object

length

Point2.length()

Returns the length of this point

Return type

number

Returns

the point length

static scale

Point2.scale(pt, k)

Scale a point by a constant factor

Arguments
  • pt (Point2()) – Point to be scaled

  • k (number()) – Amount to scale by

Return type

Point2()

Returns

The scaled point

set

Point2.set(x, y)

Sets the values of this point

Arguments
  • x (number()) – value to set for x

  • y (number()) – value to set for y

Return type

Point2()

Returns

the point object

squaredLength

Point2.squaredLength()

Returns the squared length of this vector.

Return type

number

Returns

Vector squared length.

static subtract

Point2.subtract(pt1, pt2)

Subtracts a point from another

Arguments
Return type

Point2()

Returns

new point set to pt1 - pt2

toJson

Point2.toJson()

Creates an object ready for JSON serialization.

Return type

Object

Returns

The prepared object.

static distance

Point2.distance(p1, p2)

Calculate distance between two points

Arguments
Return type

number

Returns

the distance between p1 and p2

static fromJson

Point2.fromJson(objData)

Creates a new [[Point2]] from an object given by toJson

Arguments
  • objData (any()) – An object given by toJson

Return type

Point2()

Returns

The prepared object.

static fromPoint3

Point2.fromPoint3(p)
Arguments
Return type

Point2()

static zero

Point2.zero()

Creates a point initialized to (0,0)

Return type

Point2()

Returns

The new point