Vector, Matrix, Quaternion, Euler Angles, SLERPs, Projections, Transforms
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
es5
gulp
source
.gitignore
.jscs.json
.jshintrc
gulpfile.js
package.json
package.md
readme.md

readme.md

#xyzw

A generic, fast, comprehensive and dependencyless vector algebra library

##Install

$ npm install xyzw

##Use

All included classes are available at xyzw/source. Es5 versions are available at xyzw/es5

import Vector2 from 'xyzw/source/Vector2';
import Vector3 from 'xyzw/source/Vector3';
import Vector4 from 'xyzw/source/Vector4';

import Matrix2 from 'xyzw/source/Matrix2';
import Matrix3 from 'xyzw/source/Matrix3';
import Matrix4 from 'xyzw/source/Matrix4';

###Creating instances

Instances of all classes are created the same way:

const a = new Vector3();                   //a (0, 0, 0) vector
const b = new Vector3([1.0, 0.0, 0.0]);    //a unit vector along the x axis
const c = Vector3.Y()                      //a unit vector along the y axis

###Accessing and manipulating components

Invoking the contructor without arguments or without an array of the right size will always return a zero instance. The components are accessible either through getters or through the .n property

const x = a.x;      //same as a.n[0]
const y = a.n[1];   //same as a.y

a.x = 2.1;          //same as a.n[0] = 2.1
a.n[1] = 10.5;      //same as a.y = 10.5;

###Working with vectors and matrices

All basic math operations are available in three basic forms and most additional have an assignment variant of the operation.

const d = Vector3.Add(b, c);

Creates a new Vector3 by using an operator factory d = b op c

const e = Vector3.Add(b, c, a);

Uses an operator factory, but invokes it with the target instance as its last argument a = b op c, e === a

a.add(b, c);

Calls the operation method of a and assigns the result of the operation to a a = b op c

a.addEQ(b);

Calls the operation-assignment method of a a op= b

###Chaining

All member operations mutate the instance and almost all support the parameter idiom.

const v = Vector3.Subtract(a, b)
	.multiplyScalarEQ(0.5)
	.addEQ(b);

###Transforms The matrix types are equipped with factory constructors allowing to create useful transforms from a variety of sources.

const r0 = Matrix2.XY(
	new Vector2([1.0, 0.0]),
	new Vector2([0.0, 1.0])
);

A 2d rotation matrix built from two axes

const r1 = Matrix2.Rotation(Math.PI);

A 2d rotation transform built from an angle

const r2 = Matrix3.RotationZ(Math.PI);

A 3d rotation transform build the same angle in the same plane

const r3 = Matrix3.Matrix2(r0);

A 2d transform built from a rotation matrix

const t0 = Matrix3.Translation(new Vector2([1.0, 5.0]));    

A 2d transform built from a translation vector

const t1 = Matrix4.Matrix3(r2);

A 3d transform built from a rotation matrix

const t2 = Matrix4.Translation(new Vector3([1.0, 0.0, 0.0]));

A 3d transform built from a translation vector

###Concatenation

Since the last line of the matrices stays unused most of the time and in very predicable ways, the matrices come with an array of specialized concatenations in addition to their base concatenations.

const m0 = Matrix3.multiply2x3Matrix2(r2, r0);

The concatenation r2 x r0. Since r0 is only 2x2, only components n00, n01, n10, n11 will be processed while n02, n12 will be copied from r2.

const m1 = Matrix3.Multiply2x3(t0, r3);

The concatenation t0 x r3. Multiply2x3 will not process the last line of any of the source matrices, but assume both to be empty.

const m2 = Matrix4.Multiply3x4Matrix3(t2, r2);
const m3 = Matrix4.Multiply3x4(t2, t1);

The equivalent concatenations for 3x4 matrices

###Projecting vectors

Likewise the vectors will come with specialized projection operators in addition to their basic projection operators.

const p0 = Vector2.MultiplyMatrix2(r0, new Vector2([5.5, 3.3]));

Will project vector (5.0, 3.0) by rotation r0. Since only n00, n01, n10, n11 will contain arbitrary data, the projection much faster.

const p1 = Vector2.Multiply2x3Matrix3(t0, new Vector2([12.7, 7.12]));

Will project the vector by transform r2. This operator implies that n20, n21, n22 will be 0.0, 0.0, 1.0 respecively and skips them from caculations accordingly.

const p2 = Vector3.MultiplyMatrix3(r2, Vector3.Z());
const p3 = Vector3.Multiply3x4Matrix4(t2, new Vector3([1.1, 5.5, 2.2]));

The equivalent concatenations for 3x4 matrices.

ExtMath

source/Math.js:4-4

Extends Math

clamp

source/Math.js:15-17

Returns the clamped value of n

Parameters

Returns number

mix

source/Math.js:26-28

Returns the linear interpolation of a and b

Parameters

  • a number The first value
  • b number The second value
  • bf number The weight of the second value

Returns number

reflect

source/Math.js:36-38

Returns the reflected value of n against r

Parameters

Returns number

range

source/Math.js:47-52

Returns a random number between min and max

Parameters

  • min number The minimal value
  • max number The maximal value
  • intervals int? The number of discreet intervals

Returns number

overlap

source/Math.js:63-68

Returns true if ranges (a0 a1) and (b0 b1) overlap, false otherwise

Parameters

  • a0 number The first limit of range a
  • a1 number The second limit of range a
  • b0 number The first limit of range b
  • b1 number The second limit of range b

Returns boolean

Matrix2

source/Matrix2.js:4-402

2x2 transformations

constructor

source/Matrix2.js:174-183

Creates a new instance

Parameters

  • n Array<number>? Array representing 2x2 column-major ordered components Arrays of length !== 4 will return the identity matrix

n

source/Matrix2.js:182-182

The array representation The 4 column-major ordered components n[0]:n00 n[2]:n01 n[1]:n10 n[3]:n11

define

source/Matrix2.js:192-196

Redefines the instance

