{
	"patcher" : 	{
		"fileversion" : 1,
		"appversion" : 		{
			"major" : 8,
			"minor" : 1,
			"revision" : 0,
			"architecture" : "x64",
			"modernui" : 1
		}
,
		"classnamespace" : "jit.gen",
		"rect" : [ 56.0, 79.0, 1031.0, 698.0 ],
		"bglocked" : 0,
		"openinpresentation" : 0,
		"default_fontsize" : 12.0,
		"default_fontface" : 0,
		"default_fontname" : "Arial",
		"gridonopen" : 1,
		"gridsize" : [ 15.0, 15.0 ],
		"gridsnaponopen" : 1,
		"objectsnaponopen" : 1,
		"statusbarvisible" : 2,
		"toolbarvisible" : 1,
		"lefttoolbarpinned" : 0,
		"toptoolbarpinned" : 0,
		"righttoolbarpinned" : 0,
		"bottomtoolbarpinned" : 0,
		"toolbars_unpinned_last_save" : 0,
		"tallnewobj" : 0,
		"boxanimatetime" : 200,
		"enablehscroll" : 1,
		"enablevscroll" : 1,
		"devicewidth" : 0.0,
		"description" : "",
		"digest" : "",
		"tags" : "",
		"style" : "",
		"subpatcher_template" : "",
		"boxes" : [ 			{
				"box" : 				{
					"id" : "obj-12",
					"linecount" : 46,
					"maxclass" : "comment",
					"numinlets" : 1,
					"numoutlets" : 0,
					"patching_rect" : [ 572.0, 29.0, 402.0, 623.0 ],
					"text" : "unitx = vec(1, 0, 0);\nunity = vec(0, 1, 0);\n\n// current dir\nv0 = in1;\n// adjustment dir\nv1 = in2;\n\neps = 0.000001;\nd = dot(v0, v1);\nq = vec(0, 0, 0, 1);\nax = vec(0, 0, 0);\n\nif(d >= 1) {\n \t// leave as identity\n}\nelse if(d < (eps - 1)) {\n\t\n\t ax = cross(unitx, v0);\n\t if((ax.x*ax.x + ax.y*ax.y + ax.z*ax.z) < eps) {\n\t\t  ax = cross(unity, v0);\n\t }\n\t ax = normalize(ax);\n\t\n\t // quat from axis-angle\n\t scale = sin(HALFPI);\n \tq = vec(scale*ax.x, scale*ax.y, scale*ax.z, cos(HALFPI));\n}\nelse {\n\t s = sqrt((1+d)*2);\n\t invs = 1. / s;\n\t c = cross(v0, v1);\n \tq = vec(c.x * invs, c.y * invs, c.z * invs, s * 0.5);\n\t\n\t // quat_normalize\n\t m = q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w;\n\t if (m > eps) {\n\t\t  s = 1. / sqrt(m);\n\t\t  q = vec(q.x * s, q.y * s, q.z * s, q.w * s);\n\t }\n else {\n\t  \tq = vec(eps, eps, eps, eps);\n\t }\n}\n\nout1 = q;"
				}

			}
, 			{
				"box" : 				{
					"bubble" : 1,
					"bubbleside" : 3,
					"bubbleusescolors" : 1,
					"id" : "obj-10",
					"linecount" : 2,
					"maxclass" : "comment",
					"numinlets" : 1,
					"numoutlets" : 0,
					"patching_rect" : [ 338.0, 149.0, 227.0, 37.0 ],
					"text" : "this code provides a codebox source implementation for the rotor operator"
				}

			}
, 			{
				"box" : 				{
					"id" : "obj-9",
					"maxclass" : "comment",
					"numinlets" : 1,
					"numoutlets" : 0,
					"patching_rect" : [ 127.75, 85.0, 267.0, 20.0 ],
					"text" : "scale to improve behavior with small movements"
				}

			}
, 			{
				"box" : 				{
					"id" : "obj-8",
					"maxclass" : "newobj",
					"numinlets" : 1,
					"numoutlets" : 1,
					"outlettype" : [ "" ],
					"patching_rect" : [ 82.75, 108.0, 61.0, 22.0 ],
					"text" : "normalize"
				}

			}
, 			{
				"box" : 				{
					"id" : "obj-7",
					"maxclass" : "newobj",
					"numinlets" : 2,
					"numoutlets" : 1,
					"outlettype" : [ "" ],
					"patching_rect" : [ 21.0, 156.5, 80.75, 22.0 ],
					"text" : "rotor"
				}

			}
, 			{
				"box" : 				{
					"id" : "obj-6",
					"maxclass" : "newobj",
					"numinlets" : 1,
					"numoutlets" : 1,
					"outlettype" : [ "" ],
					"patching_rect" : [ 82.75, 84.0, 43.0, 22.0 ],
					"text" : "* 1000"
				}

			}
, 			{
				"box" : 				{
					"id" : "obj-5",
					"maxclass" : "newobj",
					"numinlets" : 2,
					"numoutlets" : 1,
					"outlettype" : [ "" ],
					"patching_rect" : [ 82.75, 46.0, 150.25, 22.0 ],
					"text" : "-"
				}

			}
, 			{
				"box" : 				{
					"id" : "obj-4",
					"maxclass" : "newobj",
					"numinlets" : 3,
					"numoutlets" : 1,
					"outlettype" : [ "" ],
					"patching_rect" : [ 21.0, 18.0, 57.0, 22.0 ],
					"text" : "vec 0 0 1"
				}

			}
, 			{
				"box" : 				{
					"code" : "// quat to euler\r\nq = in1;\r\nax = vec(0, 0, 0);\r\ntest = q.x*q.y + q.z*q.w;\r\nif(test > 0.499) {  // singularity at north pole\r\n\tax = vec(0, 2*atan2(q.x, q.w), HALFPI);\r\n}\r\nelse  if(test < -0.499) { // singularity at south pole\r\n\tax = vec(0, -2*atan2(q.x, q.w), -HALFPI);\r\n}\r\nelse {\r\n\tsqx = q.x*q.x;\n\tsqy = q.y*q.y;\n\tsqz = q.z*q.z;\n\tax = vec(atan2(2*q.x*q.w-2*q.y*q.z , 1 - 2*sqx - 2*sqz),\n\t\tatan2(2*q.y*q.w-2*q.x*q.z , 1 - 2*sqy - 2*sqz),\n\t\tasin(2*test));\r\n}\r\nout1 = ax * RADTODEG;",
					"fontface" : 0,
					"fontname" : "<Monospaced>",
					"fontsize" : 12.0,
					"id" : "obj-34",
					"maxclass" : "codebox",
					"numinlets" : 1,
					"numoutlets" : 1,
					"outlettype" : [ "" ],
					"patching_rect" : [ 21.0, 245.0, 506.0, 315.0 ]
				}

			}
, 			{
				"box" : 				{
					"id" : "obj-3",
					"maxclass" : "newobj",
					"numinlets" : 1,
					"numoutlets" : 0,
					"patching_rect" : [ 21.0, 574.5, 35.0, 22.0 ],
					"text" : "out 1"
				}

			}
, 			{
				"box" : 				{
					"id" : "obj-48",
					"maxclass" : "comment",
					"numinlets" : 1,
					"numoutlets" : 0,
					"patching_rect" : [ 244.0, 18.0, 55.0, 20.0 ],
					"text" : "prev pos"
				}

			}
, 			{
				"box" : 				{
					"id" : "obj-47",
					"maxclass" : "comment",
					"numinlets" : 1,
					"numoutlets" : 0,
					"patching_rect" : [ 114.5, 18.0, 69.0, 20.0 ],
					"text" : "current pos"
				}

			}
, 			{
				"box" : 				{
					"id" : "obj-1",
					"maxclass" : "newobj",
					"numinlets" : 0,
					"numoutlets" : 1,
					"outlettype" : [ "" ],
					"patching_rect" : [ 83.0, 18.0, 28.0, 22.0 ],
					"text" : "in 1"
				}

			}
, 			{
				"box" : 				{
					"id" : "obj-2",
					"maxclass" : "newobj",
					"numinlets" : 0,
					"numoutlets" : 1,
					"outlettype" : [ "" ],
					"patching_rect" : [ 214.0, 18.0, 28.0, 22.0 ],
					"text" : "in 2"
				}

			}
 ],
		"lines" : [ 			{
				"patchline" : 				{
					"destination" : [ "obj-5", 0 ],
					"source" : [ "obj-1", 0 ]
				}

			}
, 			{
				"patchline" : 				{
					"destination" : [ "obj-5", 1 ],
					"source" : [ "obj-2", 0 ]
				}

			}
, 			{
				"patchline" : 				{
					"destination" : [ "obj-3", 0 ],
					"source" : [ "obj-34", 0 ]
				}

			}
, 			{
				"patchline" : 				{
					"destination" : [ "obj-7", 0 ],
					"source" : [ "obj-4", 0 ]
				}

			}
, 			{
				"patchline" : 				{
					"destination" : [ "obj-6", 0 ],
					"source" : [ "obj-5", 0 ]
				}

			}
, 			{
				"patchline" : 				{
					"destination" : [ "obj-8", 0 ],
					"source" : [ "obj-6", 0 ]
				}

			}
, 			{
				"patchline" : 				{
					"destination" : [ "obj-34", 0 ],
					"source" : [ "obj-7", 0 ]
				}

			}
, 			{
				"patchline" : 				{
					"destination" : [ "obj-7", 1 ],
					"source" : [ "obj-8", 0 ]
				}

			}
 ],
		"autosave" : 0
	}

}
