applyMatrix4 method

Vector3 applyMatrix4(
  1. Matrix4 m
)

Multiplies the given 4x4 matrix with this 3D vector

Implementation

Vector3 applyMatrix4(Matrix4 m ) {
	final x = this.x, y = this.y, z = this.z;
	final e = m.elements;

	final w = 1 / ( ( e[ 3 ] * x ) + ( e[ 7 ] * y ) + ( e[ 11 ] * z ) + e[ 15 ] );

	this.x = ( ( e[ 0 ] * x ) + ( e[ 4 ] * y ) + ( e[ 8 ] * z ) + e[ 12 ] ) * w;
	this.y = ( ( e[ 1 ] * x ) + ( e[ 5 ] * y ) + ( e[ 9 ] * z ) + e[ 13 ] ) * w;
	this.z = ( ( e[ 2 ] * x ) + ( e[ 6 ] * y ) + ( e[ 10 ] * z ) + e[ 14 ] ) * w;

	return this;
}