Parameters

  • n Array<number>? Array representing the 2x2 column-major ordered compoents Array of length !== 4 will return the identity matrix

Returns Matrix2

n00

source/Matrix2.js:203-205

row 0, col0, Matrix2#n[0]

n01

source/Matrix2.js:216-218

row 0, col1, Matrix2#n[2]

n10

source/Matrix2.js:229-231

row 1, col0, Matrix2#n[1]

n11

source/Matrix2.js:242-244

row 1, col1, Matrix2#n[3]

determinant

source/Matrix2.js:255-257

The determinant

add

source/Matrix2.js:266-272

The sum of a and b (a+b)

Parameters

Returns Matrix2

subtract

source/Matrix2.js:280-286

The difference of a and b (a-b)

Parameters

Returns Matrix2

multiply

source/Matrix2.js:294-310

The concatenation of a and b (a*b)

Parameters

Returns Matrix2

inverseOf

source/Matrix2.js:320-336

The inverse of m Beware: method is NOT chainable Returns false if m is assumed to be singular, true otherwise

Parameters

Returns Boolean

transposeOf

source/Matrix2.js:343-350

The transpose of m

Parameters

Returns Matrix2

copyOf

source/Matrix2.js:357-361

The copy of m

Parameters

Returns Matrix2

invert

source/Matrix2.js:369-371

The inverse of the instance Returns false if the instance is assumed to singular, true otherwise

Returns boolean

transpose

source/Matrix2.js:377-379

The transpose of the instance

Returns Matrix2

toString

source/Matrix2.js:387-393

Returns a string representation of the instance

Parameters

  • digits int? The decimal digits (optional, default 3)

Returns string

valueOf

source/Matrix2.js:399-401

Returns the Matrix2#determinant of the instance

Returns number

Rotation

source/Matrix2.js:12-25

Returns a instance of z-axis rotation

Parameters

  • rad number The rotation in radians
  • target Matrix2? The target instance

Returns Matrix2

Scale

source/Matrix2.js:33-43

Returns a instance of scale vector

Parameters

Returns Matrix2

Vector2

source/Matrix2.js:52-60

Returns a new instance of axes (x, y)

Parameters

Returns Matrix2

Matrix3

source/Matrix2.js:69-78

Returns a new instance of converted m The instance will be cropped to 2x2 by removing the third row & column of m

Parameters

Returns Matrix2

Add

source/Matrix2.js:88-90

Returns the sum of a and b (a+b)

Parameters

Returns Matrix2

Subtract

source/Matrix2.js:99-101

Returns the difference of a and b (a-b)

Parameters

Returns Matrix2

Multiply

source/Matrix2.js:110-112

Returns the concatenation of a and b (a*b)

Parameters

Returns Matrix2

Inverse

source/Matrix2.js:122-126

Returns the inverse of m Returns null if m is assumed to be singular, the new instance otherwise

Parameters

Returns (Matrix2 | null)

Transpose

source/Matrix2.js:134-136

Returns the transpose of m

Parameters

Returns Matrix2

Copy

source/Matrix2.js:144-146

Returns a copy of m

Parameters

Returns Matrix2

isEQ

source/Matrix2.js:155-165

Returns true if a and b are equal, false otherwise (a==b)

Parameters

Returns boolean

Matrix3

source/Matrix3.js:9-979

2x3 and 3x3 transformations

constructor

source/Matrix3.js:495-505

Creates a new instance

Parameters

  • n Array<number>? Array represeting 3x3 column-major ordered components Arrays of length !== 9 will return the identity matrix

n

source/Matrix3.js:504-504

The array representation Contains the 9 column-major ordered components of the instance n[0]:n00 n[3]:n01 n[6]:n02 n[1]:n10 n[4]:n11 n[7]:n12 n[2]:n20 n[5]:n21 n[8]:n22

define

source/Matrix3.js:514-518

Redefines the instance

Parameters

  • n Array<number>? Array representing 3x3 column-major ordered components Arrays of length !== 9 will return the identity matrix.

Returns Matrix3

n00

source/Matrix3.js:525-527

row 0, col 0, Matrix3#n[0]

n01

source/Matrix3.js:538-540

row 0, col 1, Matrix3#n[3]

n02

source/Matrix3.js:551-553

row 0, col 2, Matrix3#n[6]

n10

source/Matrix3.js:564-566

row 1, col 0, Matrix3#n[1]

n11

source/Matrix3.js:577-579

row 1, col 1, Matrix3#n[4]

n12

source/Matrix3.js:590-592

row 1, col 2, Matrix3#n[7]

n20

source/Matrix3.js:603-605

row 2, col 0, Matrix3#n[2]

n21

source/Matrix3.js:616-618

row 2, col 1, Matrix3#n[5]

n22

source/Matrix3.js:629-631

row 2, col 2, Matrix3#n[8]

determinant

source/Matrix3.js:642-649

The determinant

add

source/Matrix3.js:658-664

The sum of a and b (a+b)

Parameters

Returns Matrix3

subtract

source/Matrix3.js:672-678

The difference of a and b (a-b)

Parameters

Returns Matrix3

multiply2x3Vector2Scale

source/Matrix3.js:687-697

The 2x3 concatenation of m and matrix-transformed v (m*Matrix3.Matrix2(Matrix2.Scale(v))) Components 2x are assumed to be (0.0,0.0,1.0)

Parameters

Returns Matrix3

multiply2x3Vector2Translation

source/Matrix3.js:706-720

The 2x3 concatenation of m and matrix-transformed v (m*Matrix3.Translation(v)) Components 2x are assumed to be (0.0,0.0,1.0)

Parameters

Returns Matrix3

multiply2x3Matrix2

source/Matrix3.js:729-747

The 2x3 concatenation of a and b (a*b) Components 2x are assumed to be (0.0,0.0,1.0)

Parameters

Returns Matrix3

multiply2x3

source/Matrix3.js:756-777

