<?xml version="1.0" encoding="UTF-8"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

			>

	<channel>
		<title>Cycling 74  &#187;  Topic: How to apply a quaternion rotation to many objects ?</title>
		<atom:link href="http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/feed" rel="self" type="application/rss+xml" />
		<link>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/feed</link>
		<description></description>
		<pubDate>Wed, 19 Jun 2013 13:55:49 +0000</pubDate>
		<generator>http://bbpress.org/?v=2.2.4</generator>
		<language></language>

		
														
					
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-46072</guid>
					<title><![CDATA[How to apply a quaternion rotation to many objects ?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-46072</link>
					<pubDate>Thu, 21 Jun 2012 12:52:03 +0000</pubDate>
					<dc:creator>Julien Bayle</dc:creator>

					<description>
						<![CDATA[
						<p>Hi there,</p>
<p>I need to apply a quaternion rotation to many objects.</p>
<p>Thus, I have to apply a quaternion rotation to a 3 planes (x,y,z) matrix containing objects positions</p>
<p>I need to :<br />
- convert the quaternion to a rotation matrix ( this helps <a href="http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToMatrix/index.htm" rel="nofollow">http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToMatrix/index.htm</a>)<br />
- multiply the rotation matrix by each triplets x,y,z</p>
<p>Basically, I&#39;d prefer to use only 1 jit.gen to calculate the rotation matrix, then I&#39;ll apply the rotation outside of gen world, multiplying the rotation matrix by the positions one.</p>
<p>How can I create the 3&#215;3 rotation matrix using jit.gen ?<br />
I have all the calculations ready etc, but I don&#39;t know how to wire stuff or objects to use to pop out .. a 3&#215;3 matrix.</p>
<p>Anyone would help here?</p>
<p> [attachment=197165,4071]</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165944</guid>
					<title><![CDATA[Re: How to apply a quaternion rotation to many objects ?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165944</link>
					<pubDate>Thu, 21 Jun 2012 14:04:51 +0000</pubDate>
					<dc:creator>Julien Bayle</dc:creator>

					<description>
						<![CDATA[
						<p>I tried to concatenate my 3 outputs, which provides a 3 triplets elements..<br />
So I tried to glue, which provides a nice 3&#215;3 matrices (afaik ?! :D)</p>
<p>but now, stuck in jit.gen&#8230;.<br />
nothing seems to be produced.<br />
I restarted max, was thinking about a mess I did<br />
nothing.</p>
<p>Anyone would point me to my problem ..?</p>
<p>Any help would be much than appreciate :)</p>
<p> [attachment=197171,4072]</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165945</guid>
					<title><![CDATA[Re: How to apply a quaternion rotation to many objects ?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165945</link>
					<pubDate>Thu, 21 Jun 2012 14:09:19 +0000</pubDate>
					<dc:creator>Julien Bayle</dc:creator>

					<description>
						<![CDATA[
						<p>this wouldn&#39;t be complete without that.</p>
<p>Indeed, I tried to setup the jit.gen param as I thought but maybe the problem comes from here..</p>
<p> [attachment=197173,4073]</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165946</guid>
					<title><![CDATA[Re: How to apply a quaternion rotation to many objects ?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165946</link>
					<pubDate>Thu, 21 Jun 2012 18:04:07 +0000</pubDate>
					<dc:creator>Rob Ramirez</dc:creator>

					<description>
						<![CDATA[
						<p>to apply the same quaternion rotation to several objects, you can simply apply the rotation to the parent node (jit.anim.node or jit.gl.node).</p>
<p>if this isn&#8217;t clear, let me know and i&#8217;ll show you an example.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165947</guid>
					<title><![CDATA[Re: How to apply a quaternion rotation to many objects ?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165947</link>
					<pubDate>Thu, 21 Jun 2012 18:55:37 +0000</pubDate>
					<dc:creator>Julien Bayle</dc:creator>

					<description>
						<![CDATA[
						<p>it is pretty clear Robert.</p>
<p>I didn&#8217;t explain why I wanted to make that.<br />
Basically, I encountered the gimbal lock problem when I calculated azimuth/elevation for each object relatively to the cam. it happened for position when the object was up above, or under the cam (singularities of atan2 in the azimuth calculation)<br />
Then, I wanted to go further and use quaternion.</p>
<p>The matrix to which I need to apply my quat rot is a global named matrix in which I have ALL my objects&#8217; coordinates.<br />
I doubt I could simplify it.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165948</guid>
					<title><![CDATA[Re: How to apply a quaternion rotation to many objects ?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165948</link>
					<pubDate>Fri, 22 Jun 2012 07:51:56 +0000</pubDate>
					<dc:creator>Julien Bayle</dc:creator>

					<description>
						<![CDATA[
						<p>I didn&#8217;t even achieve this :-(</p>
<p>objects coordinates matrix is 3 planes 1xN (N number of objects)<br />
rotation matrix is 1 plane 3&#215;3</p>
<p>how can I &#8230; apply this rotation  matrix to all my objects &#8230;?</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165949</guid>
					<title><![CDATA[Re: How to apply a quaternion rotation to many objects ?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165949</link>
					<pubDate>Fri, 22 Jun 2012 19:04:01 +0000</pubDate>
					<dc:creator>Julien Bayle</dc:creator>

					<description>
						<![CDATA[
						<p>I guess this can work:</p>
<div><span id="toggle165949-0" class="patchtoggle" onmousedown="toggleMaxPatch('post165949-0', 'er165949-0');">&#8211; Pasted Max <span id="maxversion165949-0"></span> Patch, click to <span id="er165949-0">expand</span>. &#8211;</span> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"  width="110" height="14" class="clippy" ><param name="allowScriptAccess" value="always" /><param name="quality" value="high" /><param name="scale" value="noscale" /><param NAME="FlashVars" value="copied=copied!&#038;copyto=copy to clipboard"/><param name="bgcolor" value="#FFFFFF"/><param name="wmode" value="opaque"/><embed src="/wp-content/plugins/bbpress-copy-compressed/clippy.swf"  width="110" height="14"   name="clippy"  quality="high"  allowScriptAccess="always"  type="application/x-shockwave-flash"  pluginspage="http://www.macromedia.com/go/getflashplayer"  FlashVars="text=----------begin_max5_patcher----------%0A453.3ocyV9rbBBCDF%2BL7TjImoLPPnZO09Fz6cbbhPTiMjvPBVac7cujEvZcn%0AyfsUaufr69Q1O9k%2Bf6bcvyUaYZL5NzSHGmctNNPJaBm1XGbNcapfpAYXI6E0%0A70XulRF1VCjdM23Kn94UBSWMdFToV8M2F0kbgRZjzbFT5gRNUzUQVkykBlAZ%0AC4H4Z9af7PhevGZUUlSE2jx7ZAq4ExZpY4TSIeK1CgwnosBKnlzUb4xYkrTS%0Ai1vX%2BXu5V.%2BDOttSHRfe.Zp8I165Zu38yQzRQECcepRTkK0nndPUxjyDUQ%2BM%0AnZBA.VcvEBUUxBZ5y8QnwmIgBOGBEOLBM7nAvxjHKDufrrwMnRko9NTHZgPQ%0AMQDTTuKAiRtj.92XIHYDPr10fIjKL2pKW2Z8iJM2vU1MtGHXHJYTOHjDD7em%0Agsm30rliD1KBgmGK3xS%2BFALd17elqZUUYZmWNvATvAejwzFtjZo3Qpr6nORz%0AJdVFCp281mw0z4BFv2fdmhGpgNoUegelbc8S3P7S30yOjg3Gx0wOSFv7k8uW%0AbklurmMNL%2B7cluZ1uQKJ1vJ0siIXk5SrVqJsgIdPHW1DBiHtjsg2oO10NZ6c%0AeGPIHR0u%0A-----------end_max5_patcher-----------&#038;copied=copied!&#038;;copyto=copy to clipboard"  bgcolor="#ffffff"  wmode="opaque" /> </object></div>
<div id="post165949-0" style="display:none;visibility:hidden;" >
<div class="patchtoggleInfo"><small>Copy <b>all</b> of the following text.Then, in Max, select <em>New From Clipboard</em>.</small></div>
<div class="patchtogglediv">
<pre><code id="pastedcode165949-0">----------begin_max5_patcher----------
453.3ocyV9rbBBCDF+L7TjImoLPPnZO09Fz6cbbhPTiMjvPBVac7cujEvZcn
yfsUaufr69Q1O9k+f6bcvyUaYZL5NzSHGmctNNPJaBm1XGbNcapfpAYXI6E0
70XulRF1VCjdM23Kn94UBSWMdFToV8M2F0kbgRZjzbFT5gRNUzUQVkykBlAZ
C4H4Z9af7PhevGZUUlSE2jx7ZAq4ExZpY4TSIeK1CgwnosBKnlzUb4xYkrTS
i1vX+Xu5V.+DOttSHRfe.Zp8I165Zu38yQzRQECcepRTkK0nndPUxjyDUQ+M
nZBA.VcvEBUUxBZ5y8QnwmIgBOGBEOLBM7nAvxjHKDufrrwMnRko9NTHZgPQ
MQDTTuKAiRtj.92XIHYDPr10fIjKL2pKW2Z8iJM2vU1MtGHXHJYTOHjDD7em
gsm30rliD1KBgmGK3xS+FALd17elqZUUYZmWNvATvAejwzFtjZo3Qpr6nORz
JdVFCp281mw0z4BFv2fdmhGpgNoUegelbc8S3P7S30yOjg3Gx0wOSFv7k8uW
bklurmMNL+7cluZ1uQKJ1vJ0siIXk5SrVqJsgIdPHW1DBiHtjsg2oO10NZ6c
eGPIHR0u
-----------end_max5_patcher-----------</code></pre></div>
</div>
<p> [attachment=197374,4078]</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165950</guid>
					<title><![CDATA[Re: How to apply a quaternion rotation to many objects ?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165950</link>
					<pubDate>Fri, 22 Jun 2012 20:15:58 +0000</pubDate>
					<dc:creator>Julien Bayle</dc:creator>

					<description>
						<![CDATA[
						<p>a little improvement that provides me the way to process the 3 planes resulting matrix in my same jit.gen</p>
<p>BUT &#8230; the last one is 4 planes&#8230; I expected 3.<br />
I can unpack 4 to pack 3 .. but why does it contain 4 &#8230;?</p>
<p> [attachment=197387,4079]</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165951</guid>
					<title><![CDATA[Re: How to apply a quaternion rotation to many objects ?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165951</link>
					<pubDate>Fri, 22 Jun 2012 20:21:39 +0000</pubDate>
					<dc:creator>Julien Bayle</dc:creator>

					<description>
						<![CDATA[
						<p>okay.<br />
here is the solution: use jit.pack correctly.</p>
<p>replacing the last [jit.pack] by [jit.pack 3] and it is okay.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165952</guid>
					<title><![CDATA[Re: How to apply a quaternion rotation to many objects ?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165952</link>
					<pubDate>Sat, 23 Jun 2012 00:29:59 +0000</pubDate>
					<dc:creator>Julien Bayle</dc:creator>

					<description>
						<![CDATA[
						<p>if it seemed to work, I tested and my azimuths aren&#39;t correct :-(<br />
I tested just by looking by the jit.window&#8230; 180° or 0° would mean the object projection on cam plane  is &#8220;in front of me&#8221;..<br />
With 2 objects only, in order to not mess all, it doesn&#39;t work.</p>
<p>Before to forget about that part and to work on another part because of own saturation, here is exactly what I&#39;m trying to do.<br />
I hope a comprehensive saint guru wise dude could push me into the right way&#8230;</p>
<p>I need to calculate azimuth &#038; elevation of objects relatively to my camera direction/plane.<br />
Using only the 3 Euler angles to do that doesn&#39;t seem to be enough because of gimbal lock/singularities.</p>
<p>So I decided to go to quaternions.<br />
I attached a snapshot.<br />
I&#39;m requesting position &#038; quaternion in the scheduler (global qmetro)<br />
I&#39;m sending both + the objects matrix to the jit.gen.</p>
<p>The codebox&#39; code comes from this <a href="http://fr.wikipedia.org/wiki/Quaternions_et_rotation_dans_l&#039;espace#M.C3.A9thodes_utilis.C3.A9es" rel="nofollow">http://fr.wikipedia.org/wiki/Quaternions_et_rotation_dans_l&#039;espace#M.C3.A9thodes_utilis.C3.A9es</a><br />
I verified and indeed, the quaternion rotation for vector calculation is ok.<br />
Then, I&#39;m taking the resulting vector x and z component to calculate the azimuth via atan2.</p>
<p>Why am I thinking azimuth is wrong?<br />
Whatever the position &#038; rotation of my cam, if I keep the object in the center of my window, the azimuth should be the same, right ??</p>
<p>It doesn&#39;t seem to be the case here :-/</p>
<p>Where am I doing wrong ?<br />
any ideas, leads, help, hands would be totally appreciate at this late hour or later of course :)</p>
<p>I&#39;m almost despaired about this part.</p>
<p> [attachment=197409,4080]</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165953</guid>
					<title><![CDATA[Re: How to apply a quaternion rotation to many objects ?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165953</link>
					<pubDate>Sat, 23 Jun 2012 12:39:26 +0000</pubDate>
					<dc:creator>Julien Bayle</dc:creator>

					<description>
						<![CDATA[
						<p>I guess the quaternion I&#8217;m grabbing is not the good one &#8230; I don&#8217;t have other explanations and I wouldn&#8217;t have more (considering my fresh discovering of quaternion)</p>
<p>btw, I can add something which could sound like a clue.<br />
if the cam is reset by anim_reset message, it came back to initial position BUT especially orientation.<br />
In this orientation and if I stay in the plane of the cam (I mean if I don&#8217;t go a bit up or down but only forward/backward/left &#038; right/panning left right, then my system works perfectly : azimuths are relevant etc.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165954</guid>
					<title><![CDATA[Re: How to apply a quaternion rotation to many objects ?]]></title>
					<link>http://cycling74.com/forums/topic/how-to-apply-a-quaternion-rotation-to-many-objects/#post-165954</link>
					<pubDate>Sat, 23 Jun 2012 16:37:51 +0000</pubDate>
					<dc:creator>Julien Bayle</dc:creator>

					<description>
						<![CDATA[
						<p>So, some statements.<br />
Someone in gamedev.net forum answered me about Gimbal lock/quaternion/rotation.</p>
<p>First, I read this : <a href="http://www.gamedev.net/page/resources/_/technical/math-and-physics/quaternion-powers-r1095" rel="nofollow">http://www.gamedev.net/page/resources/_/technical/math-and-physics/quaternion-powers-r1095</a><br />
Here is the process to make rotation with quaternions to avoid Gimbal Lock:</p>
<blockquote><p>
The main point you should take note (in the while loop) is<br />
- The orientation of the camera is a quaternion.<br />
- There are 3 angles corresponding to the keypress. Note the angles are meant to be an on/off switch (not accumulative). I reset them inside the while loop. Of course this is not the best way to do it but as I said, it is a quick job.<br />
- I convert the 3 angles to a temporary quaternion.<br />
- I multiply the temporary quaternion to the camera quaternion to obtain the combined orientation. Note the order of multiplication.<br />
- The camera rotation is then converted to the Axis Angle representation for transforming the final matrix.<br />
When a key is pressed, I generate a temporary quaternion corresponding to the key for a small rotation in that particular axis. I then multiply the temporary quaternion into the camera quaternion. This concatenation of rotations in 4D space will avoid gimbal lock. Try it and see for yourself.</p>
</blockquote>
<p>In my system, as shown on the patch picture, I&#8217;m grabbing the cam quaternion and this is that one I convert to matrix and I apply it to all my objects coordinates.<br />
This is that resulting vector I&#8217;m taking for my atan2 based azimuth calculation.</p>
<p>I don&#8217;t use the temporary vector at all. Maybe my problem comes from here.<br />
I don&#8217;t use it because my system provides me directly the quaternion from the cam.</p>
<p>An user answered me about the fact I didn&#8217;t use the temporary vector and it is very interesting for me :</p>
<blockquote><p>That&#8217;s the key to avoiding gimbal lock. You need to have some representation of the current attitude and modify it with incremental rotations around the axes. Whether you use quaternions or some other representation is secondary.</p>
<p>If you keep track of a cumulative roll, pitch and yaw and then compose them into an overall rotation, you&#8217;ll run into gimbal lock regardless of what representation you use. </p>
</blockquote>
<p>I&#8217;m not sure about &#8220;incremental rotations around axes&#8221;</p>
<p>Robert, how should I translate it into my system ?<br />
I thought jit.anim.drive would do that.</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

