Point2

class Communicator.Point2()

Constructors

Properties


Constructors

constructor

Communicator.Point2.constructor(x, y)

Creates a new point

Arguments
  • x (number()) –

  • y (number()) –

Return type

Communicator.Point2

Properties

Communicator.Point2.x
Communicator.Point2.y

Methods

add

Communicator.Point2.add(pt1, pt2)

Adds two points

Arguments
Return type

Communicator.Point2

Returns

new point set to pt1 + pt2

assign

Communicator.Point2.assign(pt)

Sets this point equal to another point

Arguments
Return type

Communicator.Point2

Returns

the point object

copy

Communicator.Point2.copy()

Creates a copy of this point

Return type

Communicator.Point2

Returns

Copy of this point

equals

Communicator.Point2.equals(pt)

Compares this point with another point

Arguments
Return type

boolean

Returns

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

forJson

Communicator.Point2.forJson()

Note

forJson is deprecated: Use toJson instead.

Return type

Object

length

Communicator.Point2.length()

Returns the length of this point

Return type

number

Returns

the point length

scale

Communicator.Point2.scale(pt, k)

Scale a point by a constant factor

Arguments
Return type

Communicator.Point2

Returns

The scaled point

set

Communicator.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

Communicator.Point2

Returns

the point object

squaredLength

Communicator.Point2.squaredLength()

Returns the squared length of this vector.

Return type

number

Returns

Vector squared length.

subtract

Communicator.Point2.subtract(pt1, pt2)

Subtracts a point from another

Arguments
Return type

Communicator.Point2

Returns

new point set to pt1 - pt2

toJson

Communicator.Point2.toJson()

Creates an object ready for JSON serialization.

Return type

Object

Returns

The prepared object.

distance

Communicator.Point2.distance(p1, p2)

Calculate distance between two points

Arguments
Return type

number

Returns

the distance between p1 and p2

fromJson

Communicator.Point2.fromJson(objData)

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

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

Return type

Communicator.Point2

Returns

The prepared object.

fromPoint3

Communicator.Point2.fromPoint3(p)
Arguments
Return type

Communicator.Point2

zero

Communicator.Point2.zero()

Creates a point initialized to (0,0)

Return type

Communicator.Point2

Returns

The new point