//東方弾幕風用3D回転ライブラリ	ver1.01

	function MakeAxis(rot,x,y,z){
		let norm=x^2+y^2+z^2;
		if(norm<=0){return([0,0,0,0]);}
		norm=1/(norm^0.5);
		rot=rot/2;
		return([cos(rot),sin(rot)*x*norm,sin(rot)*y*norm,sin(rot)*z*norm]);
	}

	function MakeRotate(rotx,roty,rotz){
		rotx=rotx/2;
		roty=roty/2;
		rotz=rotz/2;
		return([cos(rotx)*cos(roty)*cos(rotz)+sin(rotx)*sin(roty)*sin(rotz),
			sin(rotx)*cos(roty)*cos(rotz)-cos(rotx)*sin(roty)*sin(rotz),
			cos(rotx)*sin(roty)*cos(rotz)+sin(rotx)*cos(roty)*sin(rotz),
			cos(rotx)*cos(roty)*sin(rotz)-sin(rotx)*sin(roty)*cos(rotz)
		]);
	}

	function QuaternionMultiply(left,right){
		return([
			left[0]*right[0]-left[1]*right[1]-left[2]*right[2]-left[3]*right[3],
			left[0]*right[1]+left[1]*right[0]+left[2]*right[3]-left[3]*right[2],
			left[0]*right[2]+left[2]*right[0]+left[3]*right[1]-left[1]*right[3],
			left[0]*right[3]+left[3]*right[0]+left[1]*right[2]-left[2]*right[1]
		]);
	}

	function Rotate3D_A(x,y,z,rotq){
		return(Rotate3D_B([0,x,y,z],rotq));
	}

	function Rotate3D_B(posq,rotq){
		let temp=[0-rotq[1]*posq[1]-rotq[2]*posq[2]-rotq[3]*posq[3],
			rotq[0]*posq[1]+rotq[2]*posq[3]-rotq[3]*posq[2],
			rotq[0]*posq[2]+rotq[3]*posq[1]-rotq[1]*posq[3],
			rotq[0]*posq[3]+rotq[1]*posq[2]-rotq[2]*posq[1]
			];
		return([
			0,
			temp[1]*rotq[0]-temp[0]*rotq[1]-temp[2]*rotq[3]+temp[3]*rotq[2],
			temp[2]*rotq[0]-temp[0]*rotq[2]-temp[3]*rotq[1]+temp[1]*rotq[3],
			temp[3]*rotq[0]-temp[0]*rotq[3]-temp[1]*rotq[2]+temp[2]*rotq[1]
		]);
	}

	function Rotate3D_C(x,y,z,rotx,roty,rotz){
		return(Rotate3D_B([0,x,y,z],MakeRotate(rotx,roty,rotz)));
	}

	function Perspective(v,z,dis){
		return(v/((z-dis)/-dis));
	}