The 2x3 concatenation of a and b (a*b) Components 2x are assumed to be (0.0,0.0,1.0)

Parameters

Returns Matrix3

multiply

source/Matrix3.js:785-809

The concatenation of a and b (a*b)

Parameters

Returns Matrix3

inverseOf

source/Matrix3.js:819-843

The inverse of m Beware: method is NOT chainable

Parameters

Returns Boolean Returns false if m is assumed to be singular, true otherwise

transposeOf

source/Matrix3.js:850-858

The transpose of m

Parameters

Returns Matrix3

copyOf

source/Matrix3.js:865-869

The copy of m

Parameters

Returns Matrix3

invert

source/Matrix3.js:878-880

The inverse of the instance Beware: method is NOT chainable

Returns Boolean Returns false if the instance is assumed to be singular, true otherwise

transpose

source/Matrix3.js:886-888

The transpose of the instance

Returns Matrix3

toEulerYXZ

source/Matrix3.js:895-909

Returns a (x,y,z) ordered (y,x,z) euler angle representation of the instance

Returns Array<number>

toEulerZXY

source/Matrix3.js:915-929

Returns a (x,y,z) ordered (z,x,y) euler angle representation of the instance

Returns Array<number>

toCSS2x3

source/Matrix3.js:937-944

Returns a css-formated 2x3 string representation of the instance Components 2x are assumed to be (0.0,0.0,1.0)

Parameters

  • digits int? The decimal digits (optional, default 3)

Returns String

toCSS

source/Matrix3.js:951-957

Returns a css-formated 3x3 string representation of the instance

Parameters

  • digits int? The decimal digits (optional, default 3)

Returns String

toString

source/Matrix3.js:964-970

Returns a string representation of the instance

Parameters

  • digits int? The decimal digits (optional, default 3)

Returns String

valueOf

source/Matrix3.js:976-978

Returns the Matrix3#determinant of the instance

Returns number

Rotation

source/Matrix3.js:18-35

Returns a instance of axis and rotation

Parameters

  • axis Vector3 The rotation axis
  • rad number The rotation in radians
  • target Matrix3? The target instance

Returns Matrix3

RotationX

source/Matrix3.js:43-57

Returns a instance of x-axis rotation

Parameters

  • rad number The rotation in radians
  • target Matrix3? The target instance

Returns Matrix3

RotationY

source/Matrix3.js:65-79

Returns a instance of y-axis rotation

Parameters

  • rad number The rotation in radians
  • target Matrix3? The target instance

Returns Matrix3

RotationZ

source/Matrix3.js:87-101

Returns a instance of z-axis rotation

Parameters

  • rad number The rotation in radians
  • target Matrix3? The target instance

Returns Matrix3

EulerXYZ

source/Matrix3.js:112-135

Returns a instance of (x,y,z) ordered euler angles

Parameters

  • x number The first (x-axis) rotation in radians
  • y number The second (y-axis) rotation in radians
  • z number The third (z-axis) rotation in radians
  • target Matrix3? The target instance

Returns Matrix3

EulerYXZ

source/Matrix3.js:146-169

Returns a instance of (y,x,z) ordered euler angles

Parameters

  • x number The second (x-axis) rotation in radians
  • y number The first (y-axis) rotation in radians
  • z number The third (z-axis) rotation in radians
  • target Matrix3? The target instance

Returns Matrix3

EulerZXY

source/Matrix3.js:179-202

Returns a instance of (z,x,y) ordered euler angles

Parameters

  • x number The second (x-axis) rotation in radians
  • y number The third (y-axis) rotation in radians
  • z number The first (z-axis) rotation in radians
  • target Matrix3? The target instance

Returns Matrix3

Scale

source/Matrix3.js:211-224

Returns a instance of scale vector

Parameters

Returns Matrix3

Translation

source/Matrix3.js:232-245

Returns a instance of translation vector

Parameters

Returns Matrix3

Vector2

source/Matrix3.js:255-269

Returns an instance created from axes (x, y) and translation t

Parameters

Returns Matrix3

Vector3

source/Matrix3.js:279-287

Returns a instance of axes (x, y, z)

Parameters

Returns Matrix3

Vector4

source/Matrix3.js:295-314

Returns a instance of unit-quaternion q

Parameters

Returns Matrix3

Matrix2

source/Matrix3.js:324-333

Returns a instance of m The instance will be padded to 3x3

Parameters

Returns Matrix3

Matrix4

source/Matrix3.js:342-352

Returns a instance of m The instance will be cropped to 3x3 by removing the fourth row & column of m

Parameters

Returns Matrix3

Add

source/Matrix3.js:362-364

Returns the sum of a and b (a+b)

Parameters

Returns Matrix3

Subtract

source/Matrix3.js:373-375

Returns the difference of a and b (a-b)

Parameters

Returns Matrix3

Multiply2x3Vector2Scale

source/Matrix3.js:385-387

Returns the 2x3 concatenation of m and matrix-transformed v (m*Matrix3.Matrix2(Matrix2.Scale(v))) Components 2x are assumed to be (0.0,0.0,1.0)

Parameters

Returns Matrix3

Multiply2x3Vector2Translation

source/Matrix3.js:396-398

Returns the 2x3 concatenation of m and matrix-transformed v (m*Matrix3.Translation(v))

Parameters

Returns Matrix3

Multiply2x3Matrix2

source/Matrix3.js:408-410

Returns the 2x3 concatenation of a and b (a*b) Components 2x are assumed to be (0.0,0.0,1.0)

Parameters

Returns Matrix3

Multiply2x3

source/Matrix3.js:420-422

Returns the 2x3 concatenation of a and b (a*b) Components 2x are assumed to be (0.0,0.0,1.0)

Parameters

Returns Matrix3

Multiply

source/Matrix3.js:431-433

Returns the concatenation of a and b (a*b)

Parameters

Returns Matrix3

Inverse

source/Matrix3.js:443-447

Returns the inverse of m Returns null if m is assumed to be singular, the inverse of m otherwise

