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

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2013-11-18T11:44:51+00:00</updated>

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

		<entry>
		<author><name><![CDATA[b0gd4n]]></name></author>
		<updated>2013-11-18T11:44:51+00:00</updated>

		<published>2013-11-18T11:44:51+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32184#p32184</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32184#p32184"/>
		<title type="html"><![CDATA[get direction vector from btScalar matrix]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32184#p32184"><![CDATA[
I have created a bullet vehicle with a compound as the chassis and the compound is formed of 2 bodies, a chassis and a turret.<br><br><br>I can obtain the turret transform and opengl matrix like this:<br><div class="codebox"><p>Code: </p><pre><code>    // get chassis and turret transformsbtTransform chassisTransform = m_vehicle-&gt;getChassisWorldTransform();btTransform turretTransform = compound-&gt;getChildTransform(1);// multiply transforms to get updated turret transformturretTransform *= chassisTransform;// get turret matrixbtScalar turretMatrix[16];turretTransform.getOpenGLMatrix(turretMatrix);</code></pre></div>I am trying to get the turret forward/direction vector from this matrix. I need this so that I will have the camera fixed to the turret's position and direction.<br><br>What I have tried is this:<br>    <div class="codebox"><p>Code: </p><pre><code>btVector3 turretForwardVector = btVector3(turretMatrix[2], turretMatrix[6], turretMatrix[9]);</code></pre></div>But this doesn't give me the right vector.<br>Could someone please point out where exactly do I have to look for the vector in this matrix?<br><br><br>EDIT:<br><br>I managed to find this [link](<a href="http://www.opengl.org/discussion_boards/showthread.php/175515-Get-Direction-from-Transformation-Matrix-or-Quat" class="postlink">http://www.opengl.org/discussion_boards ... ix-or-Quat</a>). It explained where I would find the direction vector in the matrix (3rd column).<br><br>So I got the 8th, 9th and 10th matrix elemets and created the turretForwardMatrix from that like this:<br><div class="codebox"><p>Code: </p><pre><code>btVector3 turretForwardVector = btVector3(turretMatrix[8], turretMatrix[9], turretMatrix[10]);</code></pre></div><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=10543">b0gd4n</a> — Mon Nov 18, 2013 11:44 am</p><hr />
]]></content>
	</entry>
	</feed>
