Point2

class Point2()

Constructors

Properties


Constructors

Point2.constructor(x, y)
Arguments
  • x (number()) – value to set for x

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

Creates a new point

Return type

Point2

Properties

Point2.x
Type

number

Point2.y
Type

number

Methods

static add

Point2.add(pt1, pt2)
Arguments

Adds two points

Returns

new point set to pt1 + pt2

Return type

Point2

assign

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

Sets this point equal to another point

Returns

the point object

Return type

this

copy

Point2.copy()

Creates a copy of this point

Returns

Copy of this point

Return type

Point2

equals

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

Compares this point with another point

Returns

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

Return type

boolean

length

Point2.length()

Returns the length of this point

Returns

the point length

Return type

number

static scale

Point2.scale(pt, k)
Arguments
  • pt (Point2()) – Point to be scaled

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

Scale a point by a constant factor

Returns

The scaled point

Return type

Point2

set

Point2.set(x, y)
Arguments
  • x (number()) – value to set for x

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

Sets the values of this point

Returns

the point object

Return type

this

squaredLength

Point2.squaredLength()

Returns the squared length of this vector.

Returns

Vector squared length.

Return type

number

static subtract

Point2.subtract(pt1, pt2)
Arguments

Subtracts a point from another

Returns

new point set to pt1 - pt2

Return type

Point2

toJson

Point2.toJson()

Creates an object ready for JSON serialization.

Returns

The prepared object.

Return type

IPoint2

static distance

Point2.distance(p1, p2)
Arguments

Calculate distance between two points

Returns

the distance between p1 and p2

Return type

number

static fromJson

Point2.fromJson(objData)
Arguments
  • objData (unknown()) – An object given by [[toJson]].

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

Returns

The prepared object.

Return type

Point2

static fromPoint3

Point2.fromPoint3(p)
Arguments
Return type

Point2

static zero

Point2.zero()

Creates a point initialized to (0,0)

Returns

The new point

Return type

Point2