Parameters

Returns (Matrix3 | null)

Transpose

source/Matrix3.js:455-457

Returns the transpose of m

Parameters

Returns Matrix3

Copy

source/Matrix3.js:465-467

Returns a copy of m

Parameters

Returns Matrix3

isEQ

source/Matrix3.js:476-486

Returns true if a and b are equal, false otherwise

Parameters

Returns boolean

Matrix4

source/Matrix4.js:9-936

3x4 and 4x4 transformations

constructor

source/Matrix4.js:244-255

Creates a new instance

Parameters

  • n Array<number>? Array representing 4x4 column-major ordered components Arrays of length !== 16 will return the identity matrix

n

source/Matrix4.js:254-254

The array representation Contains the 16 column-major ordered components of the instance n[0]:n00 n[4]:n01 n[8] :n02 n[12]:n03 n[1]:n10 n[5]:n11 n[9] :n12 n[13]:n13 n[2]:n20 n[6]:n21 n[10]:n22 n[14]:n23 n[3]:n30 n[7]:n31 n[11]:n32 n[15]:n33

define

source/Matrix4.js:264-268

Redefines the instance

Parameters

  • n Array<number>? Array representing 4x4 column-major ordered components Arrays of length !== 16 will return the identity matrix

Returns Matrix4

n00

source/Matrix4.js:275-277

row 0, col 0, Matrix4#n[0]

n01

source/Matrix4.js:288-290

row 0, col 1, Matrix4#n[4]

n02

source/Matrix4.js:301-303

row 0, col 2, Matrix4#n[8]

n03

source/Matrix4.js:314-316

row 0, col 3, Matrix4#n[12]

n10

source/Matrix4.js:327-329

row 1, col 0, Matrix4#n[1]

n11

source/Matrix4.js:340-342

row 1, col 1, Matrix4#n[5]

n12

source/Matrix4.js:353-355

row 1, col 2, Matrix4#n[9]

n13

source/Matrix4.js:366-368

row 1, col 3, Matrix4#n[13]

n20

source/Matrix4.js:379-381

row 2, col 0, Matrix4#n[2]

n21

source/Matrix4.js:392-394

row 2, col 1, Matrix4#n[6]

n22

source/Matrix4.js:405-407

row 2, col 2, Matrix4#n[10]

n23

source/Matrix4.js:418-420

row 2, col 3, Matrix4#n[14]

n30

source/Matrix4.js:431-433

row 3, col 0, Matrix4#n[3]

n31

source/Matrix4.js:444-446

row 3, col 1, Matrix4#n[7]

n32

source/Matrix4.js:457-459

row 3, col 2, Matrix4#n[11]

n33

source/Matrix4.js:470-472

row 3, col 3, Matrix4#n[15]

determinant

source/Matrix4.js:483-490

The determinant

add

source/Matrix4.js:499-505

The sum of a and b (a+b)

Parameters

Returns Matrix4

subtract

source/Matrix4.js:513-519

The difference of a and b (a-b)

Parameters

Returns Matrix4

multiply3x4Vector3Scale

source/Matrix4.js:528-539

The 3x4 concatenation of m and matrix-transformed v (m*Matrix4.Matrix3(Matrix3.Scale(v))) Components 3x are assumed to be (0.0,0.0,0.0,1.0)

Parameters

Returns Matrix4

multiply3x4Vector3Translation

source/Matrix4.js:548-558

The 3x4 concatenation of m and matrix-transformed v (m*Matrix4.Translation(v)) Components 3x are assumed to be (0.0,0.0,0.0,1.0)

Parameters

Returns Matrix4

multiply3x4Matrix3

source/Matrix4.js:567-597

The 3x4 concatenation of a and b (a*b) Components 3x are assumed to be (0.0,0.0,0.0,1.0)

Parameters

Returns Matrix4

multiply3x4

source/Matrix4.js:606-636

The 3x4 concatenation of a and b (a*b) Components 3x are assumed to be (0.0,0.0,0.0,1.0)

Parameters

Returns Matrix4

multiply

source/Matrix4.js:644-678

The concatenation of a and b (a*b)

Parameters

Returns Matrix4

inverse3x4Of

source/Matrix4.js:689-719

The 3x4 inverse of m Beware: method is NOT chainable Components 3x are assumed to be (0.0,0.0,0.0,1.0) Returns false if m is assumed to be singular, true otherwise

Parameters

Returns Boolean

inverseOf

source/Matrix4.js:729-771

The inverse of m Beware: method is NOT chainable. Using the adjoint method - m[ij] = 1 / d _ (-1)^(i + j) _ det(adj(m[ji])) Returns false if m is assumed to be singular, true otherwise

Parameters

Returns Boolean

transposeOf

source/Matrix4.js:851-860

The transpose of m

Parameters

Returns Matrix4

copyOf

source/Matrix4.js:867-871

The copy of m

Parameters

Returns Matrix4

invert3x4

source/Matrix4.js:881-883

The 3x4 inverse of the instance Beware: method is NOT chainable Components 3x are assumed to be (0.0,0.0,0.0,1.0)

Returns boolean Returns false if the instance is assumed to be singular, true otherwise

invert

source/Matrix4.js:892-894

The inverse of the instance Beware: method is NOT chainable Using the adjoint method

Returns boolean Returns false if the instance is assumed to be singular, true otherwise

invertGauss

source/Matrix4.js:903-905

The inverse of the instance Beware: method is NOT chainable using gauss-jordan elimination

Returns boolean Returns false if the instance is singular, true otherwise

transpose

source/Matrix4.js:911-913

The transpose of the instance

Returns Matrix4

toString

source/Matrix4.js:921-927

Returns a string representation of the instance

Parameters

  • digits int? The number of digits (optional, default 3)

Returns string

valueOf

source/Matrix4.js:933-935

Returns the Matrix4#determinant of the instance

Returns number

Translation

source/Matrix4.js:17-31

Returns a instance of translation vector

Parameters

