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

	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);
		return([cos(rot/2),sin(rot/2)*x*norm,sin(rot/2)*y*norm,sin(rot/2)*z*norm]);
	}

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

	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 QuaternionMultiply(QuaternionMultiply(rotq,[0,x,y,z]),[rotq[0],-rotq[1],-rotq[2],-rotq[3]]);
	}

	function Rotate3D_B(posq,rotq){
		return QuaternionMultiply(QuaternionMultiply(rotq,posq),[rotq[0],-rotq[1],-rotq[2],-rotq[3]]);
	}

	function Rotate3D_C(x,y,z,rotx,roty,rotz){
		let rotq=MakeRotate(rotx,roty,rotz);
		return QuaternionMultiply(QuaternionMultiply(rotq,[0,x,y,z]),[rotq[0],-rotq[1],-rotq[2],-rotq[3]]);
	}

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