Point2

class Point2()

Constructors

Point2.constructor()
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

Point2.x
x: number
Point2.y
y: number

Methods

Point2.add()
add(pt: Point2): this

Adds a point to this one

Parameters

pt: Point2

the point whose values will be added

Returns: this

the point object
Point2.assign()
assign(pt: Point2): this

Sets this point equal to another point

Parameters

pt: Point2

the point whose values will be used to set this object

Returns: this

the point object
Point2.copy()
copy(): Point2

Creates a copy of this point

Returns: Point2

Copy of this point
Point2.equals()
equals(pt: Point2): boolean

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.
Point2.length()
length(): number

Returns the length of this point

Returns: number

the point length
Point2.scale()
scale(k: number): this

Scales the point by a constant value

Parameters

k: number

the value to scale by

Returns: this

the point object
Point2.set()
set(x: number, y: number): this

Sets the values of this point

Parameters

x: number

value to set for x

y: number

value to set for y

Returns: this

the point object
Point2.squaredLength()
squaredLength(): number

Returns the squared length of this vector.

Returns: number

Vector squared length.
Point2.subtract()
subtract(pt: Point2): this

Subtracts a point from this one

Parameters

pt: Point2

the point whose values will be subtracted

Returns: this

the point object
Point2.toJson()
toJson(): IPoint2

Creates an object ready for JSON serialization.

Returns: IPoint2

The prepared object.
static Point2.add()

static

add(pt1: Point2, pt2: Point2): Point2

Adds two points

Parameters

pt1: Point2

initial point

pt2: Point2

the point to add

Returns: Point2

new point set to pt1 + pt2
static Point2.distance()

static

distance(p1: Point2, p2: Point2): number

Calculate distance between two points

Parameters

p1: Point2

first point

p2: Point2

second point

Returns: number

the distance between p1 and p2
static Point2.fromJson()

static

fromJson(objData: unknown): Point2

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

Parameters

objData: unknown

An object given by [[toJson]].

Returns: Point2

The prepared object.
static Point2.fromPoint3()

static

fromPoint3(p: IPoint3): Point2

Parameters

Returns: Point2

static Point2.scale()

static

scale(pt: Point2, k: number): Point2

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 Point2.subtract()

static

subtract(pt1: Point2, pt2: Point2): Point2

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 Point2.zero()

static

zero(): Point2

Creates a point initialized to (0,0)

Returns: Point2

The new point