Returns Matrix4

Vector3

source/Matrix4.js:42-52

Returns a instance of axes (x,y,z) and translation (t)

Parameters

Returns Matrix4

Matrix3

source/Matrix4.js:61-71

Returns a instance of m The instance will be padded to 4x4

Parameters

Returns Matrix4

Add

source/Matrix4.js:81-83

Returns the sum of a and b (a+b)

Parameters

Returns Matrix4

Subtract

source/Matrix4.js:92-94

Returns the difference of a and b (a-b)

Parameters

Returns Matrix4

Multiply3x4Vector3Scale

source/Matrix4.js:104-106

Returns the 3x4 concatenation of m and matrix-transformed v (m*Matrix4.Matrix3(Matrix3.Scale(v))) Components 3x are assumed to be (0.0,0.0,0.0,1.0)

Parameters

Returns Matrix4

Multiply3x4Vector3Translation

source/Matrix4.js:116-118

Returns the 3x4 concatenation of m and matrix-transformed v (m*Matrix4.Translation(v)) Components 3x are assumed to be (0.0,0.0,0.0,1.0)

Parameters

Returns Matrix4

Multiply3x4Matrix3

source/Matrix4.js:128-130

Returns the 3x4 concatenation of a and b (a*b) Components 3x are assumed to be (0.0,0.0,0.0,1.0)

Parameters

Returns Matrix4

Multiply3x4

source/Matrix4.js:140-142

Returns the 3x4 concatenation of a and b (a*b) Components 3x are assumed to be (0.0,0.0,0.0,1.0)

Parameters

Returns Matrix4

Multiply

source/Matrix4.js:151-153

Returns the concatenation of a and b (a*b)

Parameters

Returns Matrix4

Inverse3x4

source/Matrix4.js:164-168

Returns the 3x4 inverse of m Components 3x are to be (0.0,0.0,0.0,1.0) Returns null if m is assumed to be singular, the 3x4 inverse of m otherwise

Parameters

Returns (Matrix4 | null)

Inverse

source/Matrix4.js:178-182

Returns the inverse of m Using the adjoint method Returns null if m is assumed to be singular, the 4x4 inverse of m otherwise

Parameters

Returns (Matrix4 | null)

InverseGauss

source/Matrix4.js:192-196

Returns the inverse of m Using gauss-jordan elimination Returns null if m is singular, the 4x4 inverse of m otherwise

Parameters

Returns (Matrix4 | null)

Transpose

source/Matrix4.js:204-206

Returns the transpose of m

Parameters

Returns Matrix4

Copy

source/Matrix4.js:214-216

Returns a copy of m

Parameters

Returns Matrix4

isEQ

source/Matrix4.js:225-235

Returns true if a and b are equal, false otherwise (a == b)

Parameters

Returns Boolean

inverseGaussOf

source/Matrix4.js:781-844

The inverse of m Beware: method is NOT chainable Using gauss-jordan elimination returns false if m is singular, false otherwise

Parameters

Returns Boolean

FOV_MIN

source/Matrix4Frustrum.js:10-10

The minimal vertical field of view

Type: number

FOV_MAX

source/Matrix4Frustrum.js:15-15

The maximal vertical field of view

FOV_DEFAULT

source/Matrix4Frustrum.js:20-20

The default vertical field of view

ASPECT_MIN

source/Matrix4Frustrum.js:25-25

The minimal projection aspect ratio (w/h)

Type: number

ASPECT_MIN

source/Matrix4Ortho.js:25-25

The minimal projection aspect ratio (w/h)

Type: number

ASPECT_MAX

source/Matrix4Frustrum.js:30-30

The maximal projection aspect ratio (w/h)

Type: number

ASPECT_MAX

source/Matrix4Ortho.js:30-30

The maximal projection aspect ratio (w/h)

Type: number

ASPECT_DEFAULT

source/Matrix4Frustrum.js:35-35

The default projection aspect ratio (w/h)

ASPECT_DEFAULT

source/Matrix4Ortho.js:35-35

The default projection aspect ratio (w/h)

ZPLANE_MIN

source/Matrix4Frustrum.js:40-40

The minimal z-plane distance

Type: number

ZPLANE_MIN

source/Matrix4Ortho.js:40-40

The minimal z-plane distance

Type: number

ZPLANE_MAX

source/Matrix4Frustrum.js:45-45

The maximal z-plane distance

ZPLANE_MAX

source/Matrix4Ortho.js:45-45

The maximal z-plane distance

Matrix4Frustrum

source/Matrix4Frustrum.js:59-199

Extends Matrix4

Perspectivic projection matrix

constructor

source/Matrix4Frustrum.js:81-90

Creates a new instance

Parameters

  • fov number? The vertical field of view, in radians (optional, default FOV_DEFAULT)
  • aspect number? The aspect ratio (w/h) (optional, default ASPECT_DEFAULT)
  • near number? The distance of the near plane (optional, default ZPLANE_MIN)
  • far number? The distance of the far plane (optional, default ZPLANE_MAX)

define

source/Matrix4Frustrum.js:101-148

(Re)defines the instance

Parameters

  • fov number? The vertical field of view, in radians (optional, default FOV_DEFAULT)
  • aspect number? The aspect ratio (w/h) (optional, default ASPECT_DEFAULT)
  • near number? The near plane distance (optional, default ZPLANE_MIN)
  • far number? The far plane distance (optional, default ZPLANE_MAX)

Returns Matrix4Frustrum

fov

source/Matrix4Frustrum.js:155-157

The vertical field of view, in radians

aspect

source/Matrix4Frustrum.js:163-165

The projection aspect ratio (w/h)

near

source/Matrix4Frustrum.js:171-173

The distance of the near plane

far

source/Matrix4Frustrum.js:179-181

The distance of the far plane

copyOf

source/Matrix4Frustrum.js:189-198

The copy of m

Parameters

Returns Matrix4Frustrum

Copy

source/Matrix4Frustrum.js:67-70

