<?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/6618" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2011-04-11T06:46:32+00:00</updated>

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

		<entry>
		<author><name><![CDATA[Jim Offerman]]></name></author>
		<updated>2011-04-11T06:46:32+00:00</updated>

		<published>2011-04-11T06:46:32+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=22997#p22997</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=22997#p22997"/>
		<title type="html"><![CDATA[Re: How to compute torque needed to rotate to a point]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=22997#p22997"><![CDATA[
Works now!<br><br>I finally settled on using the local-space heading and elevation angles to compute delta, which produces stable results for me. I still get some overshoot when the angles between the current heading and target are &gt;90 degrees, but for frame-to-frame course correction it works very well.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=8012">Jim Offerman</a> — Mon Apr 11, 2011 6:46 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Jim Offerman]]></name></author>
		<updated>2011-04-09T10:49:03+00:00</updated>

		<published>2011-04-09T10:49:03+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=22983#p22983</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=22983#p22983"/>
		<title type="html"><![CDATA[Re: How to compute torque needed to rotate to a point]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=22983#p22983"><![CDATA[
Thanks for the tip! I've copied the delta axis/angle calculations from the calculateDiffAxisAngle() call in calculateVelocity:<br><div class="codebox"><p>Code: </p><pre><code>// Get current orientationMatrix basis0 = entity.Orientation();// Compute desired orientationVector3 az = (point - pos).Normalized();Vector3 ax = Cross(entity.Up(), az).Normalized();if (ax.LengthSquared() &lt; FLT_EPSILON * FLT_EPSILON)ax = Vector3(1.f, 0.f, 0.f);Vector3 ay = Cross(az, ax).Normalized();Matrix basis1(ax.x, ay.x, az.x, 0.f,  ax.y, ay.y, az.y, 0.f,  ax.z, ay.z, az.z, 0.f,  0.f,  0.f,  0.f,  1.f);// Code copied from calculateDiffAxisAngle()Quaternion dorn = basis1 * basis0.Inverse();dorn.Normalize();float angle = dorn.Angle();Vector3 axis(dorn.x, dorn.y, 0.f/*dorn.z*/);float len2 = axis.LengthSquared();if (len2 &lt; FLT_EPSILON * FLT_EPSILON)axis = Vector3(1.f, 0.f, 0.f);elseaxis /= Sqrt(len2);Vector3 delta = axis * angle;...</code></pre></div>Unfortunately, this makes my function even more unstable <img class="smilies" src="https://pybullet.org/Bullet/phpBB3/images/smilies/icon_sad.gif" width="15" height="15" alt=":(" title="Sad"><br>Anything else I could be doing wrong?<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=8012">Jim Offerman</a> — Sat Apr 09, 2011 10:49 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Erwin Coumans]]></name></author>
		<updated>2011-04-08T16:24:51+00:00</updated>

		<published>2011-04-08T16:24:51+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=22968#p22968</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=22968#p22968"/>
		<title type="html"><![CDATA[Re: How to compute torque needed to rotate to a point]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=22968#p22968"><![CDATA[
Checkout calculateVelocity in src/LinearMath/btTransformUtil.cpp<br><br>Thanks,<br>Erwin<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2">Erwin Coumans</a> — Fri Apr 08, 2011 4:24 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Jim Offerman]]></name></author>
		<updated>2011-04-08T06:53:12+00:00</updated>

		<published>2011-04-08T06:53:12+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=22961#p22961</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=22961#p22961"/>
		<title type="html"><![CDATA[How to compute torque needed to rotate to a point]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=22961#p22961"><![CDATA[
I've been trying to write a function that computes how much torque must be applied to rotate a rigidbody to face a certain point:<br><div class="codebox"><p>Code: </p><pre><code>void RigidBody::RotateToPoint(const Vector3&amp; point, float maxTorque){const Entity&amp; entity = GetEntity();// Angular distance between current orientation and desired orientation.Vector3 localDir = entity.PointToLocal(point).Normalized();float x = atan2f(localDir.y, localDir.z);float y = 0.f; // atan2f(localDir.z, localDir.x);float z = 0.f; // atan2f(localDir.y, localDir.z);Vector3 delta = entity.VectorToWorld(Vector3(x, y, z));// Compute the angular velocity we need to reach the point in t seconds.float t = Time_GetDeltaTime();Vector3 omega = delta / t;// Subtract current velocityomega -= GetAngularVelocity();// Compute acceleration needed to reach new velocity in t seconds.Vector3 alpha = omega / t;// Compute torque needed to achieve accelerationMatrix I = GetWorldInertiaTensor();Vector3 tau = I * alpha;// Don't exceed our limitif (tau.Length() &gt; maxTorque)tau = tau.Normalized() * maxTorque;// Go!ApplyTorque(tau);}</code></pre></div>(RigidBody is a thin wrapper around btRigidBody that hooks it into my engine's component system and takes care of right-handed &lt;-&gt; left-handed conversions)<br><br>The above code works as long as I restrict my calculations to a single axis. Unfortunately, it completely breaks down when I try the general version.<br><br>I suspect the problem is in how I compute the angular distance that the body must travel. Could any of you help me out with that?<br><br>thanks,<br>Jim.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=8012">Jim Offerman</a> — Fri Apr 08, 2011 6:53 am</p><hr />
]]></content>
	</entry>
	</feed>
