Options
All
• Public
• Public/Protected
• All

# Class Vector3

Defines a 3-component vector with X,Y,Z values

• Vector3

## Constructors

### constructor

• new Vector3(x: number, y: number, z: number): Vector3
• Creates a 3-component vector with X,Y,Z values

## Accessors

### length

• get length(): number
• Gets the euclidean length of the vector

### x

• get x(): number
• Gets the X-value

remarks

Warning! Treat Vector3 as immutable! Do not set this value but create new vectors if you need to change a value

### y

• get y(): number
• Gets the Y-value

remarks

Warning! Treat Vector3 as immutable! Do not set this value but create new vectors if you need to change a value

### z

• get z(): number
• Gets the Z-value

remarks

Warning! Treat Vector3 as immutable! Do not set this value but create new vectors if you need to change a value

### Static zero

• Returns a static shared zero vector where X,Y,Z = 0

## Methods

• Performs vector addition of this + other, returning the result in a new vector

description

An example can be found below

``````const firstVector = new Vector3(1,2,3);
const secondVector = new Vector3(1,1,1);
// Result is [2,3,4]``````

#### Parameters

• ##### other: Vector3

the vector to add to this vector

#### Returns Vector3

A new vector with the addition result

### crossProduct

• Performs vector cross product of this vector and another vector, returning the result in a new vector

description

An example can be found below

``````const firstVector = new Vector3(1,2,3);
const secondVector = new Vector3(4,5,6);
const result = firstVector.crossProduct(secondVector);
// Result is firstVector ^ (cross) secondVector``````

#### Parameters

• ##### rhs: Vector3

the other vector to apply to the right hand side of the cross product

#### Returns Vector3

A new vector with the cross product result

### dotProduct

• Performs vector dot product of this vector and another vector, returning the result as a scalar

#### Parameters

• ##### rhs: Vector3

the other vector to apply to the right hand side of the dot product

### normalize

• normalize(): void
• Normalizes the current vector by computing its X,Y,Z components which make the length = 1 but direction the same

remarks

This is the only operation which modifies the current vector (not immutable)

### scalarMultiply

• scalarMultiply(scalar: number): Vector3
• Performs scalar multiplication of this vector x scalar constant, returning the result in a new vector

description

An example can be found below

``````const firstVector = new Vector3(1,2,3);
const result = firstVector.scalarMultiply(2);
// Result is [2,4,6]``````

#### Returns Vector3

A new vector with the multiply result

### subtract

• Performs vector subtraction of this - other, returning the result in a new vector

description

An example can be found below

``````const firstVector = new Vector3(1,2,3);
const secondVector = new Vector3(1,1,1);
const result = firstVector.subtract(secondVector);
// Result is [0,1,2]``````

#### Parameters

• ##### other: Vector3

the vector to substract from this vector

#### Returns Vector3

A new vector with the subtraction result

### toString

• toString(): string
• Returns a string representation of the vector for debugging purposes

### toTsrVector3

• toTsrVector3(webAssemblyContext: TSciChart3D): TSRVector3
• Used internally - converts the Vector3 to a {@link TSRVector3} for compatibility with SciChart's webassembly engine

#### Parameters

• ##### webAssemblyContext: TSciChart3D

The SciChart 3D WebAssembly Context containing native methods and access to our WebGL2 Engine and WebAssembly numerical methods

#### Returns TSRVector3

Generated using TypeDoc