Returns a copy of m

Parameters

Returns Matrix4Frustrum

EXTEND_MIN

source/Matrix4Ortho.js:10-10

The minimal vertical extend of the viewcube

Type: number

EXTEND_MAX

source/Matrix4Ortho.js:15-15

The maximal vertical extend of the viewcube

Type: number

EXTEND_DEFAULT

source/Matrix4Ortho.js:20-20

The default vertical extend of the viewcube

Type: number

Matrix4Ortho

source/Matrix4Ortho.js:59-197

Extends Matrix4

Orthographic projection Matrix

constructor

source/Matrix4Ortho.js:81-90

Creates a new instance

Parameters

  • extend number? The vertical extend of the viewcube (optional, default EXTEND_DEFAULT)
  • aspect number? The aspect ratio (w/h) (optional, default ASPECT_DEFAULT)
  • near number? The near plane distance (optional, default ZPLANE_MIN)
  • far number? The far plane distance (optional, default ZPLANE_MAX)

define

source/Matrix4Ortho.js:101-146

(Re)defines the instance

Parameters

  • extend number? The vertical extend of the viewcube (optional, default EXTEND_DEFAULT)
  • aspect number? The aspect ratio (w/h) (optional, default ASPECT_DEFAULT)
  • near number? The near plane distance (optional, default ZPLANE_MIN)
  • far number? The far plane distance (optional, default ZPLANE_MAX)

Returns Matrix4Ortho

extend

source/Matrix4Ortho.js:153-155

The vertical extend of the viewcube

aspect

source/Matrix4Ortho.js:161-163

The aspect ratio (w/h)

near

source/Matrix4Ortho.js:169-171

The near plane distance

far

source/Matrix4Ortho.js:177-179

The far plane distance

copyOf

source/Matrix4Ortho.js:187-196

The copy of m

Parameters

Returns Matrix4Ortho

Copy

source/Matrix4Ortho.js:67-70

Returns a copy of m

Parameters

Returns Matrix4Ortho

Vector2

source/Vector2.js:4-602

Two component vector

constructor

source/Vector2.js:235-241

Creates a new instance

Parameters

  • n Array<number>? Array representing the two components Arrays of length !== 2 will return the zero (0,0) vector

n

source/Vector2.js:240-240

The component array

define

source/Vector2.js:249-253

Redefines the instance

Parameters

  • n Array<number> Array representing the two components

Returns Vector2

x

source/Vector2.js:260-262

The x component Vector2#n[0]

y

source/Vector2.js:272-274

The y component Vector2#n[1]

s

source/Vector2.js:285-287

The s component Alias of Vector2#x

t

source/Vector2.js:298-300

The t component Alias of Vector2#y

norm

source/Vector2.js:311-315

The norm

normSquared

source/Vector2.js:321-325

The square of the norm (norm*norm)

add

source/Vector2.js:334-339

The sum of v and w (v+w)

Parameters

Returns Vector2

subtract

source/Vector2.js:347-352

The difference of v and w (v-w)

Parameters

Returns Vector2

multiplyScalar

source/Vector2.js:360-365

The scalar product of v and n (v*n)

Parameters

Returns Vector2

multiplyMatrix2

source/Vector2.js:373-380

The transformation of v (m*v)

Parameters

Returns Vector2

multiply2x3Matrix3

source/Vector2.js:388-395

The 2x3 transformation of v (m*v)

Parameters

Returns Vector2

multiplyMatrix3

source/Vector2.js:403-411

The transformation of v (m*v)

Parameters

Returns Vector2

project

source/Vector2.js:419-427

The orthogonal projection of w on v

Parameters

Returns Vector2

minXY

source/Vector2.js:435-442

The componentwise minimum of v and w (min(v,w))

Parameters

Returns Vector2

maxXY

source/Vector2.js:450-457

The componentwise maximum of v and w (max(v,w))

Parameters

Returns Vector2

addEQ

source/Vector2.js:465-470

The sum of the instance and w (v+w)

Parameters

Returns Vector2

subtractEQ

source/Vector2.js:477-482

The difference of the instance and w (v-w)

Parameters

Returns Vector2

multiplyScalarEQ

source/Vector2.js:489-494

The scalar product of the instance and n (v*n)

Parameters

Returns Vector2

projectEQ

source/Vector2.js:501-509

The orthogonal projection of w on the instance

Parameters

Returns Vector2

normalizationOf

source/Vector2.js:517-526

The normal form of v

Parameters

Returns Vector2

perpendicularOf

source/Vector2.js:533-539

The perpendicular dot product of v

Parameters

Returns Vector2

copyOf

source/Vector2.js:546-550

The copy of v

Parameters

Returns Vector2

normalize

source/Vector2.js:557-567

The normal form of the instance

Returns Vector2

perpendicular

source/Vector2.js:573-579

The perpendicular dot product of the instance

Returns Vector2

toString

source/Vector2.js:587-593

Returns a string representation of the instance

Parameters

  • digits int? The decimal digits (optional, default 3)

Returns string

valueOf

source/Vector2.js:599-601

Returns the Vector2#norm of the instance

Returns number

X

source/Vector2.js:11-18

Returns an instance representing the x axis

Parameters

  • target Vector2? The target instance

Returns Vector2

Y

source/Vector2.js:25-32

Returns an instance representing the y axis

Parameters

  • target Vector2? The target instance

Returns Vector2

Rotation

source/Vector2.js:40-50

Returns a unit instance from rad

Parameters

  • rad number The rotation in radians
  • target Vector2? The target instance

Returns Vector2

BarycentricUV

source/Vector2.js:62-75

Returns the resulting instance of cw triangle (v0,v1,v2) and barycentric coordinates (u,v)

Parameters

Returns Vector2

Add

source/Vector2.js:85-87

Returns the sum of v and w (v+w)

Parameters

Returns Vector2

Subtract

source/Vector2.js:96-98

Returns the difference of v and w (v-w)

Parameters

Returns Vector2

MultiplyScalar

source/Vector2.js:107-109

Returns the scalar product of v and n (v*n)

Parameters

Returns Vector2

MultiplyMatrix2

source/Vector2.js:118-120

Returns the transformation of v (m*v)

Parameters

Returns Vector2

Multiply2x3Matrix3

source/Vector2.js:129-131

Returns the 2x3 transformation of v (m*v)

Parameters

Returns Vector2

MultiplyMatrix3

source/Vector2.js:140-142

Returns the transformation of v (m*v)

Parameters

Returns Vector2

Project

source/Vector2.js:151-153

Returns the orthogonal projection of w on v

Parameters

Returns Vector2

Normalize

source/Vector2.js:161-163

Returns a normal form of v

Parameters

Returns Vector2

Perpendicular

source/Vector2.js:171-173

Returns a perpendicular dot product of v

Parameters

Returns Vector2

Copy

source/Vector2.js:181-183

Returns a copy of v

Parameters

Returns Vector2

cross

source/Vector2.js:192-194

Returns the outer product of v and w (v cross w)

Parameters

Returns number

dot

source/Vector2.js:202-204

Returns the inner product of v and w (v dot w)

Parameters

Returns number

rad

source/Vector2.js:212-214

Returns the angle in radians between v and w (acos(v dot w))

Parameters

Returns number

isEQ

source/Vector2.js:223-227

Returns true if v and w are equal, false otherwise

Parameters

Returns boolean

Vector3

source/Vector3.js:4-612

Three component vector

constructor

source/Vector3.js:255-261

Creates a new instance

Parameters

  • n Array<number>? Array representing the three components Arrays of length !== 3 will return the zero (0.0,0.0,0.0) vector

n

source/Vector3.js:260-260

The component array

define

source/Vector3.js:270-274

Redefines the instance

Parameters

  • n Array<number>? Array representing the three components Arrays of length !== 3 will return the zero (0.0,0.0,0.0) vector

Returns Vector3

x

source/Vector3.js:281-283

The x component, Vector3#n[0]

y

source/Vector3.js:294-296

The y component, Vector3#n[1]

z

source/Vector3.js:307-309

The z component, Vector3#n[2]

norm

source/Vector3.js:320-324

The norm

normSquared

source/Vector3.js:330-334

The square of the norm (norm*norm)

add

source/Vector3.js:343-349

The sum of v and w (v+w)

Parameters

Returns Vector3

subtract

source/Vector3.js:357-363

The difference of v and w (v-w)

Parameters

Returns Vector3

multiplyScalar

source/Vector3.js:371-377

The scalar product of v and n (v*n)

Parameters

Returns Vector3

cross

source/Vector3.js:385-391

The exterior product of v and w (v cross w)

Parameters

Returns Vector3

multiplyMatrix3

source/Vector3.js:399-408

The transformation of v (m*v)

Parameters

Returns Vector3

multiply3x4Matrix4

source/Vector3.js:416-424

The 3x4 transformation of v (m*v)

Parameters

Returns Vector3

multiplyMatrix4

source/Vector3.js:432-441

The transformation of v (m*v)

Parameters

Returns Vector3

project

source/Vector3.js:449-457

The projection of w on v

Parameters

Returns Vector3

orthoNormalize

source/Vector3.js:466-474

The orthonormalization of w against v Gram-Schmidt-Normalization: t -= n * (t dot n)

Parameters

Returns Vector3

addEQ

source/Vector3.js:482-488

The sum of the instance and w

Parameters

Returns Vector3

subtractEQ

source/Vector3.js:495-501

The difference of the instance and w

Parameters

Returns Vector3

multiplyScalarEQ

source/Vector3.js:508-514

The scalar product of the instance and n

Parameters

Returns Vector3

projectEQ

source/Vector3.js:521-529

The projection of w on the instance

Parameters

Returns Vector3

orthoNormalizeEQ

source/Vector3.js:537-544

The orthonormalization of the instance against v Gram-Schmidt-Normalization: t -= n * (t dot n)

Parameters

Returns Vector3

normalizationOf

source/Vector3.js:552-561

The normal form of v

Parameters

Returns Vector3

copyOf

source/Vector3.js:568-572

The copy of v

Parameters

Returns Vector3

normalize

source/Vector3.js:579-589

The normal form of the instance

Returns Vector3

toString

source/Vector3.js:597-603

Returns a string representation of the instance

Parameters

  • digits int? The decimal digits (optional, default 3)

Returns string

valueOf

source/Vector3.js:609-611

Returns the Vector3#norm of the instance

Returns number

X

source/Vector3.js:11-18

Returns a representation of the x-axis vector (1.0,0.0,0.0)

Parameters

  • target Vector3? The target instance

Returns Vector3

Y

source/Vector3.js:25-32

Returns a representation of the y-axis vector (0.0,1.0,0.0)

Parameters

  • target Vector3? The target instance

Returns Vector3

Z

source/Vector3.js:39-46

Returns a representation of the z-axis vector (0.0,0.0,1.0)

Parameters

  • target Vector3? The target instance

Returns Vector3

BarycentricUV

source/Vector3.js:59-70

Returns the resulting instance of cw triangle (v0,v1,v2) and barycentric coordinates (u,v)

Parameters

Returns Vector3

Add

source/Vector3.js:80-82

Returns the sum of v and w (v+w)

Parameters

Returns Vector3

Subtract

source/Vector3.js:91-93

Returns the difference between v and w (v-w)

Parameters

Returns Vector3

MultiplyScalar

source/Vector3.js:102-104

Returns the scalar product of v and n (v*n)

Parameters

Returns Vector3

Cross

source/Vector3.js:113-115

Returns the exterior product of v and w (v cross w)

Parameters

Returns Vector3

MultiplyMatrix3

source/Vector3.js:124-126

Returns the transformation of v (m*v)

Parameters

Returns Vector3

Multiply3x4Matrix4

source/Vector3.js:135-137

