A benchmark comparison of two 3D rotation functions

Rotating a vertex 10 million times...
Watch here for results.


function trig_rotate(vert, roll, pitch, yaw){
				
	var d, p, x=vert.x, y=vert.y, z=vert.z;
	var {sin, cos, atan2, sqrt} = Math;
	d = sqrt(x*x+y*y);
	p = atan2(x,y);
	x = sin(p-roll)*d;
	y = cos(p-roll)*d;
	d = sqrt(y*y+z*z);
	p = atan2(y,z);
	y = sin(p+pitch)*d;
	z = cos(p+pitch)*d;
	d = sqrt(x*x+z*z);
	p = atan2(x,z);
	x = sin(p+yaw)*d;
	z = cos(p+yaw)*d;
	return {x:x, y:y, z:z};
}

function matrix_rotate(vert, roll, pitch, yaw) {
				
	var {sin, cos} = Math;	
	var cosa = cos(roll);
	var sina = sin(roll);
	var cosb = cos(yaw);
	var sinb = sin(yaw);
	var cosc = cos(-pitch);
	var sinc = sin(-pitch);

	var xx = cosa*cosb;
	var xy = cosa*sinb*sinc - sina*cosc;
	var xz = cosa*sinb*cosc + sina*sinc;
	var yx = sina*cosb;
	var yy = sina*sinb*sinc + cosa*cosc;
	var yz = sina*sinb*cosc - cosa*sinc;
	var zx = -sinb;
	var zy = cosb*sinc;
	var zz = cosb*cosc;

	var px = xx*vert.x + xy*vert.y + xz*vert.z;
	var py = yx*vert.x + yy*vert.y + yz*vert.z;
	var pz = zx*vert.x + zy*vert.y + zz*vert.z;
	
	return {x:px, y:py, z:pz};
}