normalize method

Quaternion normalize()

Normalizes this quaternion.

Implementation

Quaternion normalize() {
	double l = length;

	if ( l == 0 ) {
		x = 0;
		y = 0;
		z = 0;
		w = 1;
	}
    else {
		l = 1 / l;

		x = x * l;
		y = y * l;
		z = z * l;
		w = w * l;
	}

	return this;
}