Returns the 3x4 transformation of v (m*v)

Parameters

Returns Vector3

MultiplyMatrix4

source/Vector3.js:146-148

Returns the transformation of v (m*v)

Parameters

Returns Vector3

Project

source/Vector3.js:158-160

Returns the projection of w on v

Parameters

Returns Vector3

OrthoNormalize

source/Vector3.js:169-171

Returns the orthonormalization of w against v

Parameters

Returns Vector3

Normalize

source/Vector3.js:180-182

Returns the normal form of v

Parameters

Returns Vector3

Copy

source/Vector3.js:190-192

Returns a copy of v

Parameters

Returns Vector3

dot

source/Vector3.js:201-203

Returns the inner product of v and w (v dot w)

Parameters

Returns number

isEQ

source/Vector3.js:212-216

Returns true if v and w are equal, false otherwise (u==v)

Parameters

Returns boolean

isNormLT

source/Vector3.js:224-226

Returns true if the norm of v is less than n, false otherwise (v.norm<n)

Parameters

Returns boolean

isNormGT

source/Vector3.js:234-236

Returns true if the norm of v is greater than n, false otherwise (v.norm>n)

Parameters

Returns boolean

isNormEQ

source/Vector3.js:244-246

Returns true if the norm of v and n are equal, false otherwise (v.norm===n)

Parameters

Returns boolean

Vector4

source/Vector4.js:4-555

Four component vector

constructor

source/Vector4.js:241-247

Creates a new instance

Parameters

  • n Array<number>? Array representing the four components Arrays of length !== 4 will return the identity (0.0,0.0,0.0,1.0) vector

n

source/Vector4.js:246-246

The component array

define

source/Vector4.js:256-260

Redefines the instance

Parameters

  • n Array<number>? Array representing the four components Arrays of length !== 4 will return the identity (0.0,0.0,0.0,1.0) vector

Returns Vector4

x

source/Vector4.js:267-269

The x component, Vector4#n[0]

y

source/Vector4.js:280-282

The y component, Vector4#n[1]

z

source/Vector4.js:293-295

The z component, Vector4#n[2]

w

source/Vector4.js:306-308

The w component, Vector4#n[3]

norm

source/Vector4.js:319-323

The norm of the instance

normSquared

source/Vector4.js:329-333

The square of the norm of the instance

Returns number

add

source/Vector4.js:342-349

The sum of q and r (q+r)

Parameters

Returns Vector4

subtract

source/Vector4.js:357-364

The difference of q and r (q-r)

Parameters

Returns Vector4

multiplyScalar

source/Vector4.js:372-379

The scalar product of q and n (q*n)

Parameters

Returns Vector4

multiply

source/Vector4.js:387-397

The exterior product of q and r (q cross r)

Parameters

Returns Vector4

addEQ

source/Vector4.js:405-412

The sum of the instance and q

Parameters

Returns Vector4

subtractEQ

source/Vector4.js:419-426

The difference of the instance and q

Parameters

Returns Vector4

multiplyScalarEQ

source/Vector4.js:433-440

The scalar product of the instance and n

Parameters

Returns Vector4

normalizationOf

source/Vector4.js:448-457

The normalization of q

Parameters

Returns Vector4

conjugateOf

source/Vector4.js:464-471

The conjugate of q

Parameters

Returns Vector4

inverseOf

source/Vector4.js:478-488

The inverse of q

Parameters

Returns Vector4

copyOf

source/Vector4.js:495-499

The copy of q

Parameters

Returns Vector4

normalize

source/Vector4.js:506-516

The normal form of the instance

Returns Vector4

conjugate

source/Vector4.js:522-524

The conjugate of the instance

Returns Vector4

invert

source/Vector4.js:530-532

The inverse of the instance

Returns Vector4

toString

source/Vector4.js:540-546

Returns a string representation of the instance

Parameters

  • digits int? The decimal digits (optional, default 3)

Returns string

valueOf

source/Vector4.js:552-554

Returns the Vector4#norm of the instance

Returns number

Rotation

source/Vector4.js:13-27

Returns a unit-quaternion instance of axis and rotation

Parameters

  • axis Vector3 The rotation axis
  • rad number The rotation in radians
  • target Vector4? The target instance

Returns Vector4

SLERP

source/Vector4.js:37-58

Returns a unit-quaternion instance of Spherical Linear intERPolation

Parameters

  • q Vector4 The starting unit quaternion
  • r Vector4 The ending unit quaternion
  • t number The interpolation factor
  • target Vector4? The target instance

Returns Vector4

Matrix3

source/Vector4.js:66-107

Returns a unit-quaternion instance of a rotation matrix

Parameters

  • m Matrix3 The source 3x3 transform
  • target Vector4? The target instance

Returns Vector4

Vector3

source/Vector4.js:115-122

Returns a instance of Vector3

Parameters

Returns Vector4

Add

source/Vector4.js:132-134

Returns the sum of q and r (q+r)

Parameters

Returns Vector4

Subtract

source/Vector4.js:143-145

Returns the difference of q and r (q-r)

Parameters

Returns Vector4

MultiplyScalar

source/Vector4.js:154-156

Returns the scalar product of q and n (q*n)

Parameters

Returns Vector4

Multiply

source/Vector4.js:165-167

Returns the exterior product of q and r (q*r)

Parameters

Returns Vector4

Normalize

source/Vector4.js:176-178

Returns the normal form of q

Parameters

Returns Vector4

Conjugate

source/Vector4.js:186-188

Returns the conjugate of q

Parameters

Returns Vector4

Inverse

source/Vector4.js:196-198

Returns the inverse of q

Parameters

Returns Vector4

Copy

source/Vector4.js:206-208

Returns a copy of q

Parameters

Returns Vector4

dot

source/Vector4.js:217-219

Returns the inner product of q and r

Parameters

Returns number

isEQ

source/Vector4.js:228-232

Returns true if q and r are equal, false otherwise (q==r)

Parameters

Returns boolean