Point3

class Point3()

Constructors

Point3.constructor()
Point3(x: number, y: number, z: number): Point3

Creates a new point object.

Parameters

x: number

X value

y: number

Y value

z: number

Z value

Returns: Point3

Properties

Point3.x
x: number
Point3.y
y: number
Point3.z
z: number

Methods

Point3.add()
add(pt: IPoint3): this

Adds another point to this point.

Parameters

Returns: this

This point object.
Point3.assign()
assign(point: IPoint3): this

Sets this point equal to another point.

Parameters

point: IPoint3

The point to assign.

Returns: this

This point object.
Point3.copy()
copy(): Point3

Creates a copy of this point.

Returns: Point3

Copy of this point object.
Point3.equals()
equals(other: IPoint3): boolean

Strictly compares this point with another.

Parameters

other: IPoint3

Point to compare with.

Returns: boolean

True if the values of this point equal those of the other.
Point3.equalsWithTolerance()
equalsWithTolerance(other: IPoint3, tolerance: number): boolean

Compares this point with another using a tolerance.

Parameters

other: IPoint3

Point to compare with.

tolerance: number

Tolerance to be used in the comparison.

Returns: boolean

True if the values of this point equal those of the other.
Point3.fromArray()
fromArray(arr: number[]): this

Sets this point from an array.

Parameters

arr: number[]

Array to assign from.

Returns: this

This point object.
Point3.isAxis()
isAxis(): boolean

Returns a boolean value indicating if this vector lies on a major axis.

Returns: boolean

Point3.length()
length(): number

Returns the length of this vector.

Returns: number

Vector length.
Point3.negate()
negate(): this

Negates the point.

Returns: this

This object.
Point3.normalize()
normalize(): this

Normalizes the vector.

Returns: this

This object.
Point3.scale()
scale(k: number): this

Scale the point by constant value.

Parameters

k: number

Constant value to scale by.

Returns: this

Point object.
Point3.set()
set(x: number, y: number, z: number): this

Sets the values of this point.

Parameters

x: number

X value to set.

y: number

Y value to set.

z: number

Z value to set.

Returns: this

This point object.
Point3.squaredLength()
squaredLength(): number

Returns the squared length of this vector.

Returns: number

Vector squared length.
Point3.subtract()
subtract(pt: IPoint3): this

Subtracts another point from this point.

Parameters

Returns: this

This point object.
Point3.toArray()
toArray(arr: number[]?): number[]

Sets an array from this point.

Parameters

arr: number[] = …

Array to assign.

Returns: number[]

Point3.toJson()
toJson(): IPoint3

Creates an object ready for JSON serialization.

Returns: IPoint3

The prepared object.
static Point3.add()

static

add(p1: IPoint3, p2: IPoint3): Point3

Adds two points.

Parameters

p1: IPoint3

First point.

p2: IPoint3

Second point.

Returns: Point3

Sum of p1 and p2.
static Point3.createFromArray()

static

createFromArray(arr: number[]): Point3

Creates a point from an array of numbers

Parameters

arr: number[]

Returns: Point3

new point set from array elements
static Point3.cross()

static

cross(p1: IPoint3, p2: IPoint3): Point3

Calculate cross product.

Parameters

p1: IPoint3

First point.

p2: IPoint3

Second point.

Returns: Point3

Cross product of p1 and p2.
static Point3.distance()

static

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

Calculate distance between two points

Parameters

p1: IPoint3

First point

p2: IPoint3

Second point

Returns: number

Distance between p1 and p2
static Point3.dot()

static

dot(p1: IPoint3, p2: IPoint3): number

Calculate dot product.

Parameters

p1: IPoint3

First point.

p2: IPoint3

Second point.

Returns: number

Dot product of p1 and p2.
static Point3.fromJson()

static

fromJson(objData: unknown): Point3

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

Parameters

objData: unknown

An object given by [[toJson]].

Returns: Point3

The prepared object.
static Point3.magnitude()

static

magnitude(p: IPoint3): number

Returns the length of a vector.

Parameters

Returns: number

Vector length.
static Point3.normalize()

static

normalize(v: IPoint3): Point3

Normalize a vector.

Parameters

v: IPoint3

First point.

Returns: Point3

A vector that is colinear to v with a length of 1.
static Point3.scale()

static

scale(p: IPoint3, k: number): Point3

Scale a point by a constant factor

Parameters

p: IPoint3

k: number

Constant value to scale byS

Returns: Point3

Copy of p scaled by a constant factor
static Point3.squaredLength()

static

squaredLength(p: IPoint3): number

Returns the squared length of a vector.

Parameters

Returns: number

Vector squared length.
static Point3.subtract()

static

subtract(p1: IPoint3, p2: IPoint3): Point3

Subtract two points.

Parameters

p1: IPoint3

First point.

p2: IPoint3

Second point.

Returns: Point3

Difference of p1 and p2.
static Point3.zero()

static

zero(): Point3

Creates a new Point initialized to (0,0,0).

Returns: Point3

New point with all elements set to 0.