<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/13166" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2021-02-23T23:12:50+00:00</updated>

	<author><name><![CDATA[Real-Time Physics Simulation Forum]]></name></author>
	<id>https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/13166</id>

		<entry>
		<author><name><![CDATA[drleviathan]]></name></author>
		<updated>2021-02-23T23:12:50+00:00</updated>

		<published>2021-02-23T23:12:50+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43331#p43331</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43331#p43331"/>
		<title type="html"><![CDATA[Re: rotation format in bullet physics]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43331#p43331"><![CDATA[
<blockquote class="uncited"><div>is there a way to efficiently integrate the rotation with this vector?</div></blockquote>Do you mean: "Given some initial rotation <strong class="text-strong">Q0</strong> and a non-zero angular velocity <strong class="text-strong">W</strong>... is it possible to compute the rotation <strong class="text-strong">Q(t)</strong> as time progresses forward?"<br><br>If so then: yes.  In fact, that is what Bullet does: RigidBody dynamics.  It has an integration step which computes future rotations.  The details there are a bit more complicated than my paraphrased and hypothetical question since you also need to know the body's <strong class="text-strong">InertiaTensor</strong> (angular mass distribution).  Depending on the symmetry of the Body the <strong class="text-strong">AngularVelocity</strong> might not be uniform over time for a freely tumbling object but the <strong class="text-strong">AngularMomentum</strong> would be conserved (e.g. would be invariant).<br><br>Perhaps you should describe what you really want to do and then then your questions might become more clear.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11033">drleviathan</a> — Tue Feb 23, 2021 11:12 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[pwouik]]></name></author>
		<updated>2021-02-23T21:06:14+00:00</updated>

		<published>2021-02-23T21:06:14+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43330#p43330</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43330#p43330"/>
		<title type="html"><![CDATA[Re: rotation format in bullet physics]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43330#p43330"><![CDATA[
so if I understand well,"adding" angular velocities is commutative,in contrary to rotations,and we can use for that a vector collinear to the axis of the rotation,with the norm the velocity in radians(as i understand in the code)<br>ok,I just found that:<a href="https://en.wikipedia.org/wiki/Angular_velocity#Addition_of_angular_velocity_vectors" class="postlink">https://en.wikipedia.org/wiki/Angular_v ... ty_vectors</a> so it seems to be that<br>is there a way to efficiently integrate the rotation(with a rotation matrix because it's a school project and i want to stay on the program) with this vector?<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=13916">pwouik</a> — Tue Feb 23, 2021 9:06 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[drleviathan]]></name></author>
		<updated>2021-02-23T19:03:16+00:00</updated>

		<published>2021-02-23T19:03:16+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43328#p43328</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43328#p43328"/>
		<title type="html"><![CDATA[Re: rotation format in bullet physics]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43328#p43328"><![CDATA[
<strong class="text-strong">AngularVelocity</strong> is indeed a <strong class="text-strong">btVector3</strong>, however its units are <strong class="text-strong">radians/second</strong>.  It represents the rate of change of the rotation... not the rotation.  Perhaps you had a question about <strong class="text-strong">AngularVelocity</strong>?<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11033">drleviathan</a> — Tue Feb 23, 2021 7:03 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[pwouik]]></name></author>
		<updated>2021-02-23T18:03:36+00:00</updated>

		<published>2021-02-23T18:03:36+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43327#p43327</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43327#p43327"/>
		<title type="html"><![CDATA[Re: rotation format in bullet physics]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43327#p43327"><![CDATA[
in btRigidBody.h,angles seem to be stored in a btVector3:<div class="codebox"><p>Code: </p><pre><code>btVector3 m_linearVelocity;btVector3 m_angularVelocity;</code></pre></div>also in this function:<div class="codebox"><p>Code: </p><pre><code>void applyTorqueImpulse(const btVector3&amp; torque){m_angularVelocity += m_invInertiaTensorWorld * torque * m_angularFactor;#if defined(BT_CLAMP_VELOCITY_TO) &amp;&amp; BT_CLAMP_VELOCITY_TO &gt; 0clampVelocity(m_angularVelocity);#endif</code></pre></div>computation are made on a btVector3<br>how is stored for example m_angularVelocity?<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=13916">pwouik</a> — Tue Feb 23, 2021 6:03 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[drleviathan]]></name></author>
		<updated>2021-02-23T16:53:15+00:00</updated>

		<published>2021-02-23T16:53:15+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43326#p43326</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43326#p43326"/>
		<title type="html"><![CDATA[Re: rotation format in bullet physics]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43326#p43326"><![CDATA[
Bullet stores both position and rotation in a <strong class="text-strong">btTransform</strong> which is a 4x4 matrix under the hood.  You can extract just the rotation part into a normalized <strong class="text-strong">btQuaternion</strong> which is a 4D "vector".  The components of a Quaternion are NOT the normalized_axis + angle, however with some practice you can "eyeball" a Quaternion to get an idea of what the axis and rotation are.<br><br>Quaternions are useful because it is relatively easy to do rotation math with them to obtain other rotations.  Once you're done with rotation math you would take the <strong class="text-strong">finalQuaternion</strong> and do something like this:<br><div class="codebox"><p>Code: </p><pre><code>transform.setRotation(finalQuaternion);body-&gt;setTransform(transform);</code></pre></div>There are many tutorials about Quaternions online, however I will offer a crash course on them here:<br><br><strong class="text-strong">(1)</strong> Quaternions in general span all of 4D space, however when it comes to rotations we are only concerned with those Quaternions which live on the surface of the unit hypersphere: centered at the origin with radius = 1.<br><br><strong class="text-strong">(2)</strong> The subset of Quaternions on the unit hypersphere form a "Group" (research "Group Theory" for more about what this means) under some operator we will call "multiplication".  In other words, when you "multiply" two elements in the Group the result is another element of the Group.<br><br><strong class="text-strong">(3)</strong> There is an isomorphism (sorta) between the Group of unit Quaternions and the Group of Rotations in 3D.  In other words, the two Groups behave in the same way under the multiplication operator.  This is why unitary Quaternions are so useful in 3D math.<br><br><strong class="text-strong">(4)</strong> The "sorta" qualifier is there because really there is a 2-to-1 mapping from Quaternion space to Rotations.  For each valid Rotation there are two Quaternions that represent it, and these Quaternions are at opposite ends of the hypersphere: Q and -Q.  This fact matters sometimes when you're doing interpolation from one Quaternion to another, but usually you can forget about it.<br><br><strong class="text-strong">(5)</strong> Internally the Quaternion has four elements: <strong class="text-strong">&lt;x,y,z,w&gt;</strong>.  In code: some Quaternion implementations might order them <strong class="text-strong">&lt;w,x,y,z&gt;</strong> but the <strong class="text-strong">btQuaternion</strong> ctor which takes four floats orders them <strong class="text-strong">&lt;x,y,z,w&gt;</strong>.  The <strong class="text-strong">&lt;x,y,z&gt;</strong> components are called the "imaginary" part, similar to the "imaginary number '<strong class="text-strong">i</strong>' you learned in high school) but in this case there are three distinct imaginary axes and they are often referred to as <strong class="text-strong">&lt;i,j,k&gt;</strong>.  The <strong class="text-strong">&lt;w&gt;</strong> component is known as the "real part".<br><br><strong class="text-strong">(6)</strong> The identity <strong class="text-strong">btQuaternion</strong> (zero rotation) has the form: <strong class="text-strong">&lt;0,0,0,1&gt;</strong><br><br><strong class="text-strong">(7)</strong> For a rotation of <strong class="text-strong">A</strong> radians about a normalized axis <strong class="text-strong">&lt;X,Y,Z&gt;</strong> the corresponding <strong class="text-strong">btQuaternion</strong> has components: <strong class="text-strong">&lt;sX, sY, sZ, c&gt;</strong> (and its negative as per item <strong class="text-strong">(4)</strong>) where: <strong class="text-strong">s = sin(A/2)</strong> and <strong class="text-strong">c=cos(A/2)</strong>.  Knowing this, with some practice you can "eyeball" the components of a <strong class="text-strong">btQuaternion</strong> to get an idea as to what sort of rotation it represents.  For example:<br><br><strong class="text-strong">&lt;1,0,0,0&gt;</strong> = pi radians about X-axis<br><strong class="text-strong">&lt;0,1,0,0&gt;</strong> = pi radians about Y-axis<br><strong class="text-strong">&lt;sqrt(2)/2, 0, 0, sqrt(2)/2&gt;</strong> = pi/2 radians about X-axis<br><br>There are some common "gotchas" when working with <strong class="text-strong">btQuaternions</strong> in code.  Here are some:<br><br><strong class="text-strong">(8)</strong> Due to floating point error a <strong class="text-strong">btQuaternion</strong> probably doesn't lie on the unit hypersphere, but it is close.  Consequently the product of two <strong class="text-strong">btQuaternions</strong>: <strong class="text-strong">Q1*Q2</strong> can drift even further from the sphere.  Normally this isn't a problem, but if you ever find yourself recycling a <strong class="text-strong">btQuaternion</strong> to compute its next value then it will eventually explode off the sphere... unless you constantly normalize.  In other words:<div class="codebox"><p>Code: </p><pre><code>Q = Q * deltaQ;   // BAD!Q = (Q * deltaQ).normalize(); // GOOD!</code></pre></div>If you're going to use the result then discard it, don't normalize, but if you're going to save the <strong class="text-strong">btQuaternion</strong> for the next loop then normalize it every loop.  Note, this is not a problem if you're "storing" the <strong class="text-strong">btQuaternion</strong> in a <strong class="text-strong">btTrasnform</strong> because normalization automatically happens when storing the rotation into the 4x4 matrix.<br><br><strong class="text-strong">(9)</strong> Bullet does not provide a convenient operator between <strong class="text-strong">btQuaternion</strong> and <strong class="text-strong">btVector3</strong>.  It is implemented but probably doesn't do what you think: it doesn't just rotate the vector.  To rotate a <strong class="text-strong">btVector3</strong> in Bullet first store the rotation into a <strong class="text-strong">btTransform</strong> and use that.<br><br><strong class="text-strong">(10)</strong> Rotations do not commute, so order matters.  When doing rotation math you need to figure out if it is <strong class="text-strong">Q1*Q2</strong> or <strong class="text-strong">Q2*Q1</strong>.  My advice for this is to always imagine the rotations operating from the LEFT on a hypothetical vector on the RIGHT.  So:  consider it like so:  <strong class="text-strong">Q1 * Q2 * v</strong><br>The question becomes: Which rotation should operate first?  That one always goes RIGHT-most, and subsequent rotations operate from RIGHT to LEFT order.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11033">drleviathan</a> — Tue Feb 23, 2021 4:53 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[pwouik]]></name></author>
		<updated>2021-02-23T14:59:28+00:00</updated>

		<published>2021-02-23T14:59:28+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43325#p43325</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43325#p43325"/>
		<title type="html"><![CDATA[rotation format in bullet physics]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=43325#p43325"><![CDATA[
Hello, searching in src/BulletDynamics/Dynamics/btRigidBody.cpp, it seems that bullet use a 3D vector for rotation, representing the axis of rotation and the angle with the norm.It seems very practical because it's directly given by a cross product when applying an impulse ,and we can add them to combine them.<br>What is the name of this,and how can we make a rotation matrix from it?<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=13916">pwouik</a> — Tue Feb 23, 2021 2:59 pm</p><hr />
]]></content>
	</entry>
	